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 phrase model has_many :others reason model validates_presence_of :phrase_id, :message => "ERROR_MISSING_PHRASE" belongs_to :phrase other model validates_presence_of :phrase_id, :message => "ERROR_MISSING_PHRASE" belongs_to :phrase test file of prescription_test.rb context "checking assocciation" do should have_many :phrases, :through => :others end -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 8 July 2011 21:19, Yennie <joanne0558-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 => :reasonsYou 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 :phraseAgain you will need belongs_to prescription.> > other model > validates_presence_of :phrase_id, :message => "ERROR_MISSING_PHRASE" > belongs_to :phraseand belongs_to prescription.> > test file of prescription_test.rb > context "checking assocciation" do > should have_many :phrases, :through => :othersAbove you have specified through reasons not through others. Either the test or the relation is wrong. 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Jul 8, 2011 at 4:28 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 8 July 2011 21:19, Yennie <joanne0558-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.