I still receive this message

undefined method `user_id

Am I going about this wrong or is there another way?

When I hard coded a value to be returned in the user_id block it
worked, but I don't know what I need to do to pass the current user
ID.


On Jan 28, 8:31 pm, Jim Ruther Nill <[email protected]> wrote:
> Try this
>
> in your controller
>
> my_item = MyItem.new
> my_item.user_id = current_user.id
>
> In your model
>
> attr_accessor :user_id
> acts_as_activity :user
>
> On Fri, Jan 29, 2010 at 11:26 AM, Chris <[email protected]> wrote:
> > This is related to adding the acts_as_activity to an object which does
> > not have a direct user relationship.
>
> > I added this to the model
>
> >  attr_accessor :user
>
> > def user_id
> >   �...@user = User.find(current_user)
> >    return @user.id
> >  end
>
> > To avoid the undefined method I received when I add an new object.
> > When I hard code a value (return 10) everything works fine so I need
> > to have the current user ID available but with the above code I
> > receive this error.
>
> > undefined local variable or method `current_user'
>
> > Maybe I am going about this the wrong way?
>
> > On Jan 28, 8:10 pm, [email protected] wrote:
> > > Add the user as a attr_accessor and set it in the model?
> > > Sent via BlackBerry by AT&T
>
> > > -----Original Message-----
> > > From: Chris <[email protected]>
> > > Date: Thu, 28 Jan 2010 19:08:58
> > > To: CommunityEngine<[email protected]>
> > > Subject: [CommunityEngine] Accessing Current User
>
> > > I need to access the current_user to pass the user ID of the current
> > > use to the activity tracking for a model not associated with a user.
> > > Does anyone know what I need to do to access the current user in a
> > > model or controller in my main app since the authentication is handled
> > > in the CE lib.
>
> > > Not sure where to go with this one.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "CommunityEngine" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > [email protected]<communityengine%[email protected]>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/communityengine?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "CommunityEngine" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<communityengine%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/communityengine?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"CommunityEngine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/communityengine?hl=en.

Reply via email to