Hi Robb,

I ended up writing a very crude solution and then stopped that to
revamp later. I DO believe you are on the right track though. The only
part that I havent figured out though is writing neat code for the
actual message or sentence the user will read. Like,

You edited the task - Change tyres on car
Robb completed the task - Change tyres on car

These sentences will vary depending on the action, object and user. To
generate them using a function is, at least in my case, not possible.
Im hard coding them right now.

Read up on polymorphic relationships. Its basically what you have
suggested above, only, Rails makes it a bit easier.
http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html

Good luck!
And DO update this post with your efforts.

On Aug 13, 9:13 am, Robb <robb.shec...@gmail.com> wrote:
> Can anyone tell me if I'm on the right track?  I think this isn't
> quite right:
>
> I want to implement an activity log for users.  It'll show them a list
> of the objects they've viewed.  I have, of course, many types of
> objects in the Rails program.
>
> I've thought that I'd make a log_entries table which would have
> a :viewed_object_id and :viewed_object_type.
>
> I'd then like to be able to retrieve all of the viewed objects,
> something along the lines:
>
>    user.log_entries.map{|e| e.viewed_object}
>
> And I could display links to them, like:
>
>    link_to obj.to_s, obj
>
> ...so, this is a form of STI, but I'm not sure if Rails handles this
> kind.  I'm also not sure if this is the best way to implement this
> kind of feature.
>
> Thanks for any feedback!
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to