How to use Rails select with ransack -
i need use rails select method oppose *text_field* search legacy data. unfortunately, 1 of attributes in project's table capitalized, , if use alias_attribute on it, still complains correct naming actual table. code blow works point, instead of passing project_cont name value in params, id description. how can make work? here current code have @ moment:
= search_form_for @search, :html => {:class => "form-inline"} |f| .form-group = f.select :decsription_cont, options_from_collection_for_select(project.all, "id","description", @search)
here controller's code:
def index @search = project.search(params[:q]) @products = @search.result endhere view's code:
= search_form_for @search, :html => {:class => "form-inline"} |f| = f.select :decsription_cont, options_from_collection_for_select(project.all, "id","description", @search.description_cont) = f.submit
you should add description_cont @search, as
f.select :decsription_cont, options_from_collection_for_select(project.all, "id","description", @search.description_cont)
Comments
Post a Comment