Table name: configurations
id :integer not null, primary key settings :text type :string(255) created_at :datetime updated_at :datetime university_id :integer
To load sub configurations
# File app/models/configuration.rb, line 52 def self.load_sub_configurations configurations = [] descendants.each do |d| configurations << d.first_or_initialize end configurations end
To get profile steps for universities
# File app/models/configuration.rb, line 61 def self.profile_steps_for_universities if User.current and User.current.type == 'Student' [ 'courses_studying', 'select-type' ] else [ 'courses_studying', 'courses-tutoring', 'my-rate' ] end end
To get the store attributes
# File app/models/configuration.rb, line 18 def self.store_attributes(*args) if self.table_exists? options = args.pop if args.last.is_a? Hash store :settings, accessors: args unless options.blank? options[:boolean_fields].each do |field_name| define_method "#{field_name}?" do self.send(field_name) end self.before_validation {|configuration| configuration.send("#{field_name}=".to_sym, configuration.send(field_name).try(:to_bool)) true } end end args.each do |field_name| self.singleton_class.send :define_method, field_name do first.try(field_name) end self.singleton_class.send :define_method, "#{field_name}?".to_sym do self.send(field_name).present? end end end end
To get the subclass
# File app/models/configuration.rb, line 47 def self.sub_configurations descendants end