Do you have a helper method that provides the current user? Something like:
@cur_user ||= User.find(session[:user_id])
Then set up a relationship in your user model:
class User < AR::Base
then you can do
If you go through the messages relation, it constricts it only to
those messages that have the user_id belonging to that user.
Alternatively you could do
or set up a method in your Message class.
I think setting up the has_many :messages association and going
through that would be the most idiomatic way.
Also use the accessor method session instead of the instance variable
@session, which is deprecated.