aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/models/mass_assignment_specific.rb
blob: 1d123fa58cb148aa94da57ebf002188edfedb881 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class User
  include ActiveModel::MassAssignmentSecurity
  attr_protected :admin

  public :sanitize_for_mass_assignment
end

class SpecialUser
  include ActiveModel::MassAssignmentSecurity
  attr_accessible :name, :email, :as => :moderator

  public :sanitize_for_mass_assignment
end

class Person
  include ActiveModel::MassAssignmentSecurity
  attr_accessible :name, :email
  attr_accessible :name, :email, :admin, :as => :admin

  public :sanitize_for_mass_assignment
end

class Account
  include ActiveModel::MassAssignmentSecurity
  attr_accessible :name, :email, :as => [:default, :admin]
  attr_accessible :admin, :as => :admin

  public :sanitize_for_mass_assignment
end

class Firm
  include ActiveModel::MassAssignmentSecurity

  public :sanitize_for_mass_assignment

  def self.attributes_protected_by_default
    ["type"]
  end
end

class Task
  include ActiveModel::MassAssignmentSecurity
  attr_protected :starting

  public :sanitize_for_mass_assignment
end

class LoosePerson
  include ActiveModel::MassAssignmentSecurity
  attr_protected :credit_rating, :administrator
  attr_protected :credit_rating, :as => :admin
end

class LooseDescendant < LoosePerson
  attr_protected :phone_number
end

class LooseDescendantSecond< LoosePerson
  attr_protected :phone_number
  attr_protected :name
end

class TightPerson
  include ActiveModel::MassAssignmentSecurity
  attr_accessible :name, :address
  attr_accessible :name, :address, :admin, :as => :admin

  def self.attributes_protected_by_default
    ["mobile_number"]
  end
end

class TightDescendant < TightPerson
  attr_accessible :phone_number
  attr_accessible :super_powers, :as => :admin
end