Search code examples
ruby-on-railsdeclarative-authorization

rails - declarative_authorization permitted_to not working correctly


I am trying to use permitted_to to hide/show links but in one of my forms it is not appearing.

The form belongs to assignments but the actual edit function is for candidates.

<% if permitted_to? :edit, @candidate %>
<%= link_to 'Edit', edit_candidate_path(@candidate) %>
<% end %>

I can navigate to the page by url so i know its not a authorization issue.

any ideas ?

Thanks, Alex


Solution

  • Sorry, found this in the documentation!

    <%= link_to 'Edit', edit_contact_path(contact) if permitted_to? :update, contact %>