1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/models/vegetables.rb

34 lines
491 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class Vegetable < ActiveRecord::Base
validates_presence_of :name
def self.inheritance_column
"custom_type"
end
end
class Cucumber < Vegetable
end
class Cabbage < Vegetable
end
class GreenCabbage < Cabbage
end
class KingCole < GreenCabbage
end
class RedCabbage < Cabbage
2016-08-06 13:37:57 -04:00
belongs_to :seller, class_name: "Company"
end
class YellingVegetable < Vegetable
after_initialize :format_name
def format_name
self.name = name&.upcase
end
end