Skip to content

Instantly share code, notes, and snippets.

@px-amaac
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save px-amaac/440db488ef03964072e9 to your computer and use it in GitHub Desktop.
Save px-amaac/440db488ef03964072e9 to your computer and use it in GitHub Desktop.
here
I am getting all photos through the tags table where tags has a search key and search value. I order them.
Is there a way to only get uniques? Right now if i have 2 tags with the same name it will return the same photo twice.
@photos = Photo.joins(:tags).where(tags: { key: params[:searchkey], value: params[:searchvalue] }).order("created_at DESC")
@photos = Photo.joins(:tags).where(:tags => { :key => params[:search_key], :value => params[:search_value] }).order("created_at DESC")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment