Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you disable edit or delete in a show view? #134

Closed
ryanwood opened this issue May 31, 2011 · 4 comments
Closed

Can you disable edit or delete in a show view? #134

ryanwood opened this issue May 31, 2011 · 4 comments

Comments

@ryanwood
Copy link

I see the default action_items in the resource_controller class, but can't figure out how to disable them via the active_admin model config. Is that possible?

# Default Action Item Links
action_item :only => :show do
  if controller.action_methods.include?('edit')
    link_to("Edit #{active_admin_config.resource_name}", edit_resource_path(resource))
  end
end

action_item :only => :show do
  if controller.action_methods.include?("destroy")
    link_to("Delete #{active_admin_config.resource_name}",
      resource_path(resource), 
      :method => :delete, :confirm => "Are you sure you want to delete this?")
  end
end

action_item :except => [:new, :show] do
  if controller.action_methods.include?('new')
    link_to("New #{active_admin_config.resource_name}", new_resource_path)
  end
end

-Ryan

@ryanwood
Copy link
Author

Nevermind. I see how you can open up the controller in the config like this:

ActiveAdmin.register User do
  controller do
    actions :all, :except => [:edit, :destroy]
  end
end

Thanks.

@gregbell
Copy link
Contributor

Do you want to only disable the buttons? Or the entire actions?

To disable the actions use:

actions :index, :show

Or

actions :except => [:edit, :update]

Currently there is no supported mechanism to turn on and off individual action items that you didn't create.

On 2011-05-31, at 7:41 AM, ryanwoodreply@reply.github.com wrote:

I see the default action_items in the resource_controller class, but can't figure out how to disable them via the active_admin model config. Is that possible?

Default Action Item Links

action_item :only => :show do
if controller.action_methods.include?('edit')
link_to("Edit #{active_admin_config.resource_name}", edit_resource_path(resource))
end
end

action_item :only => :show do
if controller.action_methods.include?("destroy")
link_to("Delete #{active_admin_config.resource_name}",
resource_path(resource),
:method => :delete, :confirm => "Are you sure you want to delete this?")
end
end

action_item :except => [:new, :show] do
if controller.action_methods.include?('new')
link_to("New #{active_admin_config.resource_name}", new_resource_path)
end
end

-Ryan

Reply to this email directly or view it on GitHub:
#134

@gregbell
Copy link
Contributor

@ryanwood No need to open the controller class, you can call #actions directly from the registration block

@Zequez
Copy link
Contributor

Zequez commented Nov 4, 2011

And what if you need only to remove the buttons because you are using a belongs_to association of Inherited Resources?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants