Topic: Compare two polymorphic models? Pretty sure I'm doing it wrong.
if admin? @downloads = Download.find(:all, :order => 'position') else @all_downloads = Download.find(:all, :order => 'position') @downloads = Array.new # for each, check that user has one of the roles associated with the download. @all_downloads.each do |d| current_user.roles.each do |r| if d.has_role?(r.name) @downloads << d end end end end @downloads.uniq!
Anyone know a better way to do this?