How to use observer_field in RoR?
Posted
by Sindri Guðmundsson
on Stack Overflow
See other posts from Stack Overflow
or by Sindri Guðmundsson
Published on 2010-06-12T18:55:44Z
Indexed on
2010/06/12
19:02 UTC
Read the original article
Hit count: 227
ruby-on-rails
Hi, I have a single select_tag with categories gathered from array in controller. When the user selects a category I want the application to redirect to the selected category. I have the following code in my view which. (I've tried both using :method => :get and :post, only change is in development.log)
<%=select_tag "cat_selected", options_for_select(@cats_for_mt)%><br>
<%=observe_field 'cat_selected',
:url => {:action => :viewflokkur},
:with => 'cat',
:method => :get %>
When I select one of the options the following gets logged to development.log.
Processing CategoriesController#viewflokkur (for 127.0.0.1 at 2010-06-12 12:33:26) [GET]
Parameters: {"cat"=>"Taugasjúkraþjálfun", "authenticity_token"=> "B2u5ULNr7IJ/ta0+hiAMBjmjEtTtc/yMAQQvSxFn2d0="}
Rendering template within layouts/main
Rendering categories/viewflokkur
Completed in 20ms (View: 18, DB: 0) | 200 OK [http://localhost/categories/viewflokkur?cat=Taugasj%C3%BAkra%C3%BEj%C3%A1lfun&authenticity_token=B2u5ULNr7IJ%2Fta0%2BhiAMBjmjEtTtc%2FyMAQQvSxFn2d0%3D]
According to this I should now be in "viewflokkur", but nothing changes in the browser window. Is there anything else I need to do, maybe in the controller?
BR,
Sindri
© Stack Overflow or respective owner