Skip to content

Instantly share code, notes, and snippets.

@recursive
Created October 7, 2009 06:30
Show Gist options
  • Select an option

  • Save recursive/203800 to your computer and use it in GitHub Desktop.

Select an option

Save recursive/203800 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
helper_method :admin?
helper_method :user?
protected
def admin?
session[:password] == 'imcool'
end
def user?
user = User.find_by_id(session[:user_id])
if user
return true
else
return false
end
end
end
<p>
<% if admin? %>
I'm an admin.
<% elsif user? %>
I'm a user.
<% else %>
I'm nobody, a public dood.
<% end %>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment