params merge on for every action

hi

i got to merge a hash of parameters for every action for every
controller. the only thing i could image is modifying a super class
method.

so, how could i modify the method that take care of setting up the
parameters? is it ActionController.parameters?

hi

i got to merge a hash of parameters for every action for every
controller. the only thing i could image is modifying a super class
method.

No doubt I am showing my ignorance (as usual), but could you explain
in more detail what you are trying to do?

Colin

> i got to merge a hash of parameters for every action for every
> controller. the only thing i could image is modifying a super class
> method.

No doubt I am showing my ignorance (as usual),

well, at least we are 2! :wink:

but could you explain in more detail what you are trying to do?

is difficult to explain, but i'll try:

on simple words: a search form, with some inputs (search value, search
operator, search order an so on)

the problem: on every search, results can be edited, or if the users
wants to, create a new one (after a search), or just show a record (=
CRUD). but, after any CRUD action, it must go back to the orginal
search made. multiply this behaviour to all controllers.

so, i could (in fact i did) pass every single search input like hidden
inputs in order not lose those values between actions and views for
everycontroller. but i want something more clean and more
"automaticly". this will take more relevance, as i c controllers will
be more and more through time.

hope is more clear now.

thanks.

Vladimir Prieto wrote:

i got to merge a hash of parameters for every action for every
controller. the only thing i could image is modifying a super class
method.

so, how could i modify the method that take care of setting up the
parameters? is it ActionController.parameters?

I can't imagine why you would need to do something like this, but it
seems likely you could do what you want with a piece of custom Rack
middleware:

http://guides.rails.info/rails_on_rack.html#action-controller-middleware-stack

You could probably insert your middleware somewhere after the
ActionController::ParamsParser internal middleware.

Would an alternative be to store the information in the session? Then
you would not have to keep passing it to the controllers.

Colin

I think your solution is a little 'clunky'; as you're discovering - if
something's hard to do, there's probably an easier way.

Would it work for you to store the search criteria in the session? Any
controller action can access this, and if there are some actions that
accept the user posting changes to the search, then that action can
merge the changes into the session-stored value.

I can't imagine why you would need to do something like this

imagine this:

- too much records to search for.
- after a few searches, user finally get a group of records (not only
one) to work on.
- user edits one

...save it and he has to search again to get the same group? no way!
users are lazy. instead, why don't show him the same group of records
that he search before? that way, user can edit the next over and over
again without searching everytime.

so, how can i get the same group of searched records? searching
again. am i right?

, but it
seems likely you could do what you want with a piece of custom Rack
middleware:

http://guides.rails.info/rails_on_rack.html#action-controller-middlew

You could probably insert your middleware somewhere after the
ActionController::ParamsParser internal middleware.

i'll give a read! thanks!

didn't thought that. i'll play with it and see where i go.

thanks too.

Vladimir Prieto wrote:

I can't imagine why you would need to do something like this

imagine this:

- too much records to search for.
- after a few searches, user finally get a group of records (not only
one) to work on.
- user edits one

...save it and he has to search again to get the same group? no way!
users are lazy. instead, why don't show him the same group of records
that he search before? that way, user can edit the next over and over
again without searching everytime.

so, how can i get the same group of searched records? searching
again. am i right?

If I were to implement this I would create a new model, something like
Search or SavedSearch, and use the database to store recent searches.
Someone also mentioned that you could store the search criteria in the
session, which would work fine, as long as you only need to store one
set of search criteria per user.

Storing the search criteria in it's own table adds more flexibility to
the system. This way you could allow the users to essentially "bookmark"
their searches. Since you would have this separate Search model you
could provide views for users to organize and manage their searches.