Giter VIP home page Giter VIP logo

Comments (8)

pokonski avatar pokonski commented on September 13, 2024

Yes you can => http://rubydoc.info/gems/public_activity/0.3.2/PublicActivity/Tracked/ClassMethods:tracked

def Model < ActiveRecord::Base
  tracked :params => {:account_id => 123}
end

In your case, account_id is probably dynamic so setting a default in the model might not be perfect. I now realize docs don't give a proper example in the link I provided, only an explanation in one sentence.

from public_activity.

eicca avatar eicca commented on September 13, 2024

Hello.

Thanks for this useful gem.

I made a small addition which enables you to record the dynamic parameters of activity: https://github.com/eicca/public_activity/commit/a6ef4f0c560ea7e00d800517486dcca44b2130d6
For example:

def Comment < ActiveRecord::Base
  tracked :calling_params => { :comment_id => "id", :post_name => "post.name"  }
  belongs_to :post
  ...
end
post.name # "Hello World"
comment = post.create_comment
comment.activities.last.parameters #=> {:id => "5", :post_name => "Hello World"}

This is useful if the entries are deleted in the future.
Can you tell what you think about this?

from public_activity.

pokonski avatar pokonski commented on September 13, 2024

Not a bad idea, actually! But I'd do it by adding this ability in :params option for simplicity (support for Proc's and symbols). I'll keep this in mind when working on a new version. This should also solve the issue with accessing current_user model when using Devise and similar gems.

Something like:

def Comment < ActiveRecord::Base
  tracked :params => { :comment_id => :id, :post_name => {|trackable| trackable.post.name }
  belongs_to :post
  ...
end

Should be more future-proof.

Thanks for pointing this out :)

from public_activity.

eicca avatar eicca commented on September 13, 2024

Yes, your version is much more correct (by the way, I just do not know how to do it :) ).

Thank you for what you paid attention to it.

from public_activity.

pokonski avatar pokonski commented on September 13, 2024

I'll implement that as soon as time allows :)

from public_activity.

kevinelliott avatar kevinelliott commented on September 13, 2024

Was this ever implemented?

from public_activity.

pokonski avatar pokonski commented on September 13, 2024

@kevinelliott yes, you can now use Procs, :symbols or exact String/integer values in :parameters hash. Please read the docs: http://rubydoc.info/gems/public_activity/PublicActivity/Tracked/ClassMethods#tracked-instance_method

from public_activity.

kevinelliott avatar kevinelliott commented on September 13, 2024

Thanks, I'll give it a go.
On Jan 16, 2013, at 1:30 AM, Piotrek Okoński [email protected] wrote:

@kevinelliott yes, you can now use Procs, :symbols or exact String/integer values in :parameters hash. Please read the docs: http://rubydoc.info/gems/public_activity/PublicActivity/Tracked/ClassMethods#tracked-instance_method


Reply to this email directly or view it on GitHub.

from public_activity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.