Skip to content

Instantly share code, notes, and snippets.

@deathbob
Created December 9, 2010 21:51
Show Gist options
  • Select an option

  • Save deathbob/735388 to your computer and use it in GitHub Desktop.

Select an option

Save deathbob/735388 to your computer and use it in GitHub Desktop.
module ApplicationHelper
# In Rails 2 this worked as expected, if the user was admin the block would execute and show up in the view
# In Rails 3 it renders everything on the page up to here twice.
def admin &blk
yield if current_user.admin?
end
end
# View
<% admin do %>
<%= "I Like Turtles" %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment