diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb
index 6a21f46..de792e9 100644
--- a/app/controllers/orders_controller.rb
+++ b/app/controllers/orders_controller.rb
@@ -5,8 +5,19 @@ class OrdersController < ApplicationController
# GET /orders.json
def index
# filtering information according to current user
- @user = User.find(current_user.id)
- @orders = @user.orders.all
+
+ @user = User.find(current_user.id)
+
+ if @user.admin?
+
+ @orders = Order.all
+
+ else
+
+ @orders = @user.orders.all
+
+ end
+
#@orders = Order.all
end
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 54d2f90..dd81954 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -5,6 +5,8 @@ def login
flash[:notice] = "you are logged in"
redirect_to :controller => :items
#session[:cart] = nil
+
+ current_user.update_attribute :admin, true
end
def logout
#in case things go crazy and impossible to understand uncomment the line below and logout /login
diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb
index 2df32a8..0100687 100644
--- a/app/views/layouts/_footer.html.erb
+++ b/app/views/layouts/_footer.html.erb
@@ -2,15 +2,24 @@
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb
index a07b41f..abd76b1 100644
--- a/app/views/layouts/_header.html.erb
+++ b/app/views/layouts/_header.html.erb
@@ -15,16 +15,26 @@
<% if user_signed_in? %>
<%= link_to 'Edit Profile', edit_user_registration_path %>
<%= link_to 'Sign Out', destroy_user_session_path, :method =>:delete %>
+
+ <% if current_user.admin? %>
+ Admin
+ <% else %>
+ User
+ <% end %>
<% else %>
<%= link_to 'Register', new_user_registration_path %>
<%= link_to 'Sign In', new_user_session_path %>
- <% end %>
- <% if session[:login] == 1 %>
- <%= link_to "Admin Logout", logout_path %>
- <% else %>
- <%= link_to "Admin Login", login_path %>
+
+
+
<% end %>
+
+
+
+
+
+
diff --git a/app/views/static_pages/about.html.erb b/app/views/static_pages/about.html.erb
index 8575d57..d2f698b 100644
--- a/app/views/static_pages/about.html.erb
+++ b/app/views/static_pages/about.html.erb
@@ -1,7 +1,7 @@
- Bootstrap Example
+ GameLand | About
diff --git a/app/views/static_pages/help.html.erb b/app/views/static_pages/help.html.erb
index 808d529..9a3c2d2 100644
--- a/app/views/static_pages/help.html.erb
+++ b/app/views/static_pages/help.html.erb
@@ -1,7 +1,7 @@
- Bootstrap Example
+ GameLand | Help
diff --git a/db/development.sqlite3 b/db/development.sqlite3
index fba0ddd..d55d731 100644
Binary files a/db/development.sqlite3 and b/db/development.sqlite3 differ
diff --git a/db/migrate/20180421092309_add_admin_to_users.rb b/db/migrate/20180421092309_add_admin_to_users.rb
new file mode 100644
index 0000000..79116a7
--- /dev/null
+++ b/db/migrate/20180421092309_add_admin_to_users.rb
@@ -0,0 +1,5 @@
+class AddAdminToUsers < ActiveRecord::Migration[5.1]
+ def change
+ add_column :users, :admin, :boolean, default: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 3208439..36b5a92 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: 20180418113405) do
+ActiveRecord::Schema.define(version: 20180421092309) do
create_table "brands", force: :cascade do |t|
t.string "title"
@@ -82,6 +82,7 @@
t.string "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.boolean "admin", default: false
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 1beea2a..a2cc9c4 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -5,3 +5,9 @@
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
+
+
+
+
+User.create(email: "info@gameland.com", admin:"true", password: "1234567", password_confirmation: "1234567")
+