在尝试呈现我得到的表单时:
NameError in Deals#new
Showing /Users/nelsonkeating/Desktop/ReminDeal1/app/views/deals/_form.html.erb where line #8 raised:
uninitialized constant Deal::Interests
Extracted source (around line #8):
5: <li><%= f.input :name %></li>
6: <li><%= f.input :copy %></li>
7: <li><%= f.association :city %></li>
8: <li><%= f.association :interests, :label => false, :as => :check_boxes %></li>
9: </ul>
10:
11: <div class="form-actions">
该应用程序的相关部分附在下面:
楷模:
class Deal < ActiveRecord::Base
attr_accessible :title, :body
belongs_to :interests
belongs_to :city
end
class Interest < ActiveRecord::Base
attr_accessible :name
has_many :person_interests
has_many :deals
end
控制器:
deals_controller.rb
def new
@deal = Deal.new
end
看法:
<%= simple_form_for(@deal) do |f| %>
<%= f.error_notification %>
<ul class="testss1">
<li><%= f.input :name %></li>
<li><%= f.input :copy %></li>
<li><%= f.association :city %></li>
<li><%= f.association :interests, :label => false, :as => :check_boxes %></li>
</ul>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>
有任何想法吗?非常感谢!