From d2da04d5b4d965647072d96dbd3eb721801a4897 Mon Sep 17 00:00:00 2001 From: github username Date: Mon, 25 Jan 2021 14:00:48 -0600 Subject: [PATCH 1/5] made employee, project and skill class files --- lib/Employee.rb | 3 +++ lib/Project.rb | 3 +++ lib/Skill.rb | 3 +++ 3 files changed, 9 insertions(+) create mode 100644 lib/Employee.rb create mode 100644 lib/Project.rb create mode 100644 lib/Skill.rb diff --git a/lib/Employee.rb b/lib/Employee.rb new file mode 100644 index 00000000..62cab516 --- /dev/null +++ b/lib/Employee.rb @@ -0,0 +1,3 @@ +class Employee + +end diff --git a/lib/Project.rb b/lib/Project.rb new file mode 100644 index 00000000..cc885fe8 --- /dev/null +++ b/lib/Project.rb @@ -0,0 +1,3 @@ +class Project + +end \ No newline at end of file diff --git a/lib/Skill.rb b/lib/Skill.rb new file mode 100644 index 00000000..8b6066fe --- /dev/null +++ b/lib/Skill.rb @@ -0,0 +1,3 @@ +class Skill + +end \ No newline at end of file From c694da953691acfde4fa299996d94a436d72298a Mon Sep 17 00:00:00 2001 From: Khalin Redding Date: Mon, 25 Jan 2021 17:58:41 -0500 Subject: [PATCH 2/5] Basic class files --- lib/Employee.rb | 53 +++++++++++++++++++++++++++++++++++++++++++ lib/EmployeeSkills.rb | 32 ++++++++++++++++++++++++++ lib/Employeer.rb | 17 ++++++++++++++ lib/Project.rb | 17 +++++++++++++- lib/ProjectSkills.rb | 17 ++++++++++++++ lib/Skill.rb | 13 +++++++++++ lib/Temp_data_load.rb | 4 ++++ 7 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 lib/EmployeeSkills.rb create mode 100644 lib/Employeer.rb create mode 100644 lib/ProjectSkills.rb create mode 100644 lib/Temp_data_load.rb diff --git a/lib/Employee.rb b/lib/Employee.rb index 62cab516..9258c5f3 100644 --- a/lib/Employee.rb +++ b/lib/Employee.rb @@ -1,3 +1,56 @@ class Employee + #name, id, project_id + attr_accessor :id,:name,:emploeer,:project_id + @@all = [] + + def initalize (id=nil,name, employeer, project_id=Nil) + @id=id + @name = name + @project_id=project_id + @employeer = employeer + @@all << self + end + + + def self.all + @@all + end + + #basic save method to add new record into database using sql. Note requires .update method + # def save + # if self.id + # self.update + # else + # sql = <<-SQL + # INSERT INTO employee (name, project_id, employeer_id) + # VALUES (?, ?, ?) + # SQL + + # DB[:conn].execute(sql, self.name, self.project_id,employeer_id) + # @id = DB[:conn].execute("SELECT last_insert_rowid() FROM songs")[0][0] + # end + # end + + # #create new instance method + # def self.create(name, employeer, project_id=Nil) + # employee = Employee.new(name, employeer.id) + # employee.save + # employee + # end + + # def self.find_by_id(id) + # sql = "SELECT * FROM employee WHERE id = ?" + # result = DB[:conn].execute(sql, id)[0] + # Employee.new(result[0], result[1], result[2]) + # end + + # def update + # sql = "UPDATE employee SET name = ?, employeer_id = ?, project_id, WHERE id = ?" + # DB[:conn].execute(sql, self.name, self.employeer_id, self.project_id self.id) + # end + + + + end diff --git a/lib/EmployeeSkills.rb b/lib/EmployeeSkills.rb new file mode 100644 index 00000000..24ed8684 --- /dev/null +++ b/lib/EmployeeSkills.rb @@ -0,0 +1,32 @@ +class EmployeeSkills + attr_accessor :id, :employee_id, :skill_id + @@all =[] + +def initalize(id=nil, employee_id, skill_id) + @id = id + @employee_id = employee_id + @skill_id = skill_id + @@all << self +end + +def self.all + @@all +end + + + + + + + + + + + + + + + + + +end \ No newline at end of file diff --git a/lib/Employeer.rb b/lib/Employeer.rb new file mode 100644 index 00000000..9694cdb7 --- /dev/null +++ b/lib/Employeer.rb @@ -0,0 +1,17 @@ +class Employeer + attr_accessor :id, :name + + @@all = [] + + def initalize (id=nil,name) + @id=id + @name = name + @@all << self + end + + + def self.all + @@all + end + +end \ No newline at end of file diff --git a/lib/Project.rb b/lib/Project.rb index cc885fe8..eb7a3b41 100644 --- a/lib/Project.rb +++ b/lib/Project.rb @@ -1,3 +1,18 @@ class Project + #name, id + attr_accessor :id,project + @@all = [] -end \ No newline at end of file + def initalize(id=nil,project) + @id=id + @project = project + @@all << self + end + + + + def self.all + @@all + end + +end diff --git a/lib/ProjectSkills.rb b/lib/ProjectSkills.rb new file mode 100644 index 00000000..c6a6bdab --- /dev/null +++ b/lib/ProjectSkills.rb @@ -0,0 +1,17 @@ +class ProjectSkills + attr_accessor :id, :project_id, :skill_id + + @@all=[] + + def initalize(id=nil,project_id,skill_id) + @id=id + @project_id=project_id + @skill_id=skill_id + @@all< Date: Tue, 26 Jan 2021 11:14:57 -0500 Subject: [PATCH 3/5] First running file. --- Gemfile | 2 ++ Gemfile.lock | 72 ++++++++++++++++++++++--------------------- bin/run.rb | 3 ++ config/environment.rb | 1 + lib/Employee.rb | 10 +++--- lib/Project.rb | 2 +- lib/Temp_data_load.rb | 6 ++-- 7 files changed, 51 insertions(+), 45 deletions(-) diff --git a/Gemfile b/Gemfile index c004f4ca..91bb17b3 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,5 @@ gem "sinatra-activerecord" gem "sqlite3" gem "pry" gem "require_all" +gem "rake" +gem "activerecord" diff --git a/Gemfile.lock b/Gemfile.lock index 9589226d..d074a107 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,56 +1,58 @@ GEM remote: https://rubygems.org/ specs: - activemodel (6.0.3.1) - activesupport (= 6.0.3.1) - activerecord (6.0.3.1) - activemodel (= 6.0.3.1) - activesupport (= 6.0.3.1) - activesupport (6.0.3.1) + activemodel (6.1.1) + activesupport (= 6.1.1) + activerecord (6.1.1) + activemodel (= 6.1.1) + activesupport (= 6.1.1) + activesupport (6.1.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) - coderay (1.1.1) - concurrent-ruby (1.1.6) - i18n (1.8.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + coderay (1.1.3) + concurrent-ruby (1.1.8) + i18n (1.8.7) concurrent-ruby (~> 1.0) - method_source (0.8.2) - minitest (5.14.1) - mustermann (1.0.3) - pry (0.10.4) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) + method_source (1.0.0) + minitest (5.14.3) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) rack (2.2.3) - rack-protection (2.0.7) + rack-protection (2.1.0) rack - require_all (1.3.3) - sinatra (2.0.7) + rake (13.0.3) + require_all (3.0.0) + ruby2_keywords (0.0.4) + sinatra (2.1.0) mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.7) + rack (~> 2.2) + rack-protection (= 2.1.0) tilt (~> 2.0) - sinatra-activerecord (2.0.12) - activerecord (>= 3.2) + sinatra-activerecord (2.0.22) + activerecord (>= 4.1) sinatra (>= 1.0) - slop (3.6.0) - sqlite3 (1.3.13) - thread_safe (0.3.6) + sqlite3 (1.4.2) tilt (2.0.10) - tzinfo (1.2.7) - thread_safe (~> 0.1) - zeitwerk (2.3.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + zeitwerk (2.4.2) PLATFORMS - ruby + x86_64-darwin-20 DEPENDENCIES + activerecord pry + rake require_all sinatra-activerecord sqlite3 BUNDLED WITH - 1.14.6 + 2.2.6 diff --git a/bin/run.rb b/bin/run.rb index cf08c338..c725e713 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -2,4 +2,7 @@ +binding.pry puts "HELLO WORLD" + + diff --git a/config/environment.rb b/config/environment.rb index 4dbe13e5..e66361aa 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -3,3 +3,4 @@ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') require_all 'lib' + diff --git a/lib/Employee.rb b/lib/Employee.rb index 9258c5f3..0d0586c5 100644 --- a/lib/Employee.rb +++ b/lib/Employee.rb @@ -1,12 +1,12 @@ class Employee #name, id, project_id - attr_accessor :id,:name,:emploeer,:project_id + attr_accessor :id, :name, :employeer, :project_id @@all = [] - def initalize (id=nil,name, employeer, project_id=Nil) + def initalize(id = nil, name, employeer) #, project_id = nil) @id=id @name = name - @project_id=project_id + # @project_id = project_id @employeer = employeer @@all << self end @@ -50,7 +50,5 @@ def self.all # end - - - end + diff --git a/lib/Project.rb b/lib/Project.rb index eb7a3b41..f75f5918 100644 --- a/lib/Project.rb +++ b/lib/Project.rb @@ -1,6 +1,6 @@ class Project #name, id - attr_accessor :id,project + attr_accessor :id, :project @@all = [] def initalize(id=nil,project) diff --git a/lib/Temp_data_load.rb b/lib/Temp_data_load.rb index e4a59f9f..83f64111 100644 --- a/lib/Temp_data_load.rb +++ b/lib/Temp_data_load.rb @@ -1,4 +1,4 @@ -employee1 = Employee.new("Bob") -employee2 = Employee.new("Jim") +# employee1 = Employee.new("Bob") +# employee2 = Employee.new("Jim") -project1 = Project.new("Build Ruby App") +# project1 = Project.new("Build Ruby App") From 9090dc3bee9eb2c9d15d7040582bd4cb828ee52f Mon Sep 17 00:00:00 2001 From: github username Date: Tue, 26 Jan 2021 11:27:55 -0600 Subject: [PATCH 4/5] db structure built using migrations --- Rakefile | 3 ++ config/environment.rb | 2 + db/migrate/01_create_employees_table.rb | 9 ++++ db/migrate/02_create_skills_table.rb | 7 +++ db/migrate/03_create_projects_table.rb | 7 +++ db/migrate/04_create_projectskills_table.rb | 9 ++++ db/migrate/05_create_employeeskills_table.rb | 9 ++++ db/migrate/06_create_employers_table.rb | 7 +++ db/schema.rb | 45 ++++++++++++++++++++ 9 files changed, 98 insertions(+) create mode 100644 db/migrate/01_create_employees_table.rb create mode 100644 db/migrate/02_create_skills_table.rb create mode 100644 db/migrate/03_create_projects_table.rb create mode 100644 db/migrate/04_create_projectskills_table.rb create mode 100644 db/migrate/05_create_employeeskills_table.rb create mode 100644 db/migrate/06_create_employers_table.rb create mode 100644 db/schema.rb diff --git a/Rakefile b/Rakefile index 508ef20e..6f1eb5df 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,9 @@ require_relative 'config/environment' require 'sinatra/activerecord/rake' +#DatabaseTasks.db_dir = 'db' +#DatabaseTasks.migrations_paths = ['db/migrate'] + desc 'starts a console' task :console do ActiveRecord::Base.logger = Logger.new(STDOUT) diff --git a/config/environment.rb b/config/environment.rb index e66361aa..e5083671 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -4,3 +4,5 @@ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') require_all 'lib' + + diff --git a/db/migrate/01_create_employees_table.rb b/db/migrate/01_create_employees_table.rb new file mode 100644 index 00000000..092da485 --- /dev/null +++ b/db/migrate/01_create_employees_table.rb @@ -0,0 +1,9 @@ +class CreateEmployeesTable < ActiveRecord::Migration[5.1] + def change + create_table :employees do |t| + t.string :name + t.integer :employer_id + t.integer :project_id + end + end +end diff --git a/db/migrate/02_create_skills_table.rb b/db/migrate/02_create_skills_table.rb new file mode 100644 index 00000000..7d22972b --- /dev/null +++ b/db/migrate/02_create_skills_table.rb @@ -0,0 +1,7 @@ +class CreateSkillsTable < ActiveRecord::Migration[5.1] + def change + create_table :skills do |t| + t.string :skill_name + end + end +end diff --git a/db/migrate/03_create_projects_table.rb b/db/migrate/03_create_projects_table.rb new file mode 100644 index 00000000..62e6de91 --- /dev/null +++ b/db/migrate/03_create_projects_table.rb @@ -0,0 +1,7 @@ +class CreateProjectsTable < ActiveRecord::Migration[5.1] + def change + create_table :projects do |t| + t.string :name + end + end +end diff --git a/db/migrate/04_create_projectskills_table.rb b/db/migrate/04_create_projectskills_table.rb new file mode 100644 index 00000000..67b12923 --- /dev/null +++ b/db/migrate/04_create_projectskills_table.rb @@ -0,0 +1,9 @@ +class CreateProjectskillsTable < ActiveRecord::Migration[5.1] + def change + create_table :projectskills do |t| + t.integer :project_id + t.integer :skill_id + t.integer :competency_requirement + end + end +end diff --git a/db/migrate/05_create_employeeskills_table.rb b/db/migrate/05_create_employeeskills_table.rb new file mode 100644 index 00000000..5b09d993 --- /dev/null +++ b/db/migrate/05_create_employeeskills_table.rb @@ -0,0 +1,9 @@ +class CreateEmployeeskillsTable < ActiveRecord::Migration[5.1] + def change + create_table :employeeskills do |t| + t.integer :employee_id + t.integer :skill_id + t.integer :competency + end + end +end diff --git a/db/migrate/06_create_employers_table.rb b/db/migrate/06_create_employers_table.rb new file mode 100644 index 00000000..8a348459 --- /dev/null +++ b/db/migrate/06_create_employers_table.rb @@ -0,0 +1,7 @@ +class CreateEmployersTable < ActiveRecord::Migration[5.1] + def change + create_table :employers do |t| + t.string :name + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 00000000..759fb723 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,45 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 6) do + + create_table "employees", force: :cascade do |t| + t.string "name" + t.integer "employer_id" + t.integer "project_id" + end + + create_table "employeeskills", force: :cascade do |t| + t.integer "employee_id" + t.integer "skill_id" + t.integer "competency" + end + + create_table "employers", force: :cascade do |t| + t.string "name" + end + + create_table "projects", force: :cascade do |t| + t.string "name" + end + + create_table "projectskills", force: :cascade do |t| + t.integer "project_id" + t.integer "skill_id" + t.integer "competency_requirement" + end + + create_table "skills", force: :cascade do |t| + t.string "skill_name" + end + +end From 8ea1a2afb5f30567806644e3569f6c35e4917195 Mon Sep 17 00:00:00 2001 From: Khalin Redding Date: Wed, 27 Jan 2021 12:47:40 -0500 Subject: [PATCH 5/5] Database at 80%. --- db/migrate/01_create_employees_table.rb | 4 +- db/migrate/02_create_skills_table.rb | 2 +- db/migrate/04_create_projectskills_table.rb | 4 +- db/migrate/05_create_employeeskills_table.rb | 4 +- db/migrate/07_create_employee_projects.rb | 9 ++++ db/schema.rb | 10 +++- db/seeds.rb | 0 lib/Employee.rb | 54 +++++++++++++------- lib/EmployeeProjects.rb | 7 +++ lib/EmployeeSkills.rb | 30 ++++++----- lib/Employeer.rb | 17 ------ lib/Employer.rb | 24 +++++++++ lib/Project.rb | 40 ++++++++++----- lib/ProjectSkills.rb | 32 +++++++----- lib/Skill.rb | 38 ++++++++------ 15 files changed, 176 insertions(+), 99 deletions(-) create mode 100644 db/migrate/07_create_employee_projects.rb create mode 100644 db/seeds.rb create mode 100644 lib/EmployeeProjects.rb delete mode 100644 lib/Employeer.rb create mode 100644 lib/Employer.rb diff --git a/db/migrate/01_create_employees_table.rb b/db/migrate/01_create_employees_table.rb index 092da485..3cb861f0 100644 --- a/db/migrate/01_create_employees_table.rb +++ b/db/migrate/01_create_employees_table.rb @@ -2,8 +2,8 @@ class CreateEmployeesTable < ActiveRecord::Migration[5.1] def change create_table :employees do |t| t.string :name - t.integer :employer_id - t.integer :project_id + t.integer :employer_id, :foreign_key => true + t.integer :project_id, :foreign_key => true end end end diff --git a/db/migrate/02_create_skills_table.rb b/db/migrate/02_create_skills_table.rb index 7d22972b..ae87f73d 100644 --- a/db/migrate/02_create_skills_table.rb +++ b/db/migrate/02_create_skills_table.rb @@ -1,7 +1,7 @@ class CreateSkillsTable < ActiveRecord::Migration[5.1] def change create_table :skills do |t| - t.string :skill_name + t.string :name end end end diff --git a/db/migrate/04_create_projectskills_table.rb b/db/migrate/04_create_projectskills_table.rb index 67b12923..d280383f 100644 --- a/db/migrate/04_create_projectskills_table.rb +++ b/db/migrate/04_create_projectskills_table.rb @@ -1,8 +1,8 @@ class CreateProjectskillsTable < ActiveRecord::Migration[5.1] def change create_table :projectskills do |t| - t.integer :project_id - t.integer :skill_id + t.integer :project_id, :foreign_key => true + t.integer :skill_id, :foreign_key => true t.integer :competency_requirement end end diff --git a/db/migrate/05_create_employeeskills_table.rb b/db/migrate/05_create_employeeskills_table.rb index 5b09d993..770f29d3 100644 --- a/db/migrate/05_create_employeeskills_table.rb +++ b/db/migrate/05_create_employeeskills_table.rb @@ -1,8 +1,8 @@ class CreateEmployeeskillsTable < ActiveRecord::Migration[5.1] def change create_table :employeeskills do |t| - t.integer :employee_id - t.integer :skill_id + t.integer :employee_id, :foreign_key => true + t.integer :skill_id, :foreign_key => true t.integer :competency end end diff --git a/db/migrate/07_create_employee_projects.rb b/db/migrate/07_create_employee_projects.rb new file mode 100644 index 00000000..f97f9c40 --- /dev/null +++ b/db/migrate/07_create_employee_projects.rb @@ -0,0 +1,9 @@ +class CreateEmployeeProjects < ActiveRecord::Migration[6.1] + def change + create_table :employee_projects do |t| + t.integer :employee_id, :foreign_key => true + t.integer :project_id, :foreign_key => true + t.string :status + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 759fb723..de0b91be 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,13 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 6) do +ActiveRecord::Schema.define(version: 7) do + + create_table "employee_projects", force: :cascade do |t| + t.integer "employee_id" + t.integer "project_id" + t.string "status" + end create_table "employees", force: :cascade do |t| t.string "name" @@ -39,7 +45,7 @@ end create_table "skills", force: :cascade do |t| - t.string "skill_name" + t.string "name" end end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 00000000..e69de29b diff --git a/lib/Employee.rb b/lib/Employee.rb index 0d0586c5..cc310cf2 100644 --- a/lib/Employee.rb +++ b/lib/Employee.rb @@ -1,20 +1,42 @@ -class Employee - #name, id, project_id - attr_accessor :id, :name, :employeer, :project_id - @@all = [] +class Employee < ActiveRecord::Base - def initalize(id = nil, name, employeer) #, project_id = nil) - @id=id - @name = name - # @project_id = project_id - @employeer = employeer - @@all << self - end + belongs_to :employer + belongs_to :project + has_many :skills + - def self.all - @@all - end + + + + + + + + + + + + + +end + + # #name, id, project_id + # attr_accessor :id, :name, :employeer, :project_id + # @@all = [] + + # def initalize(id = nil, name, employeer)#, project_id = nil) + # @id=id + # @name = name + # @employeer = employeer + # #@project_id = project_id + # @@all << self + # end + + + # def self.all + # @@all + # end #basic save method to add new record into database using sql. Note requires .update method # def save @@ -48,7 +70,3 @@ def self.all # sql = "UPDATE employee SET name = ?, employeer_id = ?, project_id, WHERE id = ?" # DB[:conn].execute(sql, self.name, self.employeer_id, self.project_id self.id) # end - - -end - diff --git a/lib/EmployeeProjects.rb b/lib/EmployeeProjects.rb new file mode 100644 index 00000000..bf23a53b --- /dev/null +++ b/lib/EmployeeProjects.rb @@ -0,0 +1,7 @@ +class EmployeeProjects < ActiveRecord::Base + + + + + +end \ No newline at end of file diff --git a/lib/EmployeeSkills.rb b/lib/EmployeeSkills.rb index 24ed8684..8b1b277c 100644 --- a/lib/EmployeeSkills.rb +++ b/lib/EmployeeSkills.rb @@ -1,17 +1,7 @@ -class EmployeeSkills - attr_accessor :id, :employee_id, :skill_id - @@all =[] - -def initalize(id=nil, employee_id, skill_id) - @id = id - @employee_id = employee_id - @skill_id = skill_id - @@all << self -end +class EmployeeSkills < ActiveRecord::Base -def self.all - @@all -end + belongs_to :skills + belongs_to :employees @@ -27,6 +17,18 @@ def self.all +end + +# attr_accessor :id, :employee_id, :skill_id +# @@all =[] +# def initalize(id=nil, employee_id, skill_id) +# @id = id +# @employee_id = employee_id +# @skill_id = skill_id +# @@all << self +# end -end \ No newline at end of file +# def self.all +# @@all +# end diff --git a/lib/Employeer.rb b/lib/Employeer.rb deleted file mode 100644 index 9694cdb7..00000000 --- a/lib/Employeer.rb +++ /dev/null @@ -1,17 +0,0 @@ -class Employeer - attr_accessor :id, :name - - @@all = [] - - def initalize (id=nil,name) - @id=id - @name = name - @@all << self - end - - - def self.all - @@all - end - -end \ No newline at end of file diff --git a/lib/Employer.rb b/lib/Employer.rb new file mode 100644 index 00000000..9774578c --- /dev/null +++ b/lib/Employer.rb @@ -0,0 +1,24 @@ +class Employer < ActiveRecord::Base + + has_many :employees + + + +end + + + + # attr_accessor :id, :name + + # @@all = [] + + # def initalize (id=nil,name) + # @id=id + # @name = name + # @@all << self + # end + + + # def self.all + # @@all + # end \ No newline at end of file diff --git a/lib/Project.rb b/lib/Project.rb index f75f5918..d218d033 100644 --- a/lib/Project.rb +++ b/lib/Project.rb @@ -1,18 +1,32 @@ -class Project - #name, id - attr_accessor :id, :project - @@all = [] +class Project < ActiveRecord::Base + + belongs_to :employers + has_many :employees + + + + + + + + - def initalize(id=nil,project) - @id=id - @project = project - @@all << self - end - - def self.all - @@all - end end + # #name, id + # attr_accessor :id, :project + # @@all = [] + + # def initalize(id=nil,project) + # @id=id + # @project = project + # @@all << self + # end + + + + # def self.all + # @@all + # end \ No newline at end of file diff --git a/lib/ProjectSkills.rb b/lib/ProjectSkills.rb index c6a6bdab..5ae4eac3 100644 --- a/lib/ProjectSkills.rb +++ b/lib/ProjectSkills.rb @@ -1,17 +1,23 @@ -class ProjectSkills - attr_accessor :id, :project_id, :skill_id +class ProjectSkills < ActiveRecord::Base - @@all=[] + belongs_to :skills + belongs_to :projects - def initalize(id=nil,project_id,skill_id) - @id=id - @project_id=project_id - @skill_id=skill_id - @@all<