2013-12-11 52 views
1

在spree中提供了默认注册表单,我试图添加几个字段:contact_no,:address,:full_name。为注册表格中的新字段添加的值未保存在Spree中

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

这狂欢的版本是您使用? – gmacdougall

+0

宝石“大礼包”,“2.1使用。 3' – Ajay

回答

相关问题