show_for gem gives to_key error
hi i am using show_for gem and it gives me error like: undefined method `to_key' for # in app/views/messages/index.html开发者_JAVA百科.erb where line #46 raised:
my view look like these:
46: <%= show_for @messages do |s| %>
47: <%= s.attribute :subject %>
48: <%= s.attribute :message %>
49: <% end %>
my controller code look like:
@messages= Message.all
please help me what i am doing wrong. thanks in advance
I do not know this gem but according to its documentation, show_for is not supposed to receive a collection as argument (@messages) but a single object. I might be wrong.
With this supposition, I would to :
<% @messages.each do |message| %>
<%= show_for message do |s| %>
<%= s.attribute :subject %>
<%= s.attribute :message %>
<% end %>
<% end %>
精彩评论