Ok, I need my users to fill in form hit a "continue" button, then be taken to a page were they can preview the content they just entered in the previous form. I know I need sessions and cookies to make this happen, but I''m not sure where to store the session data, or how to retrieve it. Can someone please explain this to me, as I am new to ROR and programming in general? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
rein.henrichs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Sep-01  17:34 UTC
Re: Need help with sessions
http://www.google.com/search?q=rails+session Rein On Sep 1, 12:22 pm, shybe <fludid...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok, I need my users to fill in form hit a "continue" button, then be > taken to a page were they can preview the content they just entered in > the previous form. I know I need sessions and cookies to make this > happen, but I''m not sure where to store the session data, or how to > retrieve it. Can someone please explain this to me, as I am new to ROR > and programming in general?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rein, Thanks for the link, I dont know maybe its just not clicking for me, but where I get confused is in the syntax. For example: if I have a form with name, email, and message, fields, then I I create a method... def preview session[:name] = ? session[:email] = ? session[:message] =? end I''m not sure what to put after the = sign or if maybe I''m not putting the correct thing in the braces, or maybe I''m missing some step all together. I think I''m missing something very basic, so any help would be greatly appreciated, I think I need the dummy explanantion. Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
rein.henrichs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Sep-01  18:19 UTC
Re: Need help with sessions
Here''s the short of it:
session is a hash. Rails (magically) persists this hash for you from
request to request, but all you need to know for now is that it''s a
hash and that you set and get keys in the session hash the same as you
do in any other hash. So as an example:
session[:foo] = "bar"
session[:foo] #=> "bar" ( session[:foo] returns the string
"bar" )
since session is just a hash, you can play around in irb by doing
session = Hash.new # or just session = {}
to get a feel for how it works.
Hashes can use anything as the key and store anything as the value,
but convention is to use symbols ( :something ) as your session keys
so just do that :) This is also a good practice for hashes in general.
It''s fine to store a string or any other simple (small) object in
session (unless it''s a 40MB long string or something):
session[:my_string] = "My string"
session[:my_hash] = {  :foo => "bar", :bizz => "bazz }
but convention is to store references to complex (big) objects (like
an ActiveRecord object) rather than the objects themselves, so for
instance:
session[:user_id] = @user.id
is better than
session[:user] = @user
Follow that one too. It''s a Good Thing. :)
Good luck
Rein
On Sep 1, 12:56 pm, shybe
<fludid...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Rein,
>
> Thanks for the link, I dont know maybe its just not clicking for me,
> but where I get confused is in the syntax.
> For example: if I have a form with   name, email, and message, fields,
> then I I create a method...
>
> def preview
> session[:name] = ?
> session[:email] = ?
> session[:message] =?
> end
>
> I''m not sure what to put after the = sign or if maybe I''m
not putting
> the correct thing in the braces, or maybe I''m missing some step
all
> together.
>
> I think I''m missing something very basic, so any help would be
greatly
> appreciated, I think I need the dummy explanantion. Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---