Created
September 27, 2010 16:17
-
-
Save ovargas27/599286 to your computer and use it in GitHub Desktop.
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 User < ActiveRecord::Base | |
has_many :tasks | |
#common attributes and behavior for managers and workers | |
end | |
class Manager < User | |
#special manager's attributes and behavior | |
end | |
class Worker < User | |
#special worker's attributes and behavior | |
end | |
class Task < ActiveRecord::Base | |
belongs_to :manager | |
belongs_to :user | |
end | |
#Migration: create_user.rb | |
CREATE TABLE users ( | |
id INT NOT NULL AUTO_INCREMENT, | |
user VARCHAR(15) NOT NULL UNIQUE, | |
pass VARCHAR(40) NOT NULL, | |
type VARCHAR(20) NOT NULL, | |
PRIMARY KEY (id) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yes, it is
Is an inheritance in Ruby on Rails