-
Notifications
You must be signed in to change notification settings - Fork 334
[How to] Set the Activity's owner to current_user by default
guyisra edited this page Dec 24, 2012
·
5 revisions
You can set up a default value for :owner
by doing this:
- Include
PublicActivity::StoreController
in yourApplicationController
like this:
class ApplicationController < ActionController::Base
include PublicActivity::StoreController
end
- Use Proc in
:owner
attribute fortracked
class method in your desired model. For example:
class Article < ActiveRecord::Base
tracked owner: Proc.new{ |controller, model| controller.current_user }
end
Note: current_user
applies to Devise, if you are using a different authentication gem or your own code, change the current_user
to a method you use.