RailsCasts Pro episodes are now free!

Learn more or hide this

railscast's Profile

GitHub User: railscast

Comments by

Avatar

class Permission
def initialize(current_user)
allow :index_page, [:index]
allow :static_pages, [:about, :contact]
allow :sessions, [:new, :create, :destroy]
allow :users, [:edit, :update]

def allow_all
  @allow_all = true
end

def allow(controllers, actions)
  @allowed_actions ||= {}
  Array(controllers).each do |controller|
    Array(actions).each do |action|
      @allowed_actions[[controller.to_s, action.to_s]] = true
    end
  end
end

end
end

but there is something wrong
NoMethodError in PrimaryPagesController#index

undefined method `allow' for #Permission:0x007fcaee54a310
Rails.root: /Users/freshlhy/rails_projects/first_app

Application Trace | Framework Trace | Full Trace
app/models/permission.rb:3:in initialize'
app/controllers/application_controller.rb:12:in
new'
app/controllers/application_controller.rb:12:in current_permission'
app/controllers/application_controller.rb:20:in
authorize'

Avatar

How to use Handlebars instead of eco in rails ?

Avatar

egghead.io can't open.......

Looking forward to series for AngularJS:
parties
nested_urls
widget
...

Avatar

Thank you so mach and it works for me.