So maybe I am approaching this wrong, in theory I would like the
activity feed to show that someone added this item.  There is a
relationship to a parent item but if I pass that as the owner it puts
that ID into the user_id item in the activities table when it isn't
the user_id but the id of the parent object.

Maybe I need to come up with another approach and figure out a way
around this.

On Jan 28, 8:43 pm, Jim Ruther Nill <[email protected]> wrote:
> The concept behind acts_as_activity is that a model is an activity of a
> certain user with a foreign key of user_id.
> So if you instead add acts_as_activity :owner, it will ask for an owner_id.
>
> in your controller
>
> my_item = MyItem.new
> my_item.doer = current_user <http://current_user.id>
>
> In your model
>
> attr_accessor :doer
> acts_as_activity :user
>
> def user_id
>   doer.id
> end
>
> On Fri, Jan 29, 2010 at 11:37 AM, Chris <[email protected]> wrote:
> > 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]>
> > <communityengine%[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]>
> > <communityengine%[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]<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