Forum: Ruby on Rails Localization expected, got HashWithIndifferentAccess

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
1e08d48f2c4011e254f34dfb457811df?d=identicon&s=25 Felipe Lopes (Guest)
on 2009-04-21 18:07
(Received via mailing list)
Well I Have this models

 has_many :event

 belongs_to :localization

in the view events/new.html.erb

  <% f.fields_for :localization do |L| %>

    <%= l.text_field :country %>
    <%= l.text_field :state %>
    <%= l.text_field :city %>

  <% end %>

the events controller is ust saving the event model.

But when I submit the page I get "Localization expected, got
HashWithIndifferentAccess" I tried to modify the controller in many
ways, but this apper to be happening before arrive in the controller.

By the way, I will use this space also to ask you if there is a better
way to associate an event with an location making easy to reuse the
same location for different events and other models I will have?

Thank you
1e08d48f2c4011e254f34dfb457811df?d=identicon&s=25 Felipe Lopes (Guest)
on 2009-04-22 14:37
(Received via mailing list)
Anybody have an update to this question?
782b01570270ab10543bc25a258d7ea8?d=identicon&s=25 Dmitry Sokurenko (Guest)
on 2009-04-22 15:06
(Received via mailing list)
Try to specify in your Event model:
  accepts_nested_attributes_for :localization

It should work, but typically it's used from parent to child (when
event subform is inside location form).

Also has_many :event doesn't have much sence -- either has_one either

This topic is locked and can not be replied to.