Created
March 31, 2015 22:13
-
-
Save tiagopog/a37db867d224040dcfd1 to your computer and use it in GitHub Desktop.
STI example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vehicle < ActiveRecord::Base | |
attr_accessor :direction | |
validates :name, presence: true | |
end | |
class Car < Vehicle | |
def turn_wheel(direction) | |
@direction = direction | |
puts "wheel was turned to the #{direction}" | |
end | |
end | |
class Bike < Vehicle | |
def turn_handlebar(direction) | |
@direction = direction | |
puts "handlebar was turned to the #{direction}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment