ruby on rails 3 - How to call helper method through select_tag -


i trying call helper method select_tag. tried this:

<%= select_tag(:themes, options_for_select({"black" => "compiled/styles", "green" => "compiled/styles2"})) %> 

when put alert(this.options[this.selectedindex].value) instead of calling method, works. how can change code call method desired?

edit

i have on application.js

$(document).ready(function() {    $('#display_themes').change(function(){        $.ajax({url: '<%= url_for :controller => 'application', :action => 'set_themes()', :id => 'this.value' %>',                data: 'selected=' + this.value,                datatype: 'script'        })     }) }); 

and in controller have set_themes methode

def set_themes()       @themes = params[:id]       respond_to |format|         redirect_to '/galleries'         format.html # index.html.erb         format.xml  { render :xml => @themes }     end end 

the problem @themes still empty change dropdown

routes.rb

match '', :controller => 'application', :action => 'set_themes()' 

to route application#set_themes:

match '/set_themes', to: 'application#set_themes', as: :set_themes 

with done, direct url in ajax follows:

$.ajax({url: "<%= set_themes_path %>", 

it should @themes = params[:selected] in controller based on trying in application.js.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -