Reputation: 129
I have a app made in rails/angular where users can add movies to their watchlist. When a user adds a movie a activity record is created through the Public Activity gem
This is my movie model (which is being tracked by the gem),
@movie = "Star Wars"
include PublicActivity::Model
tracked owner: -> (controller, model) { controller && controller.current_user }
tracked :params => {
:title => @movie
}
I found that by using this code in my movie model I can add a parameter to the activity record.
tracked :params => {
:title => @movie,
}
Now when I add a new movie (and a new activity) it adds this to the activity record,
"parameters":{"title":"Star Wars"}
Ofcourse this is hardcoded and it should be the title of the movie object. Is is possible to get the data from the movie object in the movie model?
This is the movie table,
create_table "movies", force: :cascade do |t|
t.string "title"
t.string "release_date"
t.string "image"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "movie_id"
t.string "backdrop"
end
Upvotes: 1
Views: 187
Reputation: 769
tracked :params => {
:title => :get_title
}
def get_title
title
end
Unless I am understanding your question wrong. If so, correct me please :)
Upvotes: 1