Search Results

Search found 1 results on 1 pages for 'tryskele'.

Page 1/1 | 1 

  • How to use form_tag to update params

    - by Tryskele
    I have been struggling with a problem in Rails for a couple of days and still could not find the solution. Could you help me with that? Problem: I have a search box that puts a :search_string entry in the params structure. I use a form_tag for that and it works fine. <% form_tag :controller=> 'items', :action => 'find' do %> <%= text_field_tag :search_string, params[:search_string] %> <% end %> The problem is when I want to add and update other params key-value (in another view), for instance :start_date, to filter the search_string result. Here is the code snipped that I use in the view: <% form_tag :controller=> "items", :action => "find", :params => params do %> <%= hidden_field_tag :date_start, '2010-04-01' %> <%= submit_tag 'April' %> <% end %> <% form_tag :controller=> "items", :action => "find", :params => params do %> <%= hidden_field_tag :date_start, '2010-03-01' %> <%= submit_tag 'March' %> <% end %> When I first click on "April" submit button, then the params is correctly passed to the controller (i.e. there is a params[:start_date]='April'). However when I try to click "March" button afterwards, the params[:start_date] is not updated. I definitely think this is a stupid newbie mistake, but I cannot figure out how to properly use the form_tag. Could you tell me if I am doing something work? Otherwise, could you advise me which is the best way to update the params using form_tag's ? Thank you very much in advance. Miquel

    Read the article

1