Vote
has_many Option
, Options
belongs_to User
with column user_id
.
In vote's
show.html.erb
when <% @vote.options.user_id %> it come an error : undefined method
user_id'`.
how could i get the option.user_id
in Vote's
view?
@vote.options.first.user_id
should help
to debug you should do p @vote.options
and get output result in your rails development console among of messages, you will be able to see what's @vote.options consists of.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.