La partie de la vue qui est applicable:Obtenir erreur current_user lors de l'utilisation Bates Ryan plug-in autorisation de CanCan
<% @projects.each do |project| %>
<tr>
<td><%= project.name %></td>
<td><%= project.description %></td>
<td><%= link_to 'Show', project %></td>
<% if can? :update, @project %>
<td><%= link_to 'Edit', edit_project_path(project) %></td>
<% end %>
<% if can? :destroy, @project %>
<td><%= link_to 'Destroy', project, :confirm => 'Are you sure?', :method => :delete %></td>
<% end %>
</tr>
<% end %>
modèles/ability.rb
class Ability
include CanCan::Ability
def initialize(designer)
can :read, :all
end
end
C'est l'erreur que je reçois:
NameError in Projects#index
undefined local variable or method `current_user' for #<ProjectsController:0x000001016d62d8>
Extracted source (around line #18):
15: <td><%= project.description %></td>
16: <td><%= link_to 'Show', project %></td>
17:
18: <% if can? :update, @project %>
19: <td><%= link_to 'Edit', edit_project_path(project) %></td>
20: <% end %>
21:
Pensées?