2011-09-28 169 views
0

如何在保存自定義註冊控制器之前修改User實例的屬性,繼承自Devise :: RegistrationsController?Rails設計註冊

回答

0

你自己給出了答案。在你的模型做:

class User < ActiveRecord::Base 
    before_save :set_attributes 

    def set_attributes 
     // Change the attributes to what you like 
    end 
end 
+0

嗯..問題是通過註冊用戶改變屬性ony。它用於爲用戶創建帳戶。 – Bob

+1

然後你可以使用'before_create'而不是'before_save' – halfdan