Skip to content

Instantly share code, notes, and snippets.

@camwest
Created April 4, 2012 18:04
Show Gist options
  • Save camwest/2304313 to your computer and use it in GitHub Desktop.
Save camwest/2304313 to your computer and use it in GitHub Desktop.
class AdminController < ApplicationController
rescue_from Acl9::AccessDenied, with: :unauthorized_redirect
before_filter :require_user
access_control do
allow :admin
end
def show
@plans = PlansPresenter.new(Plan.all)
end
private
def unauthorized_redirect
flash[:error] = I18n.t('login.unauthorized')
redirect_to login_path
end
end
class Plan < ActiveRecord::Base
attr_accessible :name, :amount, as: :admin
def self.free
Plan.where(name: 'free').first_or_create!
end
end
rails c
Plan.create!(name: 'Blah')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment