class User < ActiveRecord::Base
has_one :data, inverse_of: :user
accepts_nested_attributes_for :data
end
發佈體
{數據:{活性:假},DATA_ATTRIBUTES:{活性:假},暱稱:「尼克「}
Rails日誌
參數:{「data」=> {「active」=> false},「data_attributes」=> {「active」=> false},「nickname」=>「nick」,「id」=>「1」, 「用戶」=> { 「暱稱」=> 「缺口」}}
PARAMS:
<ActionController::Parameters {"data"=>{"active"=>false}, "data_attributes"=>{"active"=>false}, "nickname"=>"nick", "controller"=>"api/users", "action"=>"update", "id"=>"1", "user"=>{"nickname"=>"nick"}} permitted: false>
params.require(:用戶).permit(:暱稱,DATA_ATTRIBUTES:[:活性] )
<ActionController::Parameters {"nickname"=>"nick"} permitted: true>
User.new的(a)
#<User id: nil, provider: "email", uid: "", name: nil, nickname: "nick", image: nil, email: nil, created_at: nil, updated_at: nil>
User.new(一)。數據
nil
什麼是錯。這是正確的嗎? 什麼需要修復嵌套的數據對象正確創建?