On Viernes, 31 de Julio de 2009 18:46:42 dwhsix escribió: > I'm using fairly plain-vanilla objects and nothing really complex in > AS, but when I try to list objects that are at one end of a habtm > relationship, I get a baffling error message like "undefined method > `discount_id=' for #<Order:0xb68f97e0>"
has_many :through in active_scaffold work worst than has_and_belongs_to_many, you can try to change your has_many to habtm: class Order < ActiveRecord::Base has_and_belongs_to_many :discounts end discount.rb: class Discount < ActiveRecord::Base has_and_belongs_to_many :orders end You need to create the table discounts_orders: #migration create_table :discounts_orders, :id => false do |t| t.references :discount t.references :order end > > Here are the relevant portions of the classes: > > order.rb > class Order < ActiveRecord::Base > has_many :applied_discounts > has_many :discounts, :through => :applied_discounts > end > > applied_discount.rb > class AppliedDiscount < ActiveRecord::Base > belongs_to :order > belongs_to :discount > end > > discount.rb: > class Discount < ActiveRecord::Base > has_many :applied_discounts > has_many :orders, :through => :applied_discounts > end > > when I go to the DiscountsController#list action, I get that error > above. I've tried changed Order to have: > has_many :discounts, :through => :applied_discounts, :source > => :discount > (or :source => :order) but it doesn't help. > > When I change the rel'ship in Discount to be: > has_many :orders, :through => :applied_discounts, :source > => :discount > at least the view renders, but the Orders column incorrectly shows > links to discounts, not orders. > > I've finally punted and have just excluded :orders from the list view. > > Thoughts? > > Thanks, > > dwh > > -- Sergio Cambra .:: entreCables S.L. ::. Mariana Pineda 23, 50.018 Zaragoza T) 902 021 404 F) 976 52 98 07 E) [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en -~----------~----~----~----~------~----~------~--~---
