2008-04-14から1日間の記事一覧

こんなwhere句の作り方

うーん。。。 >> where = String.new => "" >> where << hoge= i == 0 ? " where " + "hoge = fuga" : " and " + "hoge = fuga" => " where hoge = fuga" >> where << hoge = i == 1 ? " where " + "hoge = fuga" : " and " + "hoge = fuga" => " where hoge…

selectの選択

selectedIndex

find_by_sqlの名前付きプレースホルダ

find_by_sqlのときは sql = "select * from hoge where fuga = ? and moge = ?" fuga = 1 moge = 2 Hoge.find_by_sql([sql, fuga, moge]) のプレースホルダに名前をつけたいとき cond = Hash.new sql = "select * from hoge where fuga = :fuga and moge = :…

DateHelperのオプション

参考 例:hoge', 'hage',{:discard_hour => true, :use_month_numbers => true } %> 1. :order => [:day,:month,:year ] # 選択する項目の順番を入れ替える 2. :discard_year => true # 年のセレクトボックスを削除する。 3. :discard_month => true # 月以…