could someone help me with cookies. I need help setting them and using them for output and etc. thanks. -- Posted via http://www.ruby-forum.com/.
On 6/26/06, raj kapila <rkapila@uwo.ca> wrote:> could someone help me with cookies. > > I need help setting them and using them for output and etc.http://api.rubyonrails.org/classes/ActionController/Cookies.html
James Ludlow wrote:> On 6/26/06, raj kapila <rkapila@uwo.ca> wrote: >> could someone help me with cookies. >> >> I need help setting them and using them for output and etc. > > http://api.rubyonrails.org/classes/ActionController/Cookies.htmlwhen i try to call cookies[:name] in my rhtml file i get undefined method for cookies. -- Posted via http://www.ruby-forum.com/.
i get a undefined method/variable when i try use cookies in my rails rhtml files? any idea? <%= cookies[:user] %> gives an error -- Posted via http://www.ruby-forum.com/.
On 6/27/06, raj kapila <rkapila@uwo.ca> wrote:> i get a undefined method/variable when i try use cookies in my rails > rhtml files? any idea? > > <%= cookies[:user] %> > > gives an error"cookies" is a controller method. Call it in your controller and set a variable for your view to use. Also, given your example, I think you''re heading down the road to a disaster. If you''re really storing a user id in a cookie, that''s kind-of odd. If you''re actually trusting this value, that''s going to be big trouble when a user decides to change the user id in his cookie and send it to your server. -- James
>> <%= cookies[:user] %> >> >> gives an error > > "cookies" is a controller method. Call it in your controller and set > a variable for your view to use. > > Also, given your example, I think you''re heading down the road to a > disaster. If you''re really storing a user id in a cookie, that''s > kind-of odd. If you''re actually trusting this value, that''s going to > be big trouble when a user decides to change the user id in his cookie > and send it to your server. > > -- Jamesso should i just rails sessions? -- Posted via http://www.ruby-forum.com/.
On 6/27/06, raj kapila <rkapila@uwo.ca> wrote:> > "cookies" is a controller method. Call it in your controller and set > > a variable for your view to use. > > > > Also, given your example, I think you''re heading down the road to a > > disaster. If you''re really storing a user id in a cookie, that''s > > kind-of odd. If you''re actually trusting this value, that''s going to > > be big trouble when a user decides to change the user id in his cookie > > and send it to your server. > > so should i just rails sessions?Yes. For one thing, the hard work has already been done for you. There are also a number of 3rd party extensions / plugins for managing authentication / authorization depending on the level of complexity that you need. If you haven''t already, you should most definitely read "Agile Web Development With Rails" (2nd edition beta if you have a choice). The book "Rails Recipes" has a good section on creating your own login / role system from scratch (recipes 31 + 32). -- James
Raj Kapila wrote:> James Ludlow wrote: >> On 6/26/06, raj kapila <rkapila-OnllAtm1sHQ@public.gmane.org> wrote: >>> could someone help me with cookies. >>> >>> I need help setting them and using them for output and etc. >> >> http://api.rubyonrails.org/classes/ActionController/Cookies.html > > when i try to call cookies[:name] in my rhtml file i get undefined > method for cookies.Cookies are only controller methods. Set an instance variable in your controller for use in your rhtml view. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
why not use session? -- 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?hl=en -~----------~----~----~----~------~----~------~--~---