我在模型中有show
动作。Exhibitor
我想显示一个列表,Meetings
其中.Exhibitor
Sponsor
Exhibitor
模型:
class Exhibitor < ActiveRecord::Base
attr_accessible :description, :name, :exhibitor_category, :sponsor, :exhibitor_category_id
validates :name, :presence => true
validates :description, :presence => true
validates :exhibitor_category, :presence => true
belongs_to :exhibitor_category
belongs_to :sponsor
end
show
行动:
def show
@exhibitor = Exhibitor.find(params[:id])
@sponsoredmeetings = @exhibitor.sponsor
respond_to do |format|
format.html # show.html.erb
format.json { render json: @exhibitor }
end
end
show
看法:
<p>
<b>Meetings:</b>
<% @sponsoredmeetings.each do |c| %>
<%= c.meetings %>
<% end %>
</p>
当我运行页面时,我得到了这个:
参展商中的 NoMethodError#show
# Rails.root 的未定义方法“each”:C:/RailsInstaller/Ruby1.9.3/eventmanager
应用程序跟踪 | 框架跟踪 | 完整跟踪 app/controllers/exhibitors_controller.rb:17:in `show' 请求
参数:
{"id"=>"1"} 显示会话转储
我在控制器页面上做错了什么以不断收到此错误?