diff --git a/app/controllers/foods_controller.rb b/app/controllers/foods_controller.rb index 029be81..aa8ecf3 100644 --- a/app/controllers/foods_controller.rb +++ b/app/controllers/foods_controller.rb @@ -2,7 +2,7 @@ class FoodsController < ApplicationController before_action :set_food, only: %i[show destroy] def index - @foods = Food.all + @foods = Food.includes(:user) end def destroy diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 5ede964..bbabadb 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,26 +1,31 @@ -

Log in

+
+

Log in Page

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, autocomplete: "email", class: "form-control" %>
-
- <%= f.label :password %>
- <%= f.password_field :password, autocomplete: "current-password" %> +
+
+ <%= f.label :password %> + <%= f.password_field :password, autocomplete: "current-password", class: "form-control"%>
<% if devise_mapping.rememberable? %> -
- <%= f.check_box :remember_me %> - <%= f.label :remember_me %> +
+
+ <%= f.check_box :remember_me %> Remember me +
<% end %>
- <%= f.submit "Log in" %> +
+ <%= f.submit "Log in", class: "btn btn-primary" %>
+
<% end %> <%= render "devise/shared/links" %> diff --git a/app/views/foods/_form.html.erb b/app/views/foods/_form.html.erb index 41305a4..349a0e3 100644 --- a/app/views/foods/_form.html.erb +++ b/app/views/foods/_form.html.erb @@ -11,7 +11,7 @@
<% end %> -
+
<%= form.label :name, style: "display: block" %> <%= form.text_field :name %>
@@ -27,6 +27,7 @@
+
<%= form.submit %>
<% end %> diff --git a/app/views/foods/index.html.erb b/app/views/foods/index.html.erb index b98ced8..ef332fb 100644 --- a/app/views/foods/index.html.erb +++ b/app/views/foods/index.html.erb @@ -1,17 +1,18 @@ -
+

<%= notice %>

+

List of Foods

-
- <%= link_to 'Add Food', new_food_path %> +
+ <%= link_to 'Add Food', new_food_path, class: 'btn btn-lg btn-primary'%>
-
- +


+
- + @@ -22,7 +23,7 @@
diff --git a/app/views/foods/new.html.erb b/app/views/foods/new.html.erb index 84bc27f..173abf4 100644 --- a/app/views/foods/new.html.erb +++ b/app/views/foods/new.html.erb @@ -1,4 +1,5 @@ -

New food

+

<%= notice %>



+

NEW FOOD

<%= render "form", food: @food %> diff --git a/app/views/foods/show.html.erb b/app/views/foods/show.html.erb index f26bad9..89f155c 100644 --- a/app/views/foods/show.html.erb +++ b/app/views/foods/show.html.erb @@ -1,10 +1,9 @@ -

<%= notice %>

<%= render @food %> -
+
<%= link_to "Edit this food", edit_food_path(@food) %> | - <%= link_to "Back to foods", foods_path %> + <%= link_to "Back to foods", new_food_path, class: "btn btn-primary" %> - <%= button_to "Destroy this food", @food, method: :delete %> + <%= button_to "Confirm to delete", @food, method: :delete, class: "btn btn-danger"%>
diff --git a/db/seeds.rb b/db/seeds.rb index 2724f83..de3e3e3 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,40 +6,40 @@ # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) # Character.create(name: "Luke", movie: movies.first) -wayuni = User.create(name: 'wayungi' email: 'francis@gmail.com', password:'123456') -obella = User.create(name: 'obella', email: 'obella@gmail.com', password:'123456') -kibuuka = User.create(name: 'kibuuka', email: 'kibuuka@gmail.com', password:'123456') -mahooro = User.create(name: 'mahooro', email: 'mahooro@gmail.com', password:'123456') -anzoyo = User.create(name: 'anzoyo', email: 'anzoyo@gmail.com', password:'123456') -sali = User.create(name: 'sali', email: 'sali@gmail.com', password:'123456') +# wayuni = User.create(name: 'wayungi' email: 'francis@gmail.com', password:'123456') +# obella = User.create(name: 'obella', email: 'obella@gmail.com', password:'123456') +# kibuuka = User.create(name: 'kibuuka', email: 'kibuuka@gmail.com', password:'123456') +# mahooro = User.create(name: 'mahooro', email: 'mahooro@gmail.com', password:'123456') +# anzoyo = User.create(name: 'anzoyo', email: 'anzoyo@gmail.com', password:'123456') +# sali = User.create(name: 'sali', email: 'sali@gmail.com', password:'123456') -akora = Inventory.create(name:'Akora', description: 'Delicious staple foodfor the people of West Nile (Uganda)', user: wayungi) -dekngor = Inventory.create(name:'Dek Ngor', description: 'Boiled Amur beans mixed with landi', user: wayungi) -angara = Inventory.create(name:'Angara', description: 'Big fresh nile water fish, shinny and fatty, fried with its own fats', user: wayungi) +# akora = Inventory.create(name:'Akora', description: 'Delicious staple foodfor the people of West Nile (Uganda)', user: wayungi) +# dekngor = Inventory.create(name:'Dek Ngor', description: 'Boiled Amur beans mixed with landi', user: wayungi) +# angara = Inventory.create(name:'Angara', description: 'Big fresh nile water fish, shinny and fatty, fried with its own fats', user: wayungi) -luwombo = Inventory.create(name:'Luwombo', description: 'Chicken cooked in Ndagala', user: sali) -shawama = Inventory.create(name:'Shawama', description: 'Conconction of chips + chicken & wheat', user: sali) -lekuki = Inventory.create(name:'Lekuki', description: 'Wid lased kuki iten 1 pa de', user: sali) +# luwombo = Inventory.create(name:'Luwombo', description: 'Chicken cooked in Ndagala', user: sali) +# shawama = Inventory.create(name:'Shawama', description: 'Conconction of chips + chicken & wheat', user: sali) +# lekuki = Inventory.create(name:'Lekuki', description: 'Wid lased kuki iten 1 pa de', user: sali) -# --------------------------------------------------------------------------- -oboo = Food.create(name: 'Oboo', measurement_unit: 'Bundle', price: 500) -rec = Food.create(name: 'Rec', measurement_unit: 'Piece', price: 15000) -odii = Food.create(name: 'Odii', measurement_unit: 'Kg', price: 10000) -oboo = Food.create(name: 'Oboo', measurement_unit: 'Bundle', price: 500) -beans = Food.create(name: 'Beans', measurement_unit: 'Kg', price: 3600) -moo = Food.create(name: 'Moo', measurement_unit: 'Litre', price: 8000) -yao = Food.create(name: 'Yao', measurement_unit: 'Litre', price: 12000) +# # --------------------------------------------------------------------------- +# oboo = Food.create(name: 'Oboo', measurement_unit: 'Bundle', price: 500) +# rec = Food.create(name: 'Rec', measurement_unit: 'Piece', price: 15000) +# odii = Food.create(name: 'Odii', measurement_unit: 'Kg', price: 10000) +# oboo = Food.create(name: 'Oboo', measurement_unit: 'Bundle', price: 500) +# beans = Food.create(name: 'Beans', measurement_unit: 'Kg', price: 3600) +# moo = Food.create(name: 'Moo', measurement_unit: 'Litre', price: 8000) +# yao = Food.create(name: 'Yao', measurement_unit: 'Litre', price: 12000) -InventoryFood.create(quantity: 8, inventory: akora, food:oboo) -InventoryFood.create(quantity: 2, inventory: akora, food:rec) -InventoryFood.create(quantity: 1, inventory: akora, food:odii) +# InventoryFood.create(quantity: 8, inventory: akora, food:oboo) +# InventoryFood.create(quantity: 2, inventory: akora, food:rec) +# InventoryFood.create(quantity: 1, inventory: akora, food:odii) -InventoryFood.create(quantity: 1, inventory: dekngor, food:beans) -InventoryFood.create(quantity: 1, inventory: dekngor, food:odii) +# InventoryFood.create(quantity: 1, inventory: dekngor, food:beans) +# InventoryFood.create(quantity: 1, inventory: dekngor, food:odii) -InventoryFood.create(quantity: 4, inventory: angara, food:rec) -InventoryFood.create(quantity: 50, inventory: angara, food:moo) +# InventoryFood.create(quantity: 4, inventory: angara, food:rec) +# InventoryFood.create(quantity: 50, inventory: angara, food:moo) #Users #5.times do
Food Measurement Unit Price UnitActionActions
<%= food.price %> - <% if can? :delete, food %><%= link_to'Delete', food, :method => :delete %><% end %> + <% if can? :delete, food %><%= link_to'Delete', food, :method => :delete, class: "btn btn-danger" %><% end %>