Hi,
i need to implement a simple text function for the app i dev now.
1- the form in app/views/layouts
<% form_tag({:controller => “teachers”, :action => “search”}, :method =>
“get”) do %>
<%= text_field_tag :query, nil, :id => “search-text” %>
<%= submit_tag(“GO”, :id => “search-submit”) %>
<% end %>
2- the search method in teacher_controller.rb
def search
session[:query] = params[:query].strip if params[:query]
if session[:query]
@teachers = Teacher.find(:all, :conditions => ["materie LIKE ?",
“%#{session[:query]}%”], :order => “cognome ASC”)
end
end
3- the page for the result in app/view/teachers/search.html.erb
Teachers found
<% if searchresults.length == 0 %>
No teacher found...
<% elsif params[:query] == "" %>Insert a term, please.
<% else %>-
<% for teacher in searchresults %>
- <%= link_to teacher.cognome , teacher_url(:id => teacher.id)%> <% end %>
But when I push the search button the page goes to the show function…
Heeeeeeelp !!!
Many many thanks to all who…