Guest User

Untitled

a guest
May 24th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. ## controller
  2.  
  3. def index
  4. @forum_categories = ForumCategories.all
  5. end
  6.  
  7. ## view (this works)
  8.  
  9. <% @forum_categories.each do |forum_category| %>
  10. <h1><%= h(forum_category.name) %></h1>
  11.  
  12. <ul>
  13. <% forum_categories.each do |forum| do %>
  14. <li><%= forum.topics.size %></li>
  15. <% end %>
  16. </ul>
  17. <% end %>
  18.  
  19.  
  20. ## view (this works not!)
  21.  
  22. <% @forum_categories.each do |forum_category| %>
  23. <h1><%= h(forum_category.name) %></h1>
  24.  
  25. <ul>
  26. <% forum_categories.each do |forum| do %>
  27. <li>
  28. <%= forum.topics.size %>
  29. (<%= forum.topics.size %>)
  30. </li>
  31. <% end %>
  32. </ul>
  33. <% end %>
  34.  
  35. ## The problem! (this worked on 2.1 edge but not the 2.2 edge)
  36. In the last example, I've get "wrong number of arguments (2 for 1)"
  37. on the second call to the forum.topics.size
  38.  
  39. ## full error
  40. vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:78:in `proxy_respond_to?'
  41. vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:78:in `respond_to?'
  42. /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.4/lib/will_paginate/finder.rb:155:in `respond_to?'
  43. vendor/rails/activerecord/lib/active_record/associations.rb:1287:in `topics'
  44. app/views/forums/index.html.erb:35
  45. app/views/forums/index.html.erb:27
  46. app/views/forums/index.html.erb:4:in `each'
  47. app/views/forums/index.html.erb:4
Add Comment
Please, Sign In to add comment