I am testing the following:
Account
class Account < ActiveRecord::Base has_many :ownerships has_many :brands, :through => :ownerships end
Ownership Model
class Ownership < ActiveRecord::Base belongs_to :brand belongs_to :account end
Test
it "should be able to apply for brand ownership" do account = Account.create(valid_account_attributes) account.ownerships.create(:brand => Brand.create(:name => 'Superuser')) account.ownerships.first.state == 'pending' end
And I keep getting this error
You cannot call create unless the parent is saved
I really don't understand - which parent? Shouldn't all models be created and saved when using the create method? I tried to hang "account.save".
source share