-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom db fields #55
Comments
Glad you like it! You are right, querying a serialized column would be a pain, so it is highly advised against doing that. In the early days of the gem I also was adding custom columns. The solution circumvents parts of the gem, but if you absolutely need it can be done like this:
PublicActivity::Activity.create key: 'spot.update', trackable: @spot, params: {...}, city_id: @spot.city_id, owner: current_user Please note that this completely ignores your defaults set in Spot model (inside the #tracked method), so you are on your own with setting Note to self: this might be a good idea to allow passing custom column values to #create_activity. EDIT: Included |
Lately I see a lot of people asking question about how to use this gem. |
@stas good idea. |
Thank you for your help @pokonski , work's great! :) |
I will implement this and inform you on the progress here. |
This works well, I think, but two things are needed: migration and whitelist addition for the attribute. |
This is definitely coming to 1.0 |
After searching for a while, this worked for me when I wanted to add a custom field which is a reference to a model with a uuid as the id. |
Hello,
first of all - thank you for creating this amazing gem, you saved me a lot of work and i really appreciate it :)
Anyway, i have a small problem. I'm creating an app - let's call it an online restaurants catalogue. There are two models:
Spot
andCity
What i need to do is to be able to display an activity stream on single Spot's profile but i also want to display activity streams on City's profiles (activity streams of spots which belongs to this city, not city's streams itself). Offcourse i can use
params
parameter forcreate_activity
method when trackingSpot
activity but it would be probably not quite optimal to query City's activity using SQLLIKE
statements (they are quite heavy, right?). I decided it would better to add a column toactivities
table in which i will keep the city ID.Is there any way to use custom table columns without hacking a
public_activity
source code ? Unfortunatelly, this code won't work:Thank you for any help!
The text was updated successfully, but these errors were encountered: