+
+
+ <%= link_to 'Home', '/welcome', method: :get%>
+
-
- <%= link_to 'Books', '/books', method: :get%>
+
+ <%= link_to 'Books', '/books', method: :get%>
+
+ <% if current_user&.admin? %>
+
+ <%= link_to 'Authors', '/authors', method: :get%>
+
+
+ <%= link_to 'Users', '/users', method: :get%>
+
+ <% end %>
+ <% if logged_in? %>
+
+ <%= link_to 'Shopping cart', '/authors', method: :get%>
+
+ <% end %>
- <% if current_user&.admin? %>
-
- <%= link_to 'Authors', '/authors', method: :get%>
-
-
- <%= link_to 'Users', '/users', method: :get%>
-
- <% end %>
<% flash.each do |type, notice| %>
diff --git a/db/migrate/20210321235625_add_quantity_to_books.rb b/db/migrate/20210321235625_add_quantity_to_books.rb
new file mode 100644
index 0000000..ee6dbc1
--- /dev/null
+++ b/db/migrate/20210321235625_add_quantity_to_books.rb
@@ -0,0 +1,5 @@
+class AddQuantityToBooks < ActiveRecord::Migration[6.1]
+ def change
+ add_column :books, :quantity, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 44467b1..27ba16b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2021_03_21_225317) do
+ActiveRecord::Schema.define(version: 2021_03_21_235625) do
create_table "audit_records", force: :cascade do |t|
t.string "model"
@@ -43,6 +43,7 @@ ActiveRecord::Schema.define(version: 2021_03_21_225317) do
t.boolean "published"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
+ t.integer "quantity"
t.index ["published"], name: "index_books_on_published"
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 5f2ae2a..f2c9c04 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -2,17 +2,20 @@ books = Book.create([
{
title: 'Journey to the Center of the Earth',
price: 10900,
- published: true
+ published: true,
+ quantity: 100
},
{
title: 'From the Earth to the Moon',
price: 6300,
- published: false
+ published: false,
+ quantity: 0
},
{
title: 'Imaginary trip',
price: 3600,
- published: true
+ published: true,
+ quantity: 0
},
])