Skip to content

Instantly share code, notes, and snippets.

@ovargas27
Created September 27, 2010 16:17
Show Gist options
  • Save ovargas27/599286 to your computer and use it in GitHub Desktop.
Save ovargas27/599286 to your computer and use it in GitHub Desktop.
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)
);
@bizoru
Copy link

bizoru commented Sep 27, 2010

Is that Ruby Language?

@ovargas27
Copy link
Author

yes, it is
Is an inheritance in Ruby on Rails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment