Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created January 13, 2009 05:18
Show Gist options
  • Save brandon-beacher/46338 to your computer and use it in GitHub Desktop.
Save brandon-beacher/46338 to your computer and use it in GitHub Desktop.
def index
finder = Person.ordered
finder = finder.matches params[:query] if params[:query]
finder = finder.enabled unless params[:disabled]
case params[:format]
when "csv"
@people = finder.find :all
else
@people = finder.paginate :page => params[:page], :per_page => params[:per_page]
end
respond_to do |format|
format.html
format.js { render :action => "index.rjs" }
format.csv do
headers["Content-Disposition"] = "attachment; filename=\"people.csv\""
render :action => "index.csv.haml", :layout => false, :content_type => "text/csv"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment