-
Notifications
You must be signed in to change notification settings - Fork 332
Search Action Flow
By default, ActiveScaffold has the action module :search, but it can be changed to :field_search, using conf.actions.swap :search, :field_search. Both modules use the action show_search to open the form.
These methods are called in the following order:
-
search_authorized_filtercalled as before_action-
search_authorized?(or the method defined in conf.search.link.security_method if it's changed) is called to check the permission. If this method returns false,search_authorized_filterwill raise ActiveScaffold::ActionNotAllowed.
-
-
show_search-
respond_to_action, which will call the corresponding response method for show_search action and the requested format.
-
Then it will render these views:
- search.html.erb (only for HTML request)
- _search.html.erb
These methods are called in the following order:
-
search_authorized_filtercalled as before_action-
search_authorized?(or the method defined in conf.field_search.link.security_method if it's changed) is called to check the permission. If this method returns false,search_authorized_filterwill raise ActiveScaffold::ActionNotAllowed.
-
-
show_search-
respond_to_action, which will call the corresponding response method for show_search action and the requested format.
-
Then it will render these views:
- field_search.html.erb (only for HTML request)
- _field_search.html.erb
Some of the columns defined in config.field_search.columns may be rendered in a subgroup which is collapsible and hidden by default, adding them to config.field_search.optional_columns too. When the form is open with a search active, they will be in the default group instead of the optional subgroup. The method visibles_and_hiddens can be overrided in a helper module to change the columns which are hidden, e.g. depending on params used to load the list.
Field_search module can be added without using swap, with conf.actions << :field_search. ActiveScaffold don't support having 2 action links for the same action with the same parameters, so the action link for field_search should use the parameter kind with the value :field_search:
conf.field_search.link.parameters = {kind: :field_search}
Then show_search will render the view or partial for search module, and show_search with kind=field_search will render the view or partial for field_search module.