How to find the value of a select_tag using JQuery using Rails 4

I would like to find the value of a select_tag in Rails 4 using JQuery. Once I have the value I want to update the view with a partial containing radio buttons.

My code is not working. Can you let me know what I am doing wrong.

index.html.erb file

<%= form_tag experts_path, method: :get do %>
      <%= text_field_tag :query, params[:query] %>

    <h3>Skills Categories</h3>
        <%= select_tag "skill_categories", options_from_collection_for_select(@skill_categories, "id", "category"), prompt: "All Skills" %>

    <div class="skills"></div>
<% end %>

$( "#skill_categories" ).change(function() {
    var category_from_select = $(".skills").find(":selected").text();
    $(".skills").replaceWith("<div class='skills'><%=j render 'experts/skills', selected_category: category_from_select %></div>");

_skills/html.erb partial

<% skill_all.each do |skill| %>
    <%= radio_button_tag "skills[]", "#{}",
                         ((params[:skills] != nil) && (params[:skills].index( != nil) ? true : false) %>
    <%= %>
<% end %>


  def skills_search
    @skills = Skill.all


module ExpertsHelper

  def skill_all
    @skills = Skill.all


Try to change:

var category_from_select = $(".skills").find(":selected").text();


var category_from_select = $(this).find(":selected").text();

To get selected option, you need select element with#skill_categories not div with .skills

Need Your Help

c++ deleting vector class member memory in destructor

c++ memory-management vector

I have a class containing a vector member variable.

mod_rewrite httpd.conf: Block access to directories on HTTP_REFERER

php regex apache mod-rewrite

I am (learning) implementing a Front Controller pattern, redirecting all requests to index.php and appending as a query string (to be parsed later by PHP) via a mod_rewrite rule in httpd.conf, belo...