Created
July 12, 2012 16:39
-
-
Save petrokoriakin/3099215 to your computer and use it in GitHub Desktop.
Passing current_user into the model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Aplication Controller | |
before_filter :define_current_user | |
def define_current_user | |
User.current_user = current_user | |
end | |
#User.rb (model) | |
class User | |
class << self | |
attr_accessor :current_user | |
end | |
end | |
#Account.rb (target model) | |
fires :updated, | |
on: :update, | |
actor: Proc.new { User.current_user }, | |
data: :changes, | |
if: Proc.new { | acc | !acc.changes.blank? && acc.changes[:cancellation_code].blank? } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment