fix some shit

This commit is contained in:
Benjamin Cousaert 2014-12-10 09:20:12 +01:00
parent e1ee373b92
commit 11097ccfb9
6 changed files with 5 additions and 45 deletions

View file

@ -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

View file

@ -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

View file

@ -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'

View file

@ -2,11 +2,7 @@
<div class="thumbnail monopoly">
<h3 class="header" style="background-color: #<%=get_color(user)%>;" ><%= user.full_name %></h3>
<div class="caption">
<% 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") %>
<p><strong>Name:</strong> <%= user.name %></p>
<p><strong>Last name:</strong> <%= user.last_name %></p>
<p><strong>Nickname:</strong> <%= user.nickname %></p>

View file

@ -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"

View file

@ -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