From fa177fd3fc9c93ba4f82fd0e7b669026a3f9b441 Mon Sep 17 00:00:00 2001 From: Sylvia Mumbi Date: Mon, 14 Aug 2023 05:42:17 +0300 Subject: [PATCH] Done lab --- .results.json | 1 + Gemfile.lock | 3 +++ app/models/student.rb | 5 +++++ db/migrate/20230814023245_create_students.rb | 11 ++++++++++ db/schema.rb | 23 ++++++++++++++++++++ db/seeds.rb | 2 ++ 6 files changed, 45 insertions(+) create mode 100644 .results.json create mode 100644 app/models/student.rb create mode 100644 db/migrate/20230814023245_create_students.rb create mode 100644 db/schema.rb diff --git a/.results.json b/.results.json new file mode 100644 index 000000000..6709b24da --- /dev/null +++ b/.results.json @@ -0,0 +1 @@ +{"version":"3.10.1","examples":[{"id":"./spec/models/student_spec.rb[1:1:1]","description":"returns the student's first name","full_description":"Student#first_name returns the student's first name","status":"passed","file_path":"./spec/models/student_spec.rb","line_number":7,"run_time":0.0120133,"pending_message":null},{"id":"./spec/models/student_spec.rb[1:2:1]","description":"returns the student's last name","full_description":"Student#last_name returns the student's last name","status":"passed","file_path":"./spec/models/student_spec.rb","line_number":13,"run_time":0.0019273,"pending_message":null},{"id":"./spec/models/student_spec.rb[1:3:1]","description":"returns the student's grade","full_description":"Student#grade returns the student's grade","status":"passed","file_path":"./spec/models/student_spec.rb","line_number":19,"run_time":0.0024689,"pending_message":null},{"id":"./spec/models/student_spec.rb[1:4:1]","description":"has a #to_s method that returns the student's full name","full_description":"Student#to_s has a #to_s method that returns the student's full name","status":"passed","file_path":"./spec/models/student_spec.rb","line_number":25,"run_time":0.0020812,"pending_message":null}],"summary":{"duration":0.0232854,"example_count":4,"failure_count":0,"pending_count":0,"errors_outside_of_examples_count":0},"summary_line":"4 examples, 0 failures"} \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index f2ff69819..0bb1f8003 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,6 +86,8 @@ GEM nio4r (2.5.7) nokogiri (1.11.3-x86_64-darwin) racc (~> 1.4) + nokogiri (1.11.3-x86_64-linux) + racc (~> 1.4) puma (5.2.2) nio4r (~> 2.0) racc (1.5.2) @@ -162,6 +164,7 @@ GEM PLATFORMS x86_64-darwin-19 + x86_64-linux DEPENDENCIES byebug diff --git a/app/models/student.rb b/app/models/student.rb new file mode 100644 index 000000000..0785c7a34 --- /dev/null +++ b/app/models/student.rb @@ -0,0 +1,5 @@ +class Student < ApplicationRecord + def to_s + "#{self.first_name} #{self.last_name}" + end +end diff --git a/db/migrate/20230814023245_create_students.rb b/db/migrate/20230814023245_create_students.rb new file mode 100644 index 000000000..c6b550135 --- /dev/null +++ b/db/migrate/20230814023245_create_students.rb @@ -0,0 +1,11 @@ +class CreateStudents < ActiveRecord::Migration[6.1] + def change + create_table :students do |t| + t.string :first_name + t.string :last_name + t.integer :grade + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 000000000..266af24dc --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,23 @@ +# 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: 2023_08_14_023245) do + + create_table "students", force: :cascade do |t| + t.string "first_name" + t.string "last_name" + t.integer "grade" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + +end diff --git a/db/seeds.rb b/db/seeds.rb index f3a0480d1..29b3f4cf4 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,5 @@ # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) + +Student.create(first_name: "Dwayne", last_name: "Johnson", grade: 99)