First of all, I am a bit of a noob so sorry if this is a very simple
question.
Basically I want to model the relationship between a User (U) and a
Questionnaire(Qu). A Qu
has one Subject (the user that the questionnaire is about) and many
Reviewers (people/users that work
with the User answering the Qu about the U).
My migrations can be found <a href="http://pastie.caboo.se/
84359">here</a> and models ca be
found <a href="http://pastie.caboo.se/84360"></a>
I tried the following in script/console
<code>
quest1 = Questionnaire.create(:title => "First One")
sub1 = User.create(:login => "sub1", :email =>
"sub1-zuv13RyHHZkAvxtiuMwx3w@public.gmane.org", :name
=> "Subject 1", :password => "password",
:password_confirmation =>
"password")
rev1 = User.create(:login => "rev1", :email =>
"rev1-zuv13RyHHZkAvxtiuMwx3w@public.gmane.org", :name
=> "reviewer 1", :password => "password",
:password_confirmation =>
"password")
rev2 = User.create(:login => "rev2", :email =>
"rev2-zuv13RyHHZkAvxtiuMwx3w@public.gmane.org", :name
=> "reviewer 2", :password => "password",
:password_confirmation =>
"password")
a_sub = Subjectships.create(:user_id => sub1.id, :questionnaire_id =>
quest1.id)
a_rev1 = Reviewerships.create(:user_id => rev1.id, :questionnaire_id
=> quest1.id)
a_rev2 = Reviewerships.create(:user_id => rev2.id, :questionnaire_id
=> quest1.id)
</code>
but when I tried <code>quest1.subjects</code>
I get the following error
<error>
NameError: uninitialized constant Questionnaire::Subjectship
from /Users/paulbrackenridge/Rails/projects/work/enabling
development/ED/vendor/rails/activerecord/lib/../../activesupport/lib/
active_support/dependencies.rb:477:in `const_missing''
from /Users/paulbrackenridge/Rails/projects/work/enabling
development/ED/vendor/rails/activerecord/lib/active_record/base.rb:
1479:in `compute_type''
from /Users/paulbrackenridge/Rails/projects/work/enabling
development/ED/vendor/rails/activerecord/lib/active_record/
reflection.rb:125:in `send''
from /Users/paulbrackenridge/Rails/projects/work/enabling
development/ED/vendor/rails/activerecord/lib/active_record/
reflection.rb:125:in `klass''
from /Users/paulbrackenridge/Rails/projects/work/enabling
development/ED/vendor/rails/activerecord/lib/active_record/
reflection.rb:169:in `source_reflection''
from /Users/paulbrackenridge/Rails/projects/work/enabling
development/ED/vendor/rails/activerecord/lib/active_record/
reflection.rb:169:in `collect''
from /Users/paulbrackenridge/Rails/projects/work/enabling
development/ED/vendor/rails/activerecord/lib/active_record/
reflection.rb:169:in `source_reflection''
from /Users/paulbrackenridge/Rails/projects/work/enabling
development/ED/vendor/rails/activerecord/lib/active_record/
reflection.rb:178:in `check_validity!''
from /Users/paulbrackenridge/Rails/projects/work/enabling
development/ED/vendor/rails/activerecord/lib/active_record/
associations/has_many_through_association.rb:6:in `initialize''
from /Users/paulbrackenridge/Rails/projects/work/enabling
development/ED/vendor/rails/activerecord/lib/active_record/
associations.rb:1048:in `new''
from /Users/paulbrackenridge/Rails/projects/work/enabling
development/ED/vendor/rails/activerecord/lib/active_record/
associations.rb:1048:in `subjects''
from (irb):18
</error>
I''m not quite at home with the error messages yet, so if anyone could
give me a hand I would
be eternally greatfull :-)
Cheers,
P
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---