Platform and Project core models
This commit is contained in:
parent
340e8697c7
commit
0218f5dfd0
|
@ -0,0 +1,19 @@
|
|||
class Platform < ActiveRecord::Base
|
||||
validate :name, :presence => true, :uniqueness => true
|
||||
validate :unixname, :presence => true, :uniqueness => true
|
||||
before_validation :generate_unixname
|
||||
validate :validate_unixname
|
||||
|
||||
has_many :projects
|
||||
has_one :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id'
|
||||
|
||||
protected
|
||||
|
||||
def generate_unixname
|
||||
#TODO: Implement unixname generation
|
||||
end
|
||||
|
||||
def validate_unixname
|
||||
#TODO: Implement unixname validation
|
||||
end
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
class Project < ActiveRecord::Base
|
||||
validate :name, :uniqueness => true, :presence => true
|
||||
validate :unixname, :uniqueness => true, :presence => true
|
||||
before_validation :generate_unixname
|
||||
validate :validate_unixname
|
||||
|
||||
belongs_to :platform
|
||||
|
||||
protected
|
||||
|
||||
def generate_unixname
|
||||
#TODO: Implement unixname generation
|
||||
end
|
||||
|
||||
def validate_unixname
|
||||
#TODO: Implement unixname validation
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
class CreatePlatforms < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :platforms do |t|
|
||||
t.string :name
|
||||
t.string :unixname
|
||||
t.integer :parent_platform_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :platforms
|
||||
end
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
class CreateProjects < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :projects do |t|
|
||||
t.string :name
|
||||
t.string :unixname
|
||||
t.integer :platform_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :projects
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Platform do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Project do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue