Skip to content

Instantly share code, notes, and snippets.

@poc7667
Created July 25, 2013 10:03
Show Gist options
  • Save poc7667/6078407 to your computer and use it in GitHub Desktop.
Save poc7667/6078407 to your computer and use it in GitHub Desktop.
Rails 3 Simple Search Form Example (without Ajax)
<%= form_tag translate_search_path, :method => :get do %>
<%= text_field_tag :search %>
<%= submit_tag 'Search_key' %>
<% end %>
get "translate/search" => "translates#search"
<ul>
<% if !@results.nil? %>
<% @results.each do |result| %>
<li>
<%= result.inspect %>
</li>
<% end %>
<% else %>
LOL
<% end %>
</ul>
def search
@results = Translate.search(params[:search])
respond_to do |format|
format.html # index.html.erb
format.js { render 'search' }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment