GUIDE

The road ahead will be long and our climb will be steep

ActiveRecord, Class_attribute

| Comments

how to use class_attribuet:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'active_record'

class Base
  class_attribute :setting
end

class Subclass < Base
end

Base.setting = true
puts Subclass.setting # => true
Subclass.setting = false
puts Subclass.setting # => false
puts Base.setting # => true


base = Base.new
puts base.setting # => true
base.setting = false
puts Base.setting # => true
puts base.setting # => false

Comments