1
我拔掉了我的所有头发。没有更多的左... :(无法批量分配受保护的属性:
我使用Spree 0.3.4,在一个扩展中我需要注册一些零售商,所以我指示他们到一个零售商的形式,它有许多属于零售商模式的自定义字段...
所以我试图验证/从一种形式提交所有领域,像这样
myextension /应用/视图/ user_registrations/new.html.erb
<%= form_for (:user, :url => registration_path(@user, :type => "retailer) do |f| %>
<%= f.fields_for :retailer do |r| %>
<%= r.text_field :name %>
<% end %>
<%= f.text_field :email %>
<% end %>
等等等等
class Retailer < ActiveRecord::Base
belongs_to :user
validates :name,
:presence => true
end
class User < ActiveRecord::Base
has_one :retailer
accepts_nested_attributes_for :retailer
attr_accessible :retailer_attributes
# theres a whole lot more spree and devise stuff here. not sure worth mentioning
end
我还增加了在康康舞能力ability.rb
的问题是零售商精密组件永远不会得到验证和数据永远不会插入到数据库...
我创建了一个空白应用程序,并从一些普通的旧脚手架从头开始尝试这个过程,它工作正常。
任何想法??