[Rails] Re: A Good Tutorial on Params and Variables

Ilya Grigorik
2006-04-30T03:47:42Z

I don''t have a link for you, but I think it''s simpler than you
think...

Post/Get variables are passed in the ''content'' body of the
http request
for POST (form submit) and GET variables are passed in the url. In both
cases, the variables that are passed are immediately available to you
within params[:name_of_passed_param].

If you want to use sessions to store some information you can just
create a new variable in ''session[:name_of_var]''. So, for
example, if
you want to create a new class that will store a bunch of information
you can just do:

session[:user_info] ||= User.new

That will return the User object from the cart if it exists, and if
doesn''t it will create a new one. (Note, if you are embedding a
''class''
into sessions, you also need to specify a ''model'' so other
controllers
know how to process the chunk of data specified in the session).



Ted Battreall wrote:
> I have found various posts about instance variables, session variables
> and parameters (each of which seems to use differnet syntax and have
> different view on the "best practice") I would like to find a
single,
> reliable source that provides a good overview on all of it.
>
> Specifically, I would like to learn how to pass parameters between
> controllers and how to set session variables so they can be seen from
> any Controller/Model.
>
> Thanks