Alexander Farley wrote in post #978480: > That helps a lot. To clarify, I am not necessarily looking to create > seed data upon creation of a User; just trying to figure out how to > "link" the creation of the two resources. The create_model method sounds > about right. > > Anyway, your info gives me plenty to read up on for now. Thanks again > > Alex
Hi Alex, To simplify how you see those methods, you don't necessarily have to create a new user object. You can use: user = User.first .. and then look through the methods for the user object. The reason why I supplied two different puts statements is so that you can see the difference between methods for each. One is showing the methods available to the User "class", while the other is showing methods available to the User "object". Look for build_ methods as well as these will not save the record until you forcibly save the record. It will allow you a little more flexibility with your getting used to the console. Also notice that the create_ and build_ methods available to the user object are usuable with has_one relationships. While the same methods are usuable with objects from models that have belongs_to relationships. So, as an example: has_many :moderators has_many :topics has_many :posts has_one :userprofile You would see the create_ and build_ methods for a user object only for userprofile. user = User.first user.methods.sort.each do |method| p method end ... methods.. ... build_userprofile ... create_userprofile ... etc.. Likewise, for topic, if you had: class Topic < ActiveRecord::Base belongs_to :user #... end topic = Topic.first topic.methods.sort.each do |method| p method end ... methods.. ... build_user ... create_user ... etc.. Test out a brief example just to see what happens: topic.build_user As for accessing the table data for each model with has_one or has_many from the user model.. topics = User.first.topics And if you want to iterate over the returned array.. topics.each do |topic| p topic end -- 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 [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.

