Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --controller--
- class SearchController < ApplicationController
- def query
- @query = params[:query]
- @posts = Post.search(@query)
- format.html { redirect_to(posts_url) }
- format.xml { head :ok }
- end
- end
- --view--
- <% form_tag :controller => "search", :action => "query" do %>
- <p>
- <%= text_field_tag "query", "", "size" => 30 %>
- </p>
- <p>
- <%= submit_tag "Search" %>
- </p>
- <% end %>
Add Comment
Please, Sign In to add comment