Skip to content

Instantly share code, notes, and snippets.

@neotericdesign
Created February 7, 2011 22:24
Show Gist options
  • Select an option

  • Save neotericdesign/815374 to your computer and use it in GitHub Desktop.

Select an option

Save neotericdesign/815374 to your computer and use it in GitHub Desktop.
scope :similar, lambda { |id, tag_name|
unscoped {
where(['artwork_entries.id != ?', id]).limit(2).tagged_with(tag_name).order('RAND()')
}
}
scope :similar, lambda { |id, tag_name|
send(:with_exclusive_scope) do
where(['artwork_entries.id != ?', id]).limit(3).tagged_with(tag_name).order('RAND()')
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment