Hi,
I've 2 models
class Room < ActiveRecord::Base
has_many :people
accepts_nested_attributes_for :people, :reject_if => lambda { |a| a[:person_id].blank? }, :allow_destroy => true
end
class Person < ActiveRecord::Base
belongs_to :room
end
In '/rooms/new' form I've a select tag containing all Person + an 'other' option tag that allow the user to add dynamicaly a person to the select tag (New name).
So, when I submit my form I can have a person with id = -1 which doesn't exist in database, and of course, I want to create a new Person with the new name.
I'm wondering what is the best way to achieve that?
with a 'before_filter' or a 'rescue ActiveRecord::RecordNotFound' or ...
thanks for your help