hi!! i have a little problem, that i cant resolve. how can i put in a session as an object? i mean, for example i know only to give a value to a session so: @session[''something''] = "hello world" but i want to give to the @session[''something''] a name, an age, etc so i can call the name of the session like: @session[''something''].name or @session[''something''].age i dont know which one the right syntax is. thanks!! bye! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hey sabin, @session[''key''][''value''] = 3 @session[''key''][''value2''] = 3.5 @session[''key2''][''someother-value''] = 4 this would result in the data you just entered like this: (two seperate hashes) ''key'' hash would look like this: {"value" => 3, "value2" => 3.5 } and the ''key2'' hash would look like this: {"someother-value" => 4 } ...if this isn''t helpful enough, i personally like rubycentral.com; it''s a great site. either way, i hope on of the two provides a good enough solution to the problem. good luck, harp -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hey harper! thanks for ur answer, but it doesnt work :S i was checking the "login" generator, and there the script put different values as i like in the session ''user''. ur syntax @sessionâ—‹[''something''][''vaue1''] = 100 doesnt work. someone has an idea?? ty! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
i''m not exactly sure of what you are trying to do in the big picture, so i may be leading you to places you don''t need to go to (?) , but here''s a shot in the dark, i hope it somewhat helps. if you want to assign values to a @session[x][y] variable, (creating a hash) you will first need to define that the @session[x] is of a Hash type. so, to assign, say, 100 to @session[''something''][''vaue1''] you will first need to define @session[''something''] = Hash.new and then @session[''something''][''value1''] = 100 ...if you check the contents of the session ((@session[''something''].inspect)) you will see that it will give you: {''value1'' => 100} (btw, if you are using the acl system from wiki.rubyonrails.com, and you don''t want to erase the @session[''user''] - - you just want to add more data, make sure you put the Hash.new BEFORE you the session is created. (i.e, the user logs in) so that Hash.new doesn''t overwrite the current session. i hope this helps. i know there are great reading materials in rubycentral.com if i''m leading you round round and astray. harp -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Sabin, sabin sur wrote:> how can i put in a session as an object?There''s no magic here. The session will hold an object if you assign an object to it.> @session[''something''] = "hello world"But if you keep using ''@session'' you''re going to have problems. The instance variable syntax has been depracated since 1.2. Use ''session[]'' instead (drop the ''@'')> but i want to give to the @session[''something''] > a name, an age, etcYou need to create a model for your ''something'' object that includes those attributes. Then assign that object to the session. The syntax you wanted to use should work, but I haven''t tested it.. hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---