Comments (8)
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.
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.
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.
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.
I'll implement that as soon as time allows :)
from public_activity.
Was this ever implemented?
from public_activity.
@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.
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)
- Gem requires db connection during assets precompile HOT 9
- After setting up public_activity missing render HOT 1
- How to handle activity where parameters is empty? HOT 1
- why public_activity dependency is not resolved by actionpack gem with version 6.0.4 HOT 2
- Random odd failure when PublicActivity.with_tracking used in Rails app with RSpec HOT 1
- Commits for new versions not in Github HOT 2
- Trying to return activity text such as "updated ..." in API HOT 1
- Release notes for 2.0.0 HOT 1
- Issue when tracking is triggered from within a thread HOT 3
- Custom After_Commit callback when activities are created HOT 2
- Callbacks not triggered when used in combination with activerecord-import HOT 2
- DRY Rendering activities using ViewComponent HOT 3
- Psych::DisallowedClass: Tried to load unspecified class: Symbol HOT 5
- Heroku demo site is down HOT 1
- TypeError: no implicit conversion of Symbol into Integer HOT 2
- Was :fallback accidentally left out? HOT 1
- missing keyword: :coder If no default coder is configured, a coder must be provided to `serialize`. rails 7 HOT 10
- ActiveRecord::Base.serialize signature changed when ActiveRecord >= 7.1 HOT 1
- v3 has breaking change (parameters defaults to nil) HOT 2
- Error: Tried to load unspecified class Psych::DisallowedClass of a model HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from public_activity.