Commit 61d967f4 by vulehuan

add new product form

parent 7eca9aae
......@@ -17,9 +17,24 @@ class ProductsController < ApplicationController
end
def new
add_breadcrumb "Add new product", :new_product_path
@product = Product.new
end
def user_items
end
private
def product_params
params.require(:product).permit(:name, :description, :headline, :availability, :code, :condition, :image_small, :image_medium, :price_currency, :price)
end
# Before filters
def signed_in_user
unless signed_in?
store_location
redirect_to signin_url, notice: "Please sign in."
end
end
end
<%= render 'shared/error_messages', entity: @product %>
<%= f.label :name %>
<%= f.text_field :name, class: "form-control" %>
<%= f.label :description %>
<%= f.text_area :description, class: "form-control" %>
<%= f.label :headline %>
<%= f.text_field :headline, class: "form-control" %>
<%= f.label :availability %>
<%= f.text_field :availability, class: "form-control" %>
<%= f.label :code %>
<%= f.text_field :code, class: "form-control" %>
<%= f.label :condition %>
<%= f.text_field :condition, class: "form-control" %>
<%= f.label :image_small %>
<%= f.text_field :image_small, class: "form-control" %>
<%= f.label :image_medium %>
<%= f.text_field :image_medium, class: "form-control" %>
<%= f.label :price_currency %>
<%= f.text_field :price_currency, class: "form-control" %>
<%= f.label :price %>
<%= f.text_field :price, class: "form-control" %>
\ No newline at end of file
<% provide(:title, 'Add new product') %>
<div class="body-box">
<h2 class="sprite-2">Add new product<span class="sprite-2"></span></h2>
<div class="text-justify">
<%= form_for(@product) do |f| %>
<%= render 'fields', f:f %>
<%= f.submit "Submit", class: "btn btn-large btn-primary btn-submit" %>
<% end %>
</div>
</div>
\ No newline at end of file
<% if @user.errors.any? %>
<% if entity.errors.any? %>
<div id="error_explanation">
<div class="alert alert-error">
The form contains <%= pluralize(@user.errors.count, "error") %>.
The form contains <%= pluralize(entity.errors.count, "error") %>.
<ul>
<% @user.errors.full_messages.each do |msg| %>
<% entity.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
......
<%= render 'shared/error_messages' %>
<%= render 'shared/error_messages', entity: @user %>
<%= f.label :name %>
<%= f.text_field :name, class: "form-control" %>
<%= f.label :email %>
<%= f.text_field :email, class: "form-control", class: "form-control" %>
<%= f.text_field :email, class: "form-control" %>
<%= f.label :password %>
<%= f.password_field :password, class: "form-control" %>
......
......@@ -14,6 +14,7 @@ class CreateProducts < ActiveRecord::Migration
t.string :price_currency
t.decimal :price
t.integer :product_category_id
t.integer :user_id
t.timestamps
end
......
......@@ -47,6 +47,7 @@ ActiveRecord::Schema.define(version: 20131024162951) do
t.string "price_currency"
t.decimal "price", precision: 10, scale: 0
t.integer "product_category_id"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment