Guest User

Untitled

a guest
Oct 16th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. ## body_helper.rb
  2. module BodyHelper
  3.  
  4.  
  5. def body_class(body_class)
  6. @body_class ||= ""
  7. @body_class << "#{body_class}"
  8. end
  9.  
  10. end
  11.  
  12. ## application_controller.rb
  13.  
  14. class ApplicationController < ActionController::Base
  15. protect_from_forgery
  16.  
  17. helper :all
  18.  
  19. before_filter :setup_menu
  20. def setup_menu
  21. #look into building a hash
  22. #@nav_data[:authors] = Author.all
  23. @all_authors = Author.order(:name)
  24. @genres = Genre.all
  25. end
  26. end
  27.  
  28. ##books_controller.rb
  29.  
  30. def index
  31. @books = Book.order(:title)
  32. body_class "books"
  33. end
Add Comment
Please, Sign In to add comment