Это будет очень тупой вопрос, и я почти ненавижу себя за то, что задаю его, но здесь все сказано.
Когда я запускаю тест на огурец, я получаю «синтаксическую ошибку, неожиданную») со следующим кодом:
внутри моей пользовательской модели:
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?'
Я пробовал несколько разных вещей, и я должен упустить что-то действительно тривиальное. Другая пара глаз будет с благодарностью.
Большое спасибо.