Hi
I’m following pretty closely the following the Depot Application from
the ‘Agile Web D. with Rails’ (3rd edition), but I run into
deep trouble. I have:
class Product < ActiveRecord::Base
has_many :charge_items
end
class Transaction < ActiveRecord::Base
belongs_to :user
has_many :charge_items
end
class ChargeItem < ActiveRecord::Base
belongs_to :transaction
belongs_to :product
end
Running script/console, I try the following:
Loading development environment (Rails 2.2.2)
p = Product.find(:first)
=> #<Product id: 1, name: “50 Clicks”, description: “50 Clicks”,
valid_from: “2009-01-20 09:37:00”, valid_until: “2010-01-20 09:37:00”,
number_of_clicks: 50, price: #BigDecimal:7f4458231588,‘0.2E2’,9(18),
created_at: “2009-01-20 09:38:52”, updated_at: “2009-01-20 09:38:52”>t = Transaction.find(:first)
=> #<Transaction id: 43, user_id: 6, created_at: “2009-02-02
09:07:24”, updated_at: “2009-02-02 09:07:24”>c = ChargeItem.new(:transaction => t, :product => p, :quantity => 1, :total_price => 29.95)
=> #<ChargeItem id: nil, transaction_id: 43, product_id: 1, quantity:
1, total_price: #BigDecimal:7f44581e70c8,‘0.2995E2’,18(18),
created_at: nil, updated_at: nil>c.save
=> nil
I.e., the charge_item never gets saved.
any hint or idea is extremely welcome.
nd