I'm following a rails tutorial (Hartl) and it's been fine so far, but
something doesn't seem to be working right.

I have two basic models so far, "User" and "Micropost".

class User < ActiveRecord::Base
  has_many :microposts
end

class Micropost < ActiveRecord::Base
  belongs_to :user
end


If I do something like:
"first_user = User.first"
Then:
"first_user.microposts" - should return a hash of the first user's
microposts, but it just returns empty.

I'm sure there is data.

If I do "Micropost.first" it returns what I should see with
"first_user.microposts". If I do "Micropost.first.user_id" it does
return "1", so I know the association is there.

I did kill the rails server by pressing control+c, and then restarted
but that didn't make any difference.

Any ideas?  I'm on Ubuntu 10.04/Ruby version 1.8.7/RubyGems 1.8.5/Rack
version 1.2/Rails version 3.0.9 if that helps.

-- 
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.

Reply via email to