Created
July 25, 2013 10:03
-
-
Save poc7667/6078407 to your computer and use it in GitHub Desktop.
Rails 3 Simple Search Form Example (without Ajax)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_tag translate_search_path, :method => :get do %> | |
<%= text_field_tag :search %> | |
<%= submit_tag 'Search_key' %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get "translate/search" => "translates#search" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<% if !@results.nil? %> | |
<% @results.each do |result| %> | |
<li> | |
<%= result.inspect %> | |
</li> | |
<% end %> | |
<% else %> | |
LOL | |
<% end %> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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