I''m using devise for authentication: In my user model I''ve do: def name "#{first_name} #{last_name}" end to have a name method. After signed in successfully I can use current_user.name. I want to overwrite name method if the user is guest. That''s the use case: The guest user signed in successfully, now its name is, for example, "guest" " guest". current_user.name is guest guest. After signed in I present a form with a name input field and a surname input field. Submitting the form I want to overwrite the name value with input fields values. So if name and surname are: "newguest" "newguest" I want current_user.name have newguest newguest. There a way to do this? Thank you. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 21 September 2012 12:50, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m using devise for authentication: > In my user model I''ve do: > > def name > "#{first_name} #{last_name}" > end > > to have a name method. > After signed in successfully I can use current_user.name. > I want to overwrite name method if the user is guest. > That''s the use case: > > The guest user signed in successfully, now its name is, for example, > "guest" " guest". > current_user.name is guest guest. > After signed in I present a form with a name input field and a surname > input field. > Submitting the form I want to overwrite the name value with input fields values. > So if name and surname are: "newguest" "newguest" I want > current_user.name have newguest newguest. > There a way to do this? > Thank you.No ideas? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Hassan Schroeder
2012-Sep-22 14:33 UTC
Re: Re: How to overwrite devise user session attributes?
On Sat, Sep 22, 2012 at 7:05 AM, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:>> The guest user signed in successfully, now its name is, for example, >> "guest" " guest". >> current_user.name is guest guest. >> After signed in I present a form with a name input field and a surname >> input field. >> Submitting the form I want to overwrite the name value with input fields values. >> So if name and surname are: "newguest" "newguest" I want >> current_user.name have newguest newguest. >> There a way to do this?Save the new "names" in session or directly in a cookie. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 22 September 2012 16:33, Hassan Schroeder <hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sat, Sep 22, 2012 at 7:05 AM, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >>> The guest user signed in successfully, now its name is, for example, >>> "guest" " guest". >>> current_user.name is guest guest. >>> After signed in I present a form with a name input field and a surname >>> input field. >>> Submitting the form I want to overwrite the name value with input fields values. >>> So if name and surname are: "newguest" "newguest" I want >>> current_user.name have newguest newguest. >>> There a way to do this? > > Save the new "names" in session or directly in a cookie.Yes I want to save in session but how can access the session? user_session hash is empty. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Hassan Schroeder
2012-Sep-22 15:32 UTC
Re: Re: How to overwrite devise user session attributes?
On Sat, Sep 22, 2012 at 8:03 AM, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes I want to save in session but how can access the session? > user_session hash is empty.session["foo"] = "bar" Of course it''s empty until you put something there :-) -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 22 September 2012 17:32, Hassan Schroeder <hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sat, Sep 22, 2012 at 8:03 AM, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Yes I want to save in session but how can access the session? >> user_session hash is empty. > > session["foo"] = "bar" > > Of course it''s empty until you put something there :-)Sorry but I don''t undestand very well. In https://github.com/plataformatec/devise is said that user_session is an helper to access the session of the successfully signed in user. So after signed in I expect to find something in user_session so that I can change some of its values. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Hassan Schroeder
2012-Sep-22 17:03 UTC
Re: Re: How to overwrite devise user session attributes?
On Sat, Sep 22, 2012 at 9:26 AM, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Sorry but I don''t undestand very well. > In https://github.com/plataformatec/devise is said that user_session > is an helper to access the session of the successfully signed in user. > So after signed in I expect to find something in user_session so that > I can change some of its values.I don''t know about devise''s "user_session" offhand, but it doesn''t really matter. You can put anything you want (within reason!) in session in your app. session["guest_first_name"] = "Bob" Whatever. Just try it. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.