Created
April 4, 2012 18:04
-
-
Save camwest/2304313 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Plan < ActiveRecord::Base | |
attr_accessible :name, :amount, as: :admin | |
def self.free | |
Plan.where(name: 'free').first_or_create! | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails c | |
Plan.create!(name: 'Blah') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment