我似乎无法使用嵌套表单,我要么看不到它,要么不理解它。这里的错误
Can't mass-assign protected attributes: location
现在在这里我是如何写我的
模型/事件:
#Data
attr_accessible :customer_id, :description, :location_attributes
#Relationship
has_many :locations
accepts_nested_attributes_for :locations, :allow_destroy => true
型号/地点:
#Data
attr_accessible :address, :customer_id, :event_id, :latitude, :longitude
#Relationship
belongs_to :customer
belongs_to :event
控制器:
def create
@event = current_customer.events.build(params[:event])
...
看法:
<%= f.fields_for :location do |e| %>
<%= e.hidden_field :longitude %>
<%= e.hidden_field :latitude %>
<% end %>
参数
"location"=>{"longitude"=>"-80.9449995",
"latitude"=>"46.435371599999996"},
我在 Rails 3.2.9 上并托管在 vps 服务器上。现在我不明白为什么它不起作用。