【发布时间】:2015-07-16 09:28:41
【问题描述】:
我在编辑嵌套属性时遇到问题。我收到此错误:
no implicit conversion of Symbol into Integer
event.rb:
Class Event < ActiveRecord::Base
has_many :event_joins, :dependent => :destroy
accepts_nested_attributes_for :event_joins
end
events_controller.rb:
private
def event_params
params.require(:event).permit(event_joins_attributes: [:duration])
end
_form.html.erb:
=f.fields_for :event_joins_attributes do |a|
=number_field_tag 'event[event_joins_attributes][duration]'
end
如果我在获得许可之前更改我的params
params[:event][:event_joins_attributes][:duration] = params[:event][:event_joins_attributes][:duration].to_i
我有以下错误:
no implicit conversion of String into Integer
我已经阅读了很多关于用于批量赋值的嵌套属性的帖子,但没有任何效果。 这是我读过的部分帖子。
strong-parameters-permit-all-attributes-for-nested-attributes
rails-4-strong-parameters-nested-objects
当然,我不想这样做
params.require(:event).permit!
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 nested-attributes strong-parameters