0

when destroying one element from my database, the index view

      <% for activity in @activities %>

      <%= activity.text %>  by  <%= current_user.name %> on <%= Time.current%> <br/>


    <% end %>

no longer find the <%=trackable.element_name%> from config/pba.yml

    activity:
        element:
              create: '  <%=trackable.element_name%> has been created '
              update: '  <%=trackable.element_name%> has been edited '
             destroy: '  <%=trackable.element_name%> has been removed '

and display something like:

    element1 has been edited by me on 2012-08-19 16:20:44 UTC
  Template not defined by me on 2012-08-19 16:20:44 UTC 

"template not defined" being the element i have just deleted....

i would like to store the element name and the action that has been taken though...!?

4

2 回答 2

3

I released a new version of the public_activity gem which allows you to create views for every activity you display, so you can simply check if trackable is still in the database and act accordingly.

Upgrade your gem to https://github.com/pokonski/public_activity#upgrading-to-04 and check out my example application which does exactly that:

https://github.com/pokonski/activity_blog/blob/master/app/views/public_activity/post/_update.slim#L4

where link_to_trackable is just a helper checking if trackable exists: https://github.com/pokonski/activity_blog/blob/master/app/helpers/application_helper.rb#L34

于 2012-11-08T10:08:32.473 回答
1

That's because it can't find the original element you deleted. Have you thought of using soft-delete? The record remains in the database.

于 2012-09-23T20:00:01.427 回答