Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Mike Bethany's Profile

GitHub User: mikbe

Site: http://mikbe.tk

Comments by Mike Bethany

Avatar

ProTip: Don't use "if not," use "unless."

So the authorize method would go from:

def authorize
  if !current_permission.allow?(params[:controller], params[:action])
    redirect_to root_url, alert: "Not authorized."
  end
end

To the more readable:

def authorize
  unless current_permission.allow?(params[:controller], params[:action])
    redirect_to root_url, alert: "Not authorized."
  end
end
Avatar

Agreed about Devise. It gave me a super quick setup that I almost immediately needed to modify. I'll be taking a look at Sorcery next.

Avatar

FYI if you're using Rails 3 you need to change the line:

<% fields_for 

to:

<%= fields_for