Guest User

Untitled

a guest
Jul 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. module ApplicationHelper
  2.  
  3. # In Rails 2 this worked as expected, if the user was admin the block would execute and show up in the view
  4. # In Rails 3 it renders everything on the page up to here twice.
  5.  
  6. def admin &blk
  7. yield if current_user.admin?
  8. end
  9.  
  10. end
  11.  
  12.  
  13.  
  14. # View
  15.  
  16. <% admin do %>
  17. <%= "I Like Turtles" %>
  18. <% end %>
Add Comment
Please, Sign In to add comment