railsで親子関係にあるモデルをビューに表示させようと思っているのですが、
undefined method `each' for #<Plan:0x007f8643b96088>
とエラーが出ており、こちらが解決できませんのでどなたか教えていただけませんでしょうか?
下記、それぞれの定義ファイルとなっております。
route.rb
get '/plans/:id', to: 'plan_pages#show
plan_pages_controller.rb
def show @plan = Plan.find(params[:id]) @planaction = @plan.plan_actions end
plan_pages/show.html.erb
<% @plan.each do |plan| %> <%= plan.title %> <%= plan.description %> <%= image_tag plan.image.to_s%> <% end %> <hr> <% @planaction.each do |action| %> <%= action.title %> <%= action.experience %> <%= image_tag plan.image.to_s%> <%= image_tag plan.image2.to_s%> <%= image_tag plan.image3.to_s%> <hr> <% end %>
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/10/30 02:19
2015/10/30 02:33 編集
2015/10/30 02:40