Skip to content

Instantly share code, notes, and snippets.

@wfarr
Created August 30, 2009 17:49
Show Gist options
  • Select an option

  • Save wfarr/178056 to your computer and use it in GitHub Desktop.

Select an option

Save wfarr/178056 to your computer and use it in GitHub Desktop.
class PostsController < ApplicationController
def tag
# Will return a list of items matching one or any tags passed to the controller, sorted, without duplicates
@tag = params[:tag]
@tag = @tag.split(",") if @tag =~ /,/
@posts = Post.all(:conditions => { :tags => @tag }, :order => 'created_at desc' )
...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment