Closed tombeynon closed 9 years ago
I think I like your last suggestion to have a searchable?
method
I vote option A ("null / empty partial")
My only concern with this is around the naming, search is very generic and could be used by someone consuming this, maybe rawnet_admin_search or admin_search or something that's less likely to be implemented by someone else using this?
Personally I love the idea of having a searchable?
method, but I feel like we'll end up littering the controllers with this kind of config if we're not careful. Think the empty partial makes more sense to keep it clean, especially as the chances are they'll have to modify the search form anyway (extra params etc).
@efexen the views are namespaces to rawnet_admin and the resource, so the chances of a clash are slim. I'll name it listing_search
though.
Not 100% sure about this so any comments would be great. Search is now removed from the
index
view by default, but can be re-included using content_for(:search).The main problem with this is that the
index
view will now need to be overridden just to add search, and where possible we want to avoid overriding templates. To make this easier, I've stripped back theindex.html.erb
template so it just includes a few partials, rather than the whole listing table.Alternatively, we could render a
search
partial into theindex
template, but leave it blank by default. Then that partial can be overridden to include the content_for, rather than the wholeindex
view.The other alternative is to implement a
searchable?
method on the controller, which is false by default but can be overridden by resource controllers.Thoughts?