You can get the current_user
's permissions from a view or controller using can?
in this fashion:
<% if can? :update, @article %>
<%= link_to "Edit", edit_article_path(@article) %>
<% end %>
How can I access this functionality from a model using this syntax:
user.can?(:update, @article)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…