在狂欢中提供默认注册表单我试图添加我的几个字段:contact_no,:address,:full_name。
当Spree内部使用此Gem时,从“spree_auth_devise”复制完整视图部分。
在app/views/spree/shared/_user_form.html.erb
添加了必需的迁移
class AddUserRegistrationDetailsToSpreeUser < ActiveRecord::Migration
def change
add_column :spree_users, :full_name, :string
add_column :spree_users, :address, :text
add_column :spree_users, :contact_no, :integer
end
end
现在关注模型部分: user_registration_decorator.rb
Spree::User.class_eval do
attr_accessible :email, :password, :password_confirmation,
:contact_no, :address,:full_name, :as => [:default, :user]
end
现在,通过注册表单创建新用户,在数据库中,新添加的字段(contact_no,address,full_name)将以NULL值保存。 :(
答案 0 :(得分:3)
Spree 2.1.3在Rails 4上运行,并且已经跟随Rails 4切换到strong_parameters。您可以在Rails Blog上的这篇博客文章中阅读更多相关信息,但基本上不再使用attr_accessible,并且已被控制器中明确允许的参数替换。
您应该看一下修改these attributes使用的user registrations controller。