![](/img/trans.png)
[英]How can I set the value to the nested column when signing up with Devise?
[英]How can I set the value to the nested column when signing up with Devise in rails3?
我正在使用rails3。
用戶模型具有一個user_profile。
我剛剛安裝了devise,它的運行正常。
我做了registrations_controller.rb,它具有“創建”,“ after_update_path_for(資源)”和“編輯”操作。
如果我想在user_profile的嵌套列中輸入“ 45”作為默認值,我該如何在注冊控制器中編碼?
我是否應該再執行一個“保存/或新的”操作? ,並寫下這個?
@ user.user_profile.language_id ='45'
如果您只想要特定字段的默認值,則可以將其添加到遷移文件中,例如...
create_table :user_profile do |t|
...
t.integer :language_id, :default => 45
end
...這將自動設置與創建關聯的lauguage_id值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.