I have a database table with vehicles in it and they’re separated into columns by year, make, model, and trim.
I’d like to create a form where a user can select the year, then the make, then the model, then the trim with each selection (except for year) taking into consideration the selection before it.
Is there a way to do this? What would it look like?
Well, you have lots of different ways to do it.
I would do the following way:
In your controller,
In your models you can define some scopes:
Hope this helps!
Regards
Edit:
I’ll explain in parts
In the javascript I’m associating an event to the list of year, then I make a GET request to a controller action that get all make values. Then I fill the MAKE list with it
You should do it to make, model and trim also
In the controller I’m creating a method to retrieve the make values (that is called by the get method). You’ll have to do it for the other retrieved values also. Model and trim.
In the model I just suggested a resource that you may use to facilitate the queries that is the scope feature.
Please accept my reply!