Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save wfarr/178057 to your computer and use it in GitHub Desktop.
class PostsController < ApplicationController
...
# Displays posts that contain any of one or more tags passed in
# GET /posts/tag/:tag1,:tag2,... || GET /posts/tag/:tag
def tag
@tag = params[:tag]
@tag = @tag.split(",") if @tag =~ /,/
@posts = Post.all(:conditions => { :tags => @tag }, :order => 'created_at desc' )
respond_to do |format|
format.html
format.xml { render :xml => @posts }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment