Small commit, for iasoon <3
This commit is contained in:
parent
ebf2275c94
commit
b30b527650
6 changed files with 13 additions and 15 deletions
|
@ -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)
|
||||
|
|
7
app/views/order_products/_form_row.html.erb
Normal file
7
app/views/order_products/_form_row.html.erb
Normal 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>
|
|
@ -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 %>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
root "users#index"
|
||||
root "orders#overview"
|
||||
|
||||
resources :users do
|
||||
resources :orders, only: [:new, :create, :index]
|
||||
|
|
3
test/fixtures/products.yml
vendored
3
test/fixtures/products.yml
vendored
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue