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>"

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

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to