Method: Client#authorized_for?

Defined in:
app/models/client.rb

#authorized_for?(options) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/models/client.rb', line 73

def authorized_for?(options)
  return true unless options.try(:[],:action)
  
  case options[:action].to_sym
    when :delete
      [Invoice, Payment, Activity].each{ |k| return false if k.count(:all, :conditions => ['client_id = ?', id] ) > 0 }

      true
    else
      true
  end
end