Skip to content

Instantly share code, notes, and snippets.

@jamesalmond
Created November 9, 2010 21:42
Show Gist options
  • Save jamesalmond/669871 to your computer and use it in GitHub Desktop.
Save jamesalmond/669871 to your computer and use it in GitHub Desktop.
#some_object_controller.rb
class SomeObjectController < ApplicationController
def search
@search_results = SomeClass.find(params[:search_term])
if @search_results.count > 0
render :search_results
else
render :no_search_results
end
end
end
# search_results.html.haml
- @search_results.each do |result|
#...
# no_search_results.html.haml
%p Sorry, you have no results!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment