Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## controller
- def index
- @forum_categories = ForumCategories.all
- end
- ## view (this works)
- <% @forum_categories.each do |forum_category| %>
- <h1><%= h(forum_category.name) %></h1>
- <ul>
- <% forum_categories.each do |forum| do %>
- <li><%= forum.topics.size %></li>
- <% end %>
- </ul>
- <% end %>
- ## view (this works not!)
- <% @forum_categories.each do |forum_category| %>
- <h1><%= h(forum_category.name) %></h1>
- <ul>
- <% forum_categories.each do |forum| do %>
- <li>
- <%= forum.topics.size %>
- (<%= forum.topics.size %>)
- </li>
- <% end %>
- </ul>
- <% end %>
- ## The problem! (this worked on 2.1 edge but not the 2.2 edge)
- In the last example, I've get "wrong number of arguments (2 for 1)"
- on the second call to the forum.topics.size
- ## full error
- vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:78:in `proxy_respond_to?'
- vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:78:in `respond_to?'
- /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.4/lib/will_paginate/finder.rb:155:in `respond_to?'
- vendor/rails/activerecord/lib/active_record/associations.rb:1287:in `topics'
- app/views/forums/index.html.erb:35
- app/views/forums/index.html.erb:27
- app/views/forums/index.html.erb:4:in `each'
- app/views/forums/index.html.erb:4
Add Comment
Please, Sign In to add comment