Dear Rails folks, I have a user that has_many items, and an item model that belongs_to user. In the controller for item, how do i access the current user that is logged in? it''s very easy to access the current logged in user from when in the user controller/model/view with the @user variable, but i''m not sure how to access the currently logged in user @user in the item controller MVC. Authentication was implemented using composer, the devise gem is being used. 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/P6zFavJ5QfQJ. For more options, visit https://groups.google.com/groups/opt_out.
current_user holds the current logged in user. -- Dheeraj Kumar On Saturday 5 January 2013 at 2:28 AM, Julien Estebane wrote:> Dear Rails folks, > > I have a user that has_many items, and an item model that belongs_to user. > > In the controller for item, how do i access the current user that is logged in? it''s very easy to access the current logged in user from when in the user controller/model/view with the @user variable, but i''m not sure how to access the currently logged in user @user in the item controller MVC. > > > Authentication was implemented using composer, the devise gem is being used. > > 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 (mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com (mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/P6zFavJ5QfQJ. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Thanks Dheeraj. That works! On Friday, January 4, 2013 4:05:13 PM UTC-5, Dheeraj Kumar wrote:> > current_user holds the current logged in user. > > -- > Dheeraj Kumar > > On Saturday 5 January 2013 at 2:28 AM, Julien Estebane wrote: > > Dear Rails folks, > > I have a user that has_many items, and an item model that belongs_to user. > > In the controller for item, how do i access the current user that is > logged in? it''s very easy to access the current logged in user from when in > the user controller/model/view with the @user variable, but i''m not sure > how to access the currently logged in user @user in the item controller MVC. > > > Authentication was implemented using composer, the devise gem is being > used. > > 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 rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:> > . > To unsubscribe from this group, send email to > rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/P6zFavJ5QfQJ. > For more options, visit https://groups.google.com/groups/opt_out. > > > > >-- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/xx1NOr6fnboJ. For more options, visit https://groups.google.com/groups/opt_out.