I have a sidebar that fetches articles in my application_controller but I want to add a search function to it so I modified it to look like this
def fetch_articless
@articles = Article.search(params[:search])
end
The search works fine, but I currently have my form submitting to my application root so if you search, it always redirect to the root.
<%= form_tag root_path, :method => 'get' do %>
<p>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", :title => nil %>
</p>
<% end %>
Since my sidebar is on every page I would like to be able to submit my form to whatever page I am currently on and the search would be performed through the application helper. I assume I need to make a new route but being new to Rails I don't really understand how routes work yet.
Any help is greatly appreciated.