Jerry
Jerry

Reputation: 695

Custom action not showing on rails_admin dashboard

I have made a custom rails_admin action published for my rails project.

# rails_admin_publish_comment.rb
require '..actions'
require '..actions/base'

module RailsAdmin
  module Config
    module Actions
      class PublishComment < RailsAdmin::Config::Actions::Base
        RailsAdmin::Config::Actions.register(self)

        register_instance_option :link_icon do
          'icon-check'
        end

        register_instance_option :controller do
          Proc.new do
            @object.update_attribute(:published, true)
            flash[:notice] = "#{@object.user}'s comment has been published!"
            redirect_to back_or_index
          end
        end
      end
    end
  end
end

# rails_admin.rb
require Rails.root.join('lib/rails_admin_publish_comment.rb')
RailsAdmin.config do |config|
  ..
  config.actions do
    ..
    publish_comment
  end
end

The problem is that I can't get the icon to show, it doesn't even show up in the html.

I know that the publish_comment class gets called because the server raises an error when I change the name. Setting it as visible doesn't do anything and I have tried with other icons with no result.

Upvotes: 2

Views: 818

Answers (1)

Jerry
Jerry

Reputation: 695

Ok, the solution is to add

    register_instance_option :member? do
      true
    end

Upvotes: 4

Related Questions