Nice. I've built something very similar in my current app. In my app it's called `SearchModel` and descendants live within the `app/models` dir. I include some modules from `ActiveModel` to make it act as a regular db-backed model, which allows me to use it with `form_for`.
Comments
Nice. I've built something very similar in my current app. In my app it's called `SearchModel` and descendants live within the `app/models` dir. I include some modules from `ActiveModel` to make it act as a regular db-backed model, which allows me to use it with `form_for`.
Ah, that's neat. I usually just build these forms without the Rails helpers, using something like:
Which works out nicely, since the method defaults to 'GET' and the action defaults to the current path.It'll do too, but I think it's nice to abstract the http-layer completely away from the view.
In case you want to replicate, I believe the relevant part is simply adding this to the base class:
And then add `attr_reader` for each field.