I am trying to find a particular (in this case the last, or most
recent) status for a user. As a user does certain things, new statuses
are added (into users_statuses).
I want to be able to show a list of users with their current status. I
get as far as at least getting the full list of users (@users =
User.find(:all)), but not sure how to output the list with just the
most recent status?
Help please?
<<< The models >>>
class User < ActiveRecord::Base
has_many :statuses, :through => :users_statuses
end
class Status < ActiveRecord::Base
has_many :users, :through => :users_statuses
end
class UserStatus < ActiveRecord::Base
belongs_to :user
belongs_to :status
end
<<< The controller >>>
@users = User.find(:all)