2007-11-27から1日間の記事一覧

has_manyのオブジェクトを更新する Rails

●モデル Person has_many :sections Section belongs_to :person ●ビュー <% @person.sections.each do |@section| %> <%= text_field "section[]", "section_title" %> <%= text_area "section[]", "section_content" %> <% end %> ●コントローラー(update)…

render :partial で変数を渡す

参考URL(そのまま) http://www.hinet.mydns.jp/tdiary/?date=20060926テンプレートの中で、renderメソッドを使い別のテンプレートを呼び出し、そこに変数を渡す方法が分かった。 hoge.rhtmlファイルの中で <%= render :partial=>"fuga", :locals=>{:var=>"ho…