Search code examples
ruby-on-railsmodel-view-controllerrails-admin

How disable edit and delete rails_admin?


I want to disable the 'edit' and 'delete' buttons for users which are not owners.

Ex. I have created post and only I can do something with it and have all buttons (show, edit, delete). Another user has only the 'show' button of this post. But if they created their own post at this moment buttons 'edit' and 'delete' should be disabled for me and only they can do something with their own post.


Solution

  • If you have User has_many post, and post belong_to user and you are using devise gem.

    You can write the links to edit and delete in the if statement such as :

    - if @post.user == current_user
      = link_to #your required link