On Jul 11, 12:13 pm, Colin Law <[email protected]> wrote: > On 11 July 2011 17:05, Yennie <[email protected]> wrote: > > > > > > > > > > > Hi , > > > I want to test the one below but I got the problem > > > belongs_to :name, :class_name => "Phrase", :foreign_key => "name" > > > in my test > > context "test"do > > should have_many :phrases > > end > > > in language.rb > > belongs_to :name, :class_name => "Phrase", :foreign_key => "name" > > > error is > > > 1) Failure: > > test: check has_many and belongs_to association should have many > > languages. (PhraseTest) [/usr/local/lib/ruby/gems/1.9.1/gems/ > > shoulda-2.11.3/lib/shoulda/context.rb:324]: > > Expected Phrase to have a has_many association called languages > > (Language does not have a phrase_id foreign key.). > > Expected block to return true value. > > > I dont really understand what it's warning now.. > > It might help us if you showed us the failing test. Also I think it > would be better to use name_id as the foreign key for language > belongs_to :name. >
> Colin model language.rb class Language < ActiveRecord::Base belongs_to :phraes, :class_name => "Phrase", :foreign_key => "name" end model phrase.rb has_many :phrases, :class_name => "Phrase", :foreign_key => "category_id" belongs_to :category, :class_name => "Phrase" has_many :languages end test file phrase_test.rb context "check has_many and belongs_to association" do should belong_to :category should have_many :phrases should have_many :languages end error Started ..........F....................................... Finished in 1.313199 seconds. 1) Failure: test: check has_many and belongs_to association should have many languages. (PhraseTest) [/usr/local/lib/ruby/gems/1.9.1/gems/ shoulda-2.11.3/lib/shoulda/context.rb:324]: Expected Phrase to have a has_many association called languages (Language does not have a phrase_id foreign key.). Expected block to return true value plz help .. thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" 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/rubyonrails-talk?hl=en.

