From 11097ccfb9633918a50c83faba6b39fe8ecbbe4f Mon Sep 17 00:00:00 2001 From: Benjamin Cousaert Date: Wed, 10 Dec 2014 09:20:12 +0100 Subject: [PATCH] fix some shit --- app/helpers/orders_helper.rb | 18 ------------------ app/models/product.rb | 3 ++- app/models/user.rb | 2 +- app/views/users/_user.html.erb | 6 +----- db/schema.rb | 2 +- db/seeds.rb | 19 ------------------- 6 files changed, 5 insertions(+), 45 deletions(-) diff --git a/app/helpers/orders_helper.rb b/app/helpers/orders_helper.rb index 8faf988..443227f 100644 --- a/app/helpers/orders_helper.rb +++ b/app/helpers/orders_helper.rb @@ -1,20 +1,2 @@ module OrdersHelper - - def ordering(user) - session[:order_user_id] = user.id - end - - def current_ordering_user - @current_ordering_user ||= User.find_by(id: session[:order_user_id]) - end - - def end_order - session.delete(:order_user_id) - @current_ordering_user = nil - end - - def ordering? - !current_ordering_user.nil? - end - end diff --git a/app/models/product.rb b/app/models/product.rb index 4463062..e7f09dc 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -19,7 +19,8 @@ class Product < ActiveRecord::Base validates :name, presence: true validates :price, numericality: { only_integer: true, greater_than_or_equal_to: 0 } - validates_attachment :avatar, presence: true, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] } + validates_attachment :avatar, presence: true, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }, + default_url: "http://babeholder.pixoil.com/img/190/190" def count(order) order_products.find_by(order: order).count diff --git a/app/models/user.rb b/app/models/user.rb index f4ed8c2..e6fd81d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -23,7 +23,7 @@ class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :rememberable, :trackable - has_attached_file :avatar, styles: { medium: "100x100>" }, default_style: :medium + has_attached_file :avatar, styles: { medium: "100x100>" }, default_style: :medium, default_url: "http://babeholder.pixoil.com/img/70/70" has_many :orders, -> { includes :products } belongs_to :dagschotel, class_name: 'Product' diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index c9f0694..e940fb3 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb @@ -2,11 +2,7 @@

<%= user.full_name %>

- <% if user.avatar.exists? %> - <%= image_tag(user.avatar , class: "img-circle avatar") %> - <% else %> - <%= image_tag("http://babeholder.pixoil.com/img/70/70", class: "img-circle avatar") %> - <% end %> + <%= image_tag(user.avatar , class: "img-circle avatar") %>

Name: <%= user.name %>

Last name: <%= user.last_name %>

Nickname: <%= user.nickname %>

diff --git a/db/schema.rb b/db/schema.rb index 4119d8a..f1ba18d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -54,8 +54,8 @@ ActiveRecord::Schema.define(version: 20141209204351) do t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.boolean "admin" t.integer "dagschotel_id" + t.boolean "admin" t.string "avatar_file_name" t.string "avatar_content_type" t.integer "avatar_file_size" diff --git a/db/seeds.rb b/db/seeds.rb index da5deda..28fc1d4 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,22 +6,3 @@ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) -User.create! name: "Mats", - nickname: "Basho", - last_name: "Myncke", - admin: true, - password: "banaan12", - password_confirmation: "banaan12" - -99.times do |n| - name = Faker::Name.first_name - nickname = Faker::Name.first_name - last_name = Faker::Name.last_name - password = "password" - - User.create! name: name, - nickname: nickname, - last_name: last_name, - password: password, - password_confirmation: password -end