Haven't been using Rails 3 for a while, but from my memories:
Say you have Company with embedded Address documents and the following
code:
# _address_form.html.erb
form_for [@company, @address] do |f|
f.text_field :street
... and the usual helpers
end
# Address Controller - new action
# Assuming we have nested resources, which fit well with MongoDB
document-orientation
@company = Company.find(params[:company_id])
@address = @company.addresses.build
# AddressController - create action
@company = Company.find(params[:company_id])
@address = @company.addresses.build(params[:address])
if @address.save
....
# Address Controller - edit action
@company = Company.find(params[:company_id])
@company.addresses.each {|a| @address = a if
a.id == params[:id]}
# AddressController - update action
@company = Company.find(params[:company_id])
@company.addresses.each {|a| @address = a if
a.id == params[:id]}
if @address.update_attributes(params[:address])
...
You can also create / update addresses from Company's controller by
including this in Company's model:
accepts_nested_attributes_for :addresses
Is this of any help?
Lorenzo
On Jun 14, 6:40 pm, James <
jhicks0...@gmail.com> wrote:
> I am very interested inthis as well. I am a ruby/rails newbie so I
> could hack my way to a workaround as you did.
>
> There was a bug opened on rails but was closed as will not fix. I
> don't have the link handy but will find it later.
>
> Sent from my iPhone
>