Update Not Working When Nested Elements are Present

2 views
Skip to first unread message

gdevore

unread,
Feb 27, 2008, 12:33:52 PM2/27/08
to ActiveScaffold : Ruby on Rails plugin
I am pretty new to active scaffold and it look great. But I am having
a problem with editing my Products model.

Problem 1: When I edit the product record all of the nested elements
are displayed. Is there anyway to make these not show up on the edit
screen?

Problem 2: If I edit a product that has associated records the update
is applied twice, the first with my edit and the 2nd time with the
values of the record before I edited. This in essence does not allow
me to update the record. This doesn't happen on Product records that
don't have associated records.

I have posted some screenshots here that show what is happening:
http://bluemango.screenstepslive.com/lessons/562

Any help would be greatly appreciated.

gdevore

unread,
Feb 27, 2008, 12:41:33 PM2/27/08
to ActiveScaffold : Ruby on Rails plugin
Some additional information:
The problem seems to be with the store > product relationship.

Store is setup like this:

class Store < ActiveRecord::Base
has_many :store_products, :dependent => :destroy
has_many :products, :through => :store_products
end

Product is setup like this:

class Product < ActiveRecord::Base
has_many :store_products, :dependent => :destroy
has_many :stores, :through => :store_products


StoreProduct like this:

class StoreProduct < ActiveRecord::Base
belongs_to :store
belongs_to :product
end

Sergio Cambra

unread,
Feb 27, 2008, 4:13:01 PM2/27/08
to actives...@googlegroups.com
El Miércoles, 27 de Febrero de 2008, gdevore escribió:
> I am pretty new to active scaffold and it look great. But I am having
> a problem with editing my Products model.
>
> Problem 1: When I edit the product record all of the nested elements
> are displayed. Is there anyway to make these not show up on the edit
> screen?

You can use config.update.columns.exclude :store_products, :products

Sergio

gdevore

unread,
Feb 28, 2008, 8:47:15 PM2/28/08
to ActiveScaffold : Ruby on Rails plugin
Thanks Sergio - That worked.
Reply all
Reply to author
Forward
0 new messages