Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6833615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:00:00+00:00 2026-05-26T23:00:00+00:00

using this example on dynamic list https://github.com/sandeepleo11/Dynamic-Select-Menus-in-Rails-3 I managed to get dynamic select in

  • 0

using this example on dynamic list https://github.com/sandeepleo11/Dynamic-Select-Menus-in-Rails-3 I managed to get dynamic select in my form where I add a car, so when I select a carname in the next select field I get only car models that belongs to car I selected, Workin fine in this form.

So I decided to get this thing also in my search form, you select a car and based on that you select a car model and get the results. here is the website with search form http://ec2-107-22-183-238.compute-1.amazonaws.com/cars.

the problem here is that when I select a car I get ActionController::RoutingError (No route matches "/dynamic_search/6"): in console, 6 means I picked a car name who’s id is 6 and the select field for carmodels displays all models available.

here is some code I have for the search form and dynamic search:

_search.html.erb

    <%= form_for @search do |f| %>
    <%= f.label :carname_id_equals, "Select Car Make" %>
    <%= f.collection_select :carname_id_equals, Carname.order('name ASC').all,  :id, :name, :include_blank => 'All' %>
    <%= f.label :carmodel_id_equals, "Select Model" %>
    <%= f.collection_select :carmodel_id_equals, Carmodel.order('name ASC').all, :id, :name, :include_blank => 'All' %>
    <% end %>

dynamic_search.js.erb

$('#search_carmodel_id').empty();
<% for carmodel in @carmodels %>


   // alert(<%= carmodel.id %>);

      $('#search_carmodel_id').append($("<option></option>").attr("value",<%= carmodel.id %>).text('<%= carmodel.name %>'));


<% end %>

routes.rb

post "dynamic_carmodels/:id" => "cars#dynamic_search"

controller

def dynamic_search
    @carmodels = Carmodel.find_all_by_carname_id(params[:id])

    respond_to do |format|
      format.js
    end
  end

application.js

jQuery(document).ready(function() {

//    jQuery('#search_carmodel_id_equals').html("<option value=''>Select Carmodel</option>");
    jQuery('#search_carname_id_equals').change(function() {

        var data=$('#search_carname_id_equals').val();
        $.ajax({

            type: "POST",
             url: "http://"+location.host+"/dynamic_search/"+data,
            data: data,

            beforeSend: function()
            {
                //      alert('hi');
                //$('#status').html('<img src="loading.gif">');

            },

            success: function(response)
            {
                 //  alert(response);
                //  $('#search_carmodel_id_equals').html(html);    //dynamic_search.js.erb
                   //      $('#status').html(html);


            }

        });
    });
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:00:00+00:00Added an answer on May 26, 2026 at 11:00 pm

    Solved:

    routes is the problem:

    post "dynamic_carmodels/:id" => "cars#dynamic_search"
    

    should be

    post "dynamic_search/:id" => "cars#dynamic_search"
    

    and dynamic_search.js.erb

    $('#search_carmodel_id_equals').empty();
    <% for carmodel in @carmodels %>
    
    
       // alert(<%= carmodel.id %>);
    
          $('#search_carmodel_id_equals').append($("<option></option>").attr("value",<%= carmodel.id %>).text('<%= carmodel.name %>'));
    
    
    <% end %>strong text
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this code to be able to generate an dynamic select: demo: http://www.erichynds.com/examples/jquery-related-selects
i'm using this example implementation found at http://tangentsoft.net/wskfaq/examples/basics/select-server.html This is doing most of what
I am not using any javascript plugin, <html> <head> <title>sample dynamic select list</title> <script
I'm using this plugin: http://www.jeremymartin.name/projects.php?project=kwicks And my code follows this example: http://www.jeremymartin.name/examples/kwicks.php?example=7 I'm using
Just using this as an example... Here are the columns in my UserProfile table:
I have looked at this example using php and GD to piecewise-render a spiral
Using this question as the base is there an alogrithm or coding example to
(I'm using the pyprocessing module in this example, but replacing processing with multiprocessing should
For example, your application is using this way for passing vars into your application
Please take a look at this example: #include <iostream> #include <vector> #include <string> using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.