[Ruby] Preserving State
Eric Hodel
drbrain at segment7.net
Tue Dec 5 11:52:39 PST 2006
On Dec 5, 2006, at 11:37 , Neil Moomey wrote:
> Does Rails have some cool feature for preserving state after the first
> post? In the past I have used a mixture of hidden form fields, URL
> get
> variables, and cookies to get the job done but I'm wondering if
> Rails has
> something I'm missing? My application needs to be able to remember
> the
> values the user entered in a web form for the second, third, fouth
> pages etc
> when he clicks the Next button. I accomplished what I need by
> reposting the
> variables in hidden fields with the same name. It works great but
> now I'm
> wondering if the smart people from Rails have a better way.
You're looking for session
def my_action
session[:value] = params[:value]
end
You can store arbitrary objects in the Session.
http://api.rubyonrails.org/classes/ActionController/Base.html
--
Eric Hodel - drbrain at segment7.net - http://blog.segment7.net
I LIT YOUR GEM ON FIRE!
More information about the Ruby
mailing list