2011-06-01から1ヶ月間の記事一覧

ラクダ式とアンダースコア式の変換

$ rails c Loading development environment (Rails 3.0.1) irb(main):001:0> "hoge_foo".camelize => "HogeFoo" irb(main):002:0> "HogeFoo".underscore => "hoge_foo"tableize ってのもある。 あたり。 参考URL camelizeとunderscore | GENDOSU@NET

通貨のフォーマット

環境 Rails 3.0系 やり方 設定(config/locales/ja.yml) currency: format: format: "%n%u" unit: "円" separator: "." delimiter: "," precision: 0 significant: false strip_insignificant_zeros: falseprecision を 3 から 0 に変更します。 表示(erb…

PoderosaにHomeとEndキーの設定

環境 OS Windows7 64ビット Poderosa 4.1.0 手順 [ツール] → [オプション] → [操作] → [追加キー定義] Home=0x1B[1~, End=0x1B[4~ でOK。 参考URL index - Terminal Emulator Poderosa cygwin@Windows 7 64bit | Mazn.net

アプリ共通の定数

config/initializers/constants.rb を作成。 constants.rb # -*- coding: utf-8 -*- # 共通で利用する定数を定義 module Constants HOGE = 1 FOO = 2 end Constants::HOGEで参照できます。 参考URL コチョナナバ: Railsでグローバルな定数を書くところ

named_scopeについて

環境 Rails 3.0.8 確認用モデル生成 author $ rails g model author name:string book $ rails g model book author:references title:string price:integerauthor:referencesで生成するとBookモデルはbelongs_to :author ができます。 class Book < ActiveR…

model生成時の型の指定について

環境 Rails 3.0.8 rails generate model で生成するときのテーブルの型指定 ActiveRecord::ConnectionAdapters::TableDefinition :primary_key :string :text :integer :float :decimal :datetime :timestamp :time :date :binary :boolean integerのことをi…

WindowsにBitNamiでRedmine1.2.0をインストール

簡単でいいね。Redmine Cloud Hosting, Installers and Virtual Machines.からダウンロード。 起動・停止 起動 [スタート] → [すべてのプログラム] → [BitNami Redmine Stack] → [BitNami Redmine Stack Service] → [Start BitNami Redmine Stack service] …

UbuntuにRedmineをインストール

環境 OS Ubuntu10.10 Redmine 1.2.0(ちょうど2011/05/30に出ていたようなので) DB PostgreSQL8.4.8 インストール手順 ダウンロード RubyForge: Redmine: Project Filelistからダウンロードします。 ダウンロードしたファイルを展開します。 $ cd /tmp $ wg…