diff --git a/app/assets/javascripts/cats.coffee b/app/assets/javascripts/cats.coffee
new file mode 100644
index 0000000..24f83d1
--- /dev/null
+++ b/app/assets/javascripts/cats.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/stylesheets/cats.scss b/app/assets/stylesheets/cats.scss
new file mode 100644
index 0000000..3b00fa0
--- /dev/null
+++ b/app/assets/stylesheets/cats.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the cats controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/cats_controller.rb b/app/controllers/cats_controller.rb
new file mode 100644
index 0000000..9766022
--- /dev/null
+++ b/app/controllers/cats_controller.rb
@@ -0,0 +1,5 @@
+class CatsController < ApplicationController
+ def index
+ @cats = Cat.all
+ end
+end
diff --git a/app/helpers/cats_helper.rb b/app/helpers/cats_helper.rb
new file mode 100644
index 0000000..cadafa9
--- /dev/null
+++ b/app/helpers/cats_helper.rb
@@ -0,0 +1,2 @@
+module CatsHelper
+end
diff --git a/app/models/cat.rb b/app/models/cat.rb
new file mode 100644
index 0000000..628f8be
--- /dev/null
+++ b/app/models/cat.rb
@@ -0,0 +1,11 @@
+class Cat < ApplicationRecord
+
+ validates :name, :age, presence: true
+ validates :name, uniqueness: true
+ validates :age, inclusion: { in: (1..10) }
+ validates :color, inclusion: { in: ["brown", "tiger", "black", "white", "pink"] }, allow_nil: true
+ validates :owner, presence: true
+ validates :owner, length: { minimum: 3 }
+ validates :food, exclusion: { in: ["pineapple", "beer", "chocolate", "wine", "butter"] }
+
+end
diff --git a/app/views/cats/index.html.erb b/app/views/cats/index.html.erb
new file mode 100644
index 0000000..7c386f3
--- /dev/null
+++ b/app/views/cats/index.html.erb
@@ -0,0 +1,10 @@
+
+ <%- @cats.each do |cat| %>
+ -
+ <%= cat.name %>,
+ <%= cat.age %>,
+ <%= cat.color %>,
+ <%= cat.food %>
+
+ <%- end %>
+
diff --git a/config/routes.rb b/config/routes.rb
index 787824f..9bf9bd8 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,3 +1,4 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+ resources :cats
end
diff --git a/db/migrate/20200114183254_create_cats.rb b/db/migrate/20200114183254_create_cats.rb
new file mode 100644
index 0000000..3e59e03
--- /dev/null
+++ b/db/migrate/20200114183254_create_cats.rb
@@ -0,0 +1,12 @@
+class CreateCats < ActiveRecord::Migration[5.2]
+ def change
+ create_table :cats do |t|
+ t.string :name
+ t.integer :age
+ t.string :color
+ t.text :food
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20200205190411_add_owner_to_cats.rb b/db/migrate/20200205190411_add_owner_to_cats.rb
new file mode 100644
index 0000000..9f2def4
--- /dev/null
+++ b/db/migrate/20200205190411_add_owner_to_cats.rb
@@ -0,0 +1,5 @@
+class AddOwnerToCats < ActiveRecord::Migration[5.2]
+ def change
+ add_column :cats, :owner, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000..2b9ac0d
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,25 @@
+# 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.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 2020_02_05_190411) do
+
+ create_table "cats", force: :cascade do |t|
+ t.string "name"
+ t.integer "age"
+ t.string "color"
+ t.text "food"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "owner"
+ end
+
+end
diff --git a/test/controllers/cats_controller_test.rb b/test/controllers/cats_controller_test.rb
new file mode 100644
index 0000000..386a2ae
--- /dev/null
+++ b/test/controllers/cats_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class CatsControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/cat_test.rb b/test/models/cat_test.rb
new file mode 100644
index 0000000..666bba8
--- /dev/null
+++ b/test/models/cat_test.rb
@@ -0,0 +1,31 @@
+
+require 'test_helper'
+
+class CatTest < ActiveSupport::TestCase
+
+ test "should not save cat without name" do
+ cat = Cat.new(owner:'gloria', age: 8)
+ assert_not cat.save
+ end
+
+ test "should not save cat without age" do
+ cat = Cat.new(name:'m', owner:'gloria')
+ assert_not cat.save
+ end
+
+ test "should not save cat if the color is blue" do
+ cat = Cat.new(name:'n', age: 8, owner:'gloria', color:'blue')
+ assert_not cat.save
+ end
+
+ test "should not save cat without owner" do
+ cat = Cat.new(name:'o', age: 8)
+ assert_not cat.save
+ end
+
+ test "should not save cat with an owner without 3 charaters" do
+ cat = Cat.new(name:'p', age: 8, owner:'mi')
+ assert_not cat.save
+ end
+
+end