As this question is hard to describe, that's the best title i could come up with, so here is some code.
Given three Models Parent, Child && Grandchild.
Parent < ActiveRecord::Base
has_many :children
has_many :grandchildren
accepts_nested_attributes_for :child
end
Child < ActiveRecord::Base
belongs_to :parent
has_many :kids, :as => :grandchildren #this is just an example
accepts_nested_attributes_for :grandchild
end
Grandchild < ActiveRecord::Base
belongs_to :parent
belongs_to :child
end
I'd like to add the current_user.id to both the child record and Grandchild record that gets created in during Parent#new. I've used hidden fields for now, because i couldn't find a good way to add them.
Maybe someone can help by creating a callback to add the current_user.id on create? I've never had much luck getting that into a model anyways, but you are smart.
Thoughts?