Reputation: 273
I need to use Rails select method as oppose to *text_field* to search for legacy data. Unfortunately, one of the attributes in the Project's table is capitalized, and even if I use alias_attribute on it, it still complains for correct naming from the actual table. The code blow works to a point, but instead of passing the Project_cont as the name value in the params, I get an id for that Description. How can I make this work? Here is the current code I have at the moment:
= search_form_for @search, :html => {:class => "form-inline"} do |f|
.form-group
= f.select :Decsription_cont, options_from_collection_for_select(Project.all, "id","Description", @search)
Here is the controller's code:
def index @search = Project.search(params[:q]) @products = @search.result endHere is the view's code:
= search_form_for @search, :html => {:class => "form-inline"} do |f| = f.select :Decsription_cont, options_from_collection_for_select(Project.all, "id","Description", @search.description_cont) = f.submit
Upvotes: 3
Views: 2253
Reputation: 6025
You should add description_cont
to your @search
, like this:
f.select :description_cont, options_from_collection_for_select(Project.all, "id", "description", @search.description_cont)
Upvotes: 0