+
+<%= link_to 'Back to all books', books_path %>
\ No newline at end of file
diff --git a/app/views/copies/_copy_form.html.erb b/app/views/copies/_copy_form.html.erb
new file mode 100755
index 0000000..de56061
--- /dev/null
+++ b/app/views/copies/_copy_form.html.erb
@@ -0,0 +1,18 @@
+
+<%= form_with model: @copy do |f| %>
+
+
+
+ <%= link_to 'Back', book_copies_path(@copy.book_id || @book) %>
+
+<% end -%>
\ No newline at end of file
diff --git a/app/views/copies/edit.html.erb b/app/views/copies/edit.html.erb
new file mode 100755
index 0000000..cc1408e
--- /dev/null
+++ b/app/views/copies/edit.html.erb
@@ -0,0 +1 @@
+<%= render 'copy_form' %>
\ No newline at end of file
diff --git a/app/views/copies/index.html.erb b/app/views/copies/index.html.erb
new file mode 100755
index 0000000..23e27f5
--- /dev/null
+++ b/app/views/copies/index.html.erb
@@ -0,0 +1,21 @@
+<% if @copies.blank? %>
+
There are no copies of this book in the library
+
+<% else %>
+
All Copies of <%= @book.title %>
+
+ <% @copies.each { |copy| %>
+
+ Borrowed by <%=copy.borrower %>
+ with a return date of <%=copy.due_date %>
+ (<%= link_to 'edit', edit_copy_path(copy), :action => :edit %>)
+
+
+ <% } %>
+
+<%end %>
+
+
<%= link_to "Add new Copy", :action => 'new' %>
+
+
+<%= link_to 'Back', book_path(@book) %>
\ No newline at end of file
diff --git a/app/views/copies/new.html.erb b/app/views/copies/new.html.erb
new file mode 100755
index 0000000..9f09f1f
--- /dev/null
+++ b/app/views/copies/new.html.erb
@@ -0,0 +1 @@
+<%= render 'copy_form' %>
diff --git a/config/environments/production.rb b/config/environments/production.rb
old mode 100644
new mode 100755
index 71feec7..64b20fa
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -6,7 +6,7 @@
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
- # and those relying on copy on write to perform better.
+ # and those relying on copies on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
old mode 100644
new mode 100755
index ac033bf..9f616c2
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -1,5 +1,7 @@
# Be sure to restart your server when you modify this file.
-
+ActiveSupport::Inflector.inflections do |inflect|
+ inflect.irregular 'copy', 'copies'
+end
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
diff --git a/config/routes.rb b/config/routes.rb
old mode 100644
new mode 100755
index f47f3aa..e65a60b
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,7 @@
Rails.application.routes.draw do
- resources :books
- # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+ resources :books do
+ resources :copies, shallow: true
+ end
end
+# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+
diff --git a/db/migrate/20200909101937_create_copies.rb b/db/migrate/20200909101937_create_copies.rb
old mode 100644
new mode 100755
index bd5f4f0..82b26e7
--- a/db/migrate/20200909101937_create_copies.rb
+++ b/db/migrate/20200909101937_create_copies.rb
@@ -1,8 +1,8 @@
class CreateCopies < ActiveRecord::Migration[5.2]
def change
create_table :copies do |t|
- t.string :Borrower, null: false
- t.date :DueDate, null: false
+ t.string :borrower, null: false
+ t.date :due_date, null: false
t.timestamps
end
diff --git a/db/schema.rb b/db/schema.rb
index cac5dbb..cede1ce 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -21,8 +21,8 @@
end
create_table "copies", force: :cascade do |t|
- t.string "Borrower", null: false
- t.date "DueDate", null: false
+ t.string "borrower", null: false
+ t.date "due_date", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "book_id"