Passing params between actions?


#1

I am wondering what are the rules for the availability of params in
controller actions? If I redirect, are the params still available? How
about when I render a different action? It doesn’t seem so… What are
the
best ways to pass them?

I’m trying to use an ajax scaffold component with 2 actions which load
different data for the component. I have an ajax scaffold component
“listings” that I want to use on one page for “new listings” and on a
different page for “listings search results”. I’m also trying to make
the
“search” action save an object called “saved_search” with the search
parameters so the searches can be re-run later.

So where should code specific to the search action go? I dont’ want to
put
it in component_update as then both actions would use it. But if I put
it
in the search action, I’m not sure how to then pass the params on to the
component_action?

if @params[:saved_search_id]
@saved_search = SavedSearch.find(params[:saved_search_id])
else
@saved_search = SavedSearch.new
saved_search.update_attributes(params[:saved_search])
end

Thanks to Brian H. and Liquid for great answers on my doc question!
Thanks,

Eric