Ruby on Rails Sunday, April 1, 2012

Looking after the children but I think you got it - thanks :-)

two changes...

model filename from user_names.rb to user_name.rb

and as you say

class UserName < ActiveRecord::Base

gives...

ruby-1.9.2-p290 :005 > User.last.names
User Load (0.8ms) SELECT "users".* FROM "users" ORDER BY "users"."id"
DESC LIMIT 1
Name Load (1.0ms) SELECT "names".* FROM "names" INNER JOIN
"user_names" ON "names"."id" = "user_names"."name_id" WHERE
"user_names"."user_id" = 85
=> [#<Name id: 519, given: "Jeremiah", position: 1, gender: "m",
created_at: "2012-03-25 17:21:52", updated_at: "2012-03-25 17:21:52">]
ruby-1.9.2-p290 :006 >

(first user had no names)


lovely thanks.

--
Posted via http://www.ruby-forum.com/.

--
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@googlegroups.com.
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.

No comments:

Post a Comment