Guest User

Untitled

a guest
Mar 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. CONTROLLER:
  2. class BoardsController < ApplicationController
  3. def index
  4. @boards = Board.find(:all)
  5. end
  6. end
  7.  
  8.  
  9. VIEW:
  10. <%for board in @boards%>
  11. <%=debug(board.topics.last)%>
  12. <%end%>
  13.  
  14.  
  15. RESULT:
  16. --- !ruby/object:Topic
  17. attributes:
  18. text: Hello World
  19. title: Hello World
  20. id: !str 1
  21. date: 2008-06-14 18:06:56
  22. board_id: !str 1
  23. attributes_cache: {}
  24.  
  25. ---
  26.  
  27.  
  28. COMMENT: How can i access these attributes? A "board.topics.last.title" brings up a No method error....why?
Add Comment
Please, Sign In to add comment