ernie/ransack — Issue #52: Custom attribute select
Author: jasonpaluck
Created: 2011-12-23 19:37:58+00:00
State: open

Ernie,

As I need to customize my ransack attribute select for an advanced search form, I started down the path of constructing a custom select helper. I've got it all working with the exception of persisting the selected attribute after post:

<%= select f.object_name, "name", options_for_select(['...','...'])... %>

Obviously it's a hack but it does work for the most part without me surrendering control to your attribute_select helper which I can't customize. Writing out the params hash after post clearly shows the nested value, but I can't seem to find a simple solution to persisting the selection after submit. I tried reverse-engineering your code, but you're using different helpers on the object. I've tinkered around with variations on :selected => params[f.object_name] without success. Any thoughts?

Thanks,

Jason