开发者

way of implementing links in rails

I have a project I a开发者_C百科m doing in rails. I want to implement this sort of links

{user} has {action} on {file} in {project}

each of the words wrapped by curly braces are entities in my system (models). how do I implement saving these changes in the project and how do I get all of the changes from the database and display them to the user?

I am using rails 2.3.8 if it matters

example of the links I need to display (image)

way of implementing links in rails


There are some plugins available to keep track of activities in models:

  • https://github.com/grosser/record_activities

  • https://github.com/linkingpaths/acts_as_scribe

  • https://github.com/face/activity_streams

I normally use acts_as_scribe, it's the simplest of them.


I would recommend acts_as_audited. It works very well. It saves all your changes on a model in the form of a hash, so using it becomes as easy as

audit = Audit.first #just for example

In your view

<%= link_to User.find(audit.user_id), user(:id => audit.user_id) %> has
<%= audit.action %>

Of course you will have to customize how your messages will finally appear. And of course its better not to use find methods in your view. I've used it here just for illustration purposes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜