0
我想在我的show.html.erb做到这一点(下面的代码),但它给了我这个错误:NameError在项目#显示与色器件
NameError in Projects#show
但这工作正常我的index.html.erb这使得它更怪吗?
<%= link_to 'Back', projects_path %>
<% if project.user == current_user %>
<td><%= link_to 'Edit', edit_project_path(project) %></td>
<td><%= link_to 'Destroy', project, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<% end %>
噢,顺便说一下,我使用的设计,这是哪里,这是从
<% if project.user == current_user %>
来这里是完整的错误:
NameError在项目#秀
未定义的局部变量或方法`项目'为#<#:0x007fd419297d00> 提取的源(约行#30):
<%= link_to 'Back', projects_path %>
<% if @project.user.id == current_user.id %>
<td><%= link_to 'Edit', edit_project_path(project) %></td>
<td><%= link_to 'Destroy', project, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<% end %>
显示完整的错误堆栈 – 2015-02-08 12:22:52
和控制器代码,这不是超感官俱乐部 – 2015-02-08 12:24:31
是''%如果project.user == current_user%>'在'show.html.erb'中? – 2015-02-08 12:26:25