CodeName
CodeName

Reputation: 395

protected method `authorize!' called for #<Admin::CustomersController:0x750c540>

i have this problems that really bugs me.
I try to get activeadmin working with CanCan. User model and i create a subclass for different role.
User <-- admin
User <-- customer
etc

I did all the configuration

config.authorization_adapter = ActiveAdmin::CanCanAdapter
config.authentication_method = :authenticate_admin!
config.current_user_method = :current_admin

But when i start the server i get this:

Uncaught exception: uninitialized constant ActiveAdmin::CanCanAdapter

To get rid of this bug i install the gem

gem 'activeadmin-cancan'

now all is good i can see the activeadmin panel. BUT when i add a resource, the resource doesn't show in the nav bar and when i try to access it directly i get this

protected method `authorize!' called for #< Admin::CustomersController:0x750c540>

if you can help me with this i will be so gratful!

Here is the Gemfile

source 'http://rubygems.org'
ruby '1.9.3'

gem 'rails', '3.2.17'
gem 'actionmailer', '3.2.17'

# sass-rails
gem 'sass-rails',   '>= 3.2'
# sass-rails depends on [sass (>= 3.1.10)]
gem 'sass', '3.2.8'  # Version 3.3.4 create error in Rake jobs:work
# bootstrap-sass
gem 'bootstrap-sass', '3.0.0'
# font-awesome
gem 'font-awesome-sass', '~> 4.0.2'

# CanCan is an authorization library for Ruby on Rails which
# restricts what resources a given user is allowed to access.
# https://github.com/ryanb/cancan/
gem 'cancancan', '1.8.2'
gem 'devise', '2.2.3'
gem 'devise-async', '0.7.0'
# Delayed_job (or DJ) encapsulates the common pattern of
# asynchronously executing longer tasks in the background.
gem 'delayed_job_active_record', '0.3.2'
#gem 'dj_mon', :git => 'git://github.com/jrosesol/dj_mon.git'

# HStore gem (to use NO SQL)
gem 'activerecord-postgres-hstore', '0.4.1'#git: 'git://github.com/softa/activerecord-postgres-hstore.git',
# Geocoder gem to place requests to Google's MAP API
gem 'geocoder', '1.1.8'
# Google place API implementation
# https://github.com/marceldegraaf/google_places
gem 'google_places', '0.18.0'
# Bundles some javascript files to make them available to your application backbone/underscore/json2
# https://github.com/aflatter/backbone-rails
gem "rails-backbone", "0.7.2"
#################
# RABL (Ruby API Builder Language) is a Rails and Padrino ruby templating system for generating JSON, XML, MessagePack, PList and BSON.
# https://github.com/nesquena/rabl
#
#gem 'rabl', '0.7.9'
# Also add either `oj` or `yajl-ruby` as the JSON parser
#gem 'oj', '1.4.6'
#################

# Easiest way to add multi-environment yaml settings to Rails3
# https://github.com/railsjedi/rails_config
gem 'rails_config', '0.3.3'

# Using Postgres database gem
gem 'pg', '0.14.1'
#
gem 'will_paginate', '3.0.3'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  #gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer'

  gem 'uglifier', '>= 1.0.3'
end

# jQuery JavaScript Library v1.8
gem 'jquery-rails', '2.1'

# TODO:  Should be in the 'TEST' group but there is a bug fixed in rubymine 5.0, change when possible
# http://youtrack.jetbrains.com/issue/RUBY-12632
gem 'rspec', :require => false

group :development, :test do
  gem 'rspec-rails', '2.12.2'
  gem 'capybara', '2.0.2'
  gem 'launchy', '2.2.0'
  gem 'annotate', '~> 2.4.1.beta'
  gem 'quiet_assets', '1.0.2'
  gem 'factory_girl', '4.2.0'
  gem 'database_cleaner'
  gem 'shoulda'
  # Generate fake data for your project test
  gem 'faker', '1.0.1'
  gem 'i18n-tasks', '~> 0.3.11' #Simplifying Translations
  gem 'simplecov', '0.8.2' #to have the coverage for the tests

end

# Add CSS inline for outgoing email (requires Bundler 1.2 pre+))
gem 'premailer-rails', '1.7'

# Daemon is require to run delayed_jobs scripts in Unix systems
gem 'daemons', '1.1.9'

# Captcha for wizard
gem "recaptcha", '0.3.5', :require => "recaptcha/rails"


# For search engine indexing (Sitemap.xml)
gem 'sitemap_generator', '4.2.0'

# This is for crawling/webscraping
#https://github.com/fizx/robots
gem 'robots', '0.10.1'
#http://nokogiri.org/
gem 'nokogiri', '1.6.2.1'
#https://github.com/chriskite/anemone/tree/master
gem 'anemone', '0.7.2'

# Application monitoring
gem 'newrelic_rpm', '3.9.0.229'

# For passing data to javascript files
gem 'gon', '5.0.4'

# For autocomplete-search boxes
gem 'select2-rails', '3.5.7'

gem 'json', '1.8.1'

platform :ruby do #linux only
  group :production, :staging do
    gem 'unicorn', '4.8.3'
  end
end

# These are used to store the logo of a company into s3 amazon
gem 'paperclip' , '4.1.1'
gem 'aws-sdk'   , '1.43.2'

gem 'activeadmin'
gem 'meta_search'
gem 'activeadmin-cancan'

Upvotes: 1

Views: 744

Answers (1)

nistvan
nistvan

Reputation: 2960

Use gem 'cancancan' instead of gem 'cancan', and delete gem 'activeadmin-cancan', you don't have to use that gem. Don't forget to update your gems: bundle update.

Upvotes: 2

Related Questions