Rails: Dynamic select menu

I’m following the tutorial of railscast #88 Dynamic select menus. I got
error in jquery part of it. I’m not a familiar in jquery I just follow
tutorial, I already searched the error.

Error on console

Uncaught Error: Syntax error, unrecognized expression:
$serviceprovider_service_id :


<%= form_for(@serviceprovider, html: { :multipart => true }, class:
‘form-horizontal’) do |f| %>

  <div class="form-group">
        <label class="client-login-label">Service</label>
        <%= collection_select(:serviceprovider, :service_id, 

Service.all, :id, :service, prompt: ‘Choose Service’) %>
<%#= f.text_field :barangay, class: ‘form-control
client-login-field’, placeholder: ‘Barangay’ %>

  <div class="form-group">
        <label class="client-login-label">Category</label>
        <%= grouped_collection_select(:serviceprovider, 

:category_id, Service.order(:service), :categories, :service, :id,
:name, prompt: ‘Choose Category’) %>
<%#= f.text_field :barangay, class: ‘form-control
client-login-field’, placeholder: ‘Barangay’ %>

  <div class="form-group">
    <%= f.submit("Register", class: 'btn btn-lg btn-success 

client-signin-btn’) %>

<% end %>


jQuery ->
categories = $(’#serviceprovider_category_id’).html()
$(’#serviceprovider_service_id’).change ->
service = $(’#serviceprovider_service_id :selected’).text()
options =
if options

Change the single quotes to escaped double quotes


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs