2

I am using ActiveAdmin with Rails 4 and Grape.

I am creating new AA resources with rails g active_admin:resource ModelClassName it used to work fine. Every resource showed up as a Menu Link in the Admin Console.

But now for some reason, for the new Models that I am creating, Active Admin is not showing the resources for the same in the Menu.

Any leads to why this could happen would help a lot.

Ruby Version - 2.2.3

Rails Version - 4.2.4

Active Admin Version - 1.0.0

This is my GemFile

ruby '2.2.3'
gem 'rails', '4.2.4'
gem 'pg'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
# gem 'bcrypt', '~> 3.1.7'
# gem 'unicorn'
# gem 'capistrano-rails', group: :development

group :development, :test do
debugger console
  gem 'byebug'
end

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

gem 'devise'
gem 'activeadmin', github: 'activeadmin'
gem 'grape'
gem 'cancan'
gem 'jwt'
gem 'aws-sdk', '~> 2'
gem 'rmagick'
gem 'grape-swagger'

EDIT The new Model resource doesn't work. But if i rename the Model in the same file to some older model it shows up fine.

Generated ActiveAdmin resource file -

ActiveAdmin.register NewModel do # DOESN'T WORK AND DOESN'T SHOW UP IN MENU

    # See permitted parameters documentation:
    # https://github.com/activeadmin/activeadmin/blob/master/docs/2 resource-    customization.md#setting-up-strong-parameters
    #
    # permit_params :list, :of, :attributes, :on, :model
    #
    # or
    #
    # permit_params do
    #   permitted = [:permitted, :attributes]
    #   permitted << :other if resource.something?
    #   permitted
    # end

end

ActiveAdmin.register OldModel, :as => 'Some Name' do # WORKS AND SHOWS UP IN MENU

    # See permitted parameters documentation:
    # https://github.com/activeadmin/activeadmin/blob/master/docs/2 resource-    customization.md#setting-up-strong-parameters
    #
    # permit_params :list, :of, :attributes, :on, :model
    #
    # or
    #
    # permit_params do
    #   permitted = [:permitted, :attributes]
    #   permitted << :other if resource.something?
    #   permitted
    # end

end
5
  • Show the generated Active Admin class file, especially any 'menu' lines. Commented Feb 9, 2016 at 15:19
  • There's no 'menu' lines in the new Resources. Edited the Question to show the generated ActiveAdmin Resource FIles. Commented Feb 10, 2016 at 5:55
  • Maybe stick as: 'New Model' on the new admin resource file as well? Commented Feb 11, 2016 at 4:44
  • Tried that, doesn't work unfortunately. Commented Feb 11, 2016 at 7:00
  • 2
    Finally fixed the issue. I am using a CanCan Adapter to handle what different roles can see on the Admin Console. I didnt remember that I would need to add the new resources in the roles. Commented Feb 11, 2016 at 11:54

2 Answers 2

6

If you are using CanCan gem with your ActiveAdmin, your models folder will have a <proj-name>_admin_ability.rb file, where you need to add your new model to can :manage (or :read) list.

include CanCan::Ability

def initialize(user)
    can :manage, [User, ModelClassName]
end
Sign up to request clarification or add additional context in comments.

Comments

3

Yes the new resource could be prevented from showing by an authorization adapter. It could be CanCan or Pundit or any other Authorization system configured with Active Admin.

You can get the specific authorization scheme your active admin is using from config/initializers/active_admin.rb

on the line that reads config.authorization_adapter = ActiveAdmin::Adapter

After getting your Authorization Adapter, you will want to add the new resource to the proper Admin Authorization. Pundit for example, you will want to crate a new policy for the resource allowing an Admin User to carry out specific actions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.