Small commit, for iasoon <3

This commit is contained in:
Benjamin Cousaert 2014-12-08 17:56:48 +01:00
parent ebf2275c94
commit b30b527650
6 changed files with 13 additions and 15 deletions

View file

@ -4,8 +4,7 @@
#
# id :integer not null, primary key
# name :string(255)
# purchase_price :integer
# sale_price :integer
# price :integer
# created_at :datetime
# updated_at :datetime
# avatar_file_name :string(255)
@ -19,8 +18,7 @@ class Product < ActiveRecord::Base
has_attached_file :avatar, styles: { medium: "100x100>" }, default_style: :medium
validates :name, presence: true
validates :purchase_price, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates :sale_price, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
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"] }
def count(order)

View file

@ -0,0 +1,7 @@
<%= image_tag f.object.product.avatar %>
<div class="input-group">
<%= render partial: 'btn_dec' %>
<%= f.text_field :count, class: 'form-control', value: 0 %>
<%= render partial: 'btn_inc' %>
<%= f.hidden_field :product_id %>
</div>

View file

@ -4,12 +4,7 @@
<%= render 'application/errors', model: @order %>
<%= f.fields_for :order_products do |op_field| %>
<div class="input-group">
<%= render partial: 'btn_dec' %>
<%= op_field.text_field :count, class: 'form-control', value: 0 %>
<%= render partial: 'btn_inc' %>
<%= op_field.hidden_field :product_id %>
</div>
<%= render 'order_products/form_row', f: op_field %>
<% end %>
<%= f.submit "Order", class: "btn btn-primary " %>
<% end %>

View file

@ -1,6 +1,6 @@
Rails.application.routes.draw do
root "users#index"
root "orders#overview"
resources :users do
resources :orders, only: [:new, :create, :index]

View file

@ -4,8 +4,7 @@
#
# id :integer not null, primary key
# name :string(255)
# purchase_price :integer
# sale_price :integer
# price :integer
# created_at :datetime
# updated_at :datetime
# avatar_file_name :string(255)

View file

@ -4,8 +4,7 @@
#
# id :integer not null, primary key
# name :string(255)
# purchase_price :integer
# sale_price :integer
# price :integer
# created_at :datetime
# updated_at :datetime
# avatar_file_name :string(255)