Part 1: What i want is to fetch records of two tables in one collection select. Later, i want to perform search based on selected item.
So far i have managed to get the records in this manner in one select:
Controller:
@result1 = Model1.all
@result2 = Model2.all
@all = @result2 | @result1
View:
<%= collection_select :id,:id,@all, :id, :id,{prompt: "All Templates"} %>
The problem here is i want to display the name form Model1 and type from Model2.
Part 2 If the user selects the name
, i want to get record from Model1 and if the type
is selected, i want to get records form Model2.
All i am able to get is the id
of both the models in one collection select. I am out of ideas. Let me know if any more details are required. Any help is appreciated. Thanks.