I am having issues with editing nested attributes. I'm getting this error :
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
If I change my params
before permission with
params[:event][:event_joins_attributes][:duration] = params[:event][:event_joins_attributes][:duration].to_i
I have the following error:
no implicit conversion of String into Integer
I've read a lot of posts about nested attributes for mass-assignment but nothing works. Here is part of posts I've read.
strong-parameters-permit-all-attributes-for-nested-attributes
rails-4-strong-parameters-nested-objects
Of course, I don't want to do
params.require(:event).permit!