class Score
belongs_to :test_user
end
score table will has id,test_user_id,score
if you want to get a user score
just give test_user.score
--
Posted via http://www.ruby-forum.com/.
That should be class Score.
> belongs_to :tests_user, :foreign_key => :reg_no
> end
> where reg_no is a unique field in both the table!
You only need reg_no in the scores table
> score = Score.find(:first) gives me the first record from score table
>
> Now as i do score.tests_user it gives nill.
> and same with if i do
> test_user = TestsUser.find(:first)
> then test_user.score is showing as nil...
>
> Is this issue because of the foreign_key is not the default id!!!!
There should be no problem with a non-default foreign key. What do
you see if you do
score = Score.find(:first).reg_no
It should be an id of a TestsUser
Colin