Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. # find all submissions made by the current user, group by the
  2. # submission's :contest_year and :organization_id attributes:
  3.  
  4. <% current_user.submissions.group([:contest_year, :organization_id]).each do |contest| %>
  5. <h2><%= contest.contest_year %>: <%= contest.organization.name %></h2>
  6.  
  7. # here is where it fails, it is finding all the submissions made by the user
  8. # instead of just the submissions that belong under the
  9. # specified contest_year/organization_id heading from above.
  10. # I know I need 'contest' involved in here
  11.  
  12. <% current_user.submissions.in_groups_of(3, false).each do |group| %>
  13. <div class="row">
  14. <% group.each do |submission| %>
  15. <div class="col-md-4">
  16. # submission information here
  17. </div>
  18. <% end %>
  19. </div><br/>
  20. <% end %>
  21. <% end %>
  22.  
  23. Submission.rb
  24.  
  25. belongs_to :user
  26. belongs_to :organization
  27.  
  28. submissions_controller.rb
  29.  
  30. def index
  31. @submissions = Submission.all
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement