accept_nested_attributes_for add the possibility to ActiveRecord to be able to write into association directly from one model.
exemple :
You have models like :
class User
accepts_nested_attributes_for :cars
end
class Car
belongs_to :user
end
and a hash like :
param[:user] = {}
params[:user][:name] = "Mike"
params[:user][:car] = {}
params[:user][:car][:brand] = "Nissan"
User.create(params[:user])
This will create a new user and a new car,
without *accepts_nested_attributes_for* :
@user = User.create(params[:user])
@car = Car.create(params[:user][:car])
@user.car = @car
This function is usually with *fields_for* in HTML forms so you can easily handle the creation of an object and his associations.
In your case I imagine your models like that (regarding your XML) :
class Card
has_one :front_side, :class => "Side"
has_one :back_side, :class => "Side"
end
class Side
belongs_to :card
has_many :card_side_entry
end
class CardSideEntry
belongs_to :side
end
I don't know where your XML come from (your data are extracted from it ??), but I imagine you could use accepts_nested_attributes_for so you could have each card hash generating the associations.
But I'm not sure to understand all the problem and if this is the best solution