2
我很难让rails 4使用nested_attributes和序列化。我有:如何使rails strong_parameters + nested_attributes + serialize工作?
class Client < ActiveRecord::Base
belongs_to :event
serialize :phones
end
class Event < ActiveRecord::Base
has_one :client
end
class EventsController < ApplicationController
...
def event_params
params.permit(client_attributes: [:phones])
end
end
当我通过事件:
{client_attributes: { phones: 'string'}}
它的工作原理,但是当我尝试
{client_attributes: { phones: [{phone_1_hash},{phone_2_hash}]}}
得到 '未经许可的参数:手机' 不保存消息和现场...
我试过使用
class EventsController < ApplicationController
...
def event_params
params.permit(client_attributes: [phones:[]])
end
end
或
class Client < ActiveRecord::Base
belongs_to :event
serialize :phones, Array
end
但至今没有任何帮助。任何建议,将不胜感激。谢谢!