In my Rails application I have a User model (more or less built by RESTful Authentication), and several other models belonging to the user. So let's say, for example:
user has_many :posts
post belongs_to :user
Anywhere in the users resource I can access the user variables as I would expect. @user.name, @user.email, @user.login, etc. all return the expected object.
However, I can't seem to access any of these attributes from any other resource (in this example, posts) without it returning nil (nil rather than a NoMethodError).
Why is this? It seems even stranger to me that I can call current_user
just fine, as in current_user.name
, current_user.email
, but not for the user in question.