这将是一个非常愚蠢的问题,我几乎讨厌自己问这个问题,但是在这里。Rails语法错误,意外''''
当我跑我的黄瓜测试中,我得到一个“语法错误,意外‘)’”使用下面的代码:
在我的用户模型:
def member?(gallery)
array = []
self.groups.each do |group|
array << group.id
end
if array.include?(gallery.group.id)
true
end
end
在我看来, :
<ul>
<% @galleries.each do |gallery| %>
<% if current_user.member?(gallery) %>
<li>
<%= link_to gallery.title, gallery %>
</li>
<% end %>
<% end %>
</ul>
编辑:这是错误的全部重要组成部分:
~/Coding/Rails/galleryTest/app/views/galleries/index.html.erb:8: syntax error, unexpected ')', expecting keyword_then or ';' or '\n'
... current_user.member? gallery);@output_buffer.safe_concat('
... ^
~/Coding/Rails/galleryTest/app/views/galleries/index.html.erb:13: syntax error, unexpected keyword_end, expecting ')'
'); end
^
编辑2:删除当“=”以下是错误:
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id (ActionView::Template::Error)
./app/models/user.rb:18:in `member?'
我已经尝试了一些不同的东西,我必须失去了一些东西真是小巫见大巫。另一双眼睛将不胜感激。
非常感谢。
erb文件中的if应该不是'<%=';看看是否有帮助。 –
我试过了,出现了一个新的错误... – YuKagi
画廊没有一个组?我不知道18号线是什么。 –