On Fri, Jul 8, 2011 at 4:28 PM, Colin Law <[email protected]> wrote:
> On 8 July 2011 21:19, Yennie <[email protected]> wrote: > > Hi everyone, > > > > I am testing the validation of association of the model but i can a > > error.. plzz help > > > > > > error > > /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/ > > active_record/matchers/association_matcher.rb:27:in `have_many': wrong > > number of arguments (2 for 1) (ArgumentError) > > from > /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/ > > context.rb:429:in `method_missing' > > from test/unit/prescription_test.rb:71:in `block in > > <class:PrescriptionTest>' > > from > /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/ > > context.rb:306:in `call' > > from > /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/ > > context.rb:306:in `merge_block' > > from > /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/ > > context.rb:301:in `initialize' > > from > /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/ > > context.rb:199:in `new' > > from > /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/ > > context.rb:199:in `context' > > from test/unit/prescription_test.rb:64:in > `<class:PrescriptionTest>' > > from test/unit/prescription_test.rb:3:in `<top (required)>' > > from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ > > active_support/dependencies.rb:235:in `load' > > from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ > > active_support/dependencies.rb:235:in `block in load' > > from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ > > active_support/dependencies.rb:227:in `load_dependency' > > from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/ > > active_support/dependencies.rb:235:in `load' > > from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in > `block > > in <main>' > > from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in > `each' > > from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in > `<main>' > > Loaded suite /usr/local/lib/ruby/1.9.1/rake/rake_test_loader > > Started > > > > > > > > there is one > > > > prescription model > > has _many :others > > has_many :phrases, :through => :reasons > > You also need has_many :reasons in order to specify has_many through > (I think). Or should this be through :others? > > > > > phrase model > > has_many :others > > > > reason model > > validates_presence_of :phrase_id, :message => "ERROR_MISSING_PHRASE" > > belongs_to :phrase > > Again you will need belongs_to prescription. > > > > > other model > > validates_presence_of :phrase_id, :message => "ERROR_MISSING_PHRASE" > > belongs_to :phrase > > and belongs_to prescription. > > > > > test file of prescription_test.rb > > context "checking assocciation" do > > should have_many :phrases, :through => :others > > Above you have specified through reasons not through others. Either > the test or the relation is wrong. > > I follow the way that you said and edit "belongs to prescription" right now it gives an error /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/association_matcher.rb:27:in `have_many': wrong number of arguments (2 for 1) (ArgumentError) from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:429:in `method_missing' from test/unit/prescription_test.rb:71:in `block in <class:PrescriptionTest>' from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:306:in `call' from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:306:in `merge_block' from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:301:in `initialize' from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:199:in `new' from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:199:in `context' from test/unit/prescription_test.rb:64:in `<class:PrescriptionTest>' from test/unit/prescription_test.rb:3:in `<top (required)>' from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in `load' from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in `block in load' from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:227:in `load_dependency' from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in `load' from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `block in <main>' from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `each' from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `<main>' Loaded suite /usr/local/lib/ruby/1.9.1/rake/rake_test_loader Started plz help > Colin > > -- > 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. > > -- 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.

