How do I change the following bit of code so that I only have records with distinct sender_id and message_id combinations:
@roles = Role.find_all_by_simulation_id(session[:sim_id])
@messages = RolesMessages.find(:all, :conditions => ["sender_id IN (?) ", @roles.map(&:id)], :order => 'created_at DESC')
Edit: now that I think of it, group by is probably a better option.
:group => 'sender_id, message_id'will probably meet your needs betteryou can also do something like:
(I prefer to make the query myself… call me crazy)