Dwijen Dwijen - 5 months ago 27
Ruby Question

Rails - ActiveAdmin not showing new Resources in Menu

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

Rao Rao
Answer

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
Comments