Skip to content

Instantly share code, notes, and snippets.

@mskyle
Created October 31, 2013 19:38
Show Gist options
  • Save mskyle/7255547 to your computer and use it in GitHub Desktop.
Save mskyle/7255547 to your computer and use it in GitHub Desktop.
class MountainsController < ApplicationController
helper_method :sort_column, :sort_direction
before_filter :authorize, only: :edit
def new
@mountain = Mountain.new
end
def edit
@mountain = Mountain.find(params[:id])
end
...
private
...
def authorize
if current_user && !current_user.admin?
redirect_to root_url, alert: "Not authorized"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment