Module: Horde::Actions::RateMethods::ActorMethods

Extended by:
ActiveSupport::Concern
Defined in:
lib/horde/actions/rate.rb

Overview

methods for user, usually User class in your app.

Instance Method Summary collapse

Instance Method Details

#rate(target, options = {}) ⇒ Object

user rate something.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/horde/actions/rate.rb', line 27

def rate(target, options = {})
  pks  = {:actor_id => self.id, 
          :target_id => target.id,
          :target_type => target.class.name
         }
  rate = ::Horde::Rate.where(pks).first
  if rate
    rate.update_attributes(options)
  else
    params = pks.merge(options)
    rate = ::Horde::Rate.create(params)
  end

  target.run_hook(:after_rate, rate)

  rate
end