Commit 193525ad by Dao Minh Nhut

fix code convention

parent 2cbd592f
...@@ -8,7 +8,7 @@ class ProductsController < ApplicationController ...@@ -8,7 +8,7 @@ class ProductsController < ApplicationController
def index def index
@item = Product.find(:all) @item = Product.find(:all)
#@items = Product.all.select do |i| #@items = Product.all.select do |i|
# i.category==params[:id] #i.category==params[:id]
#end #end
end end
def new def new
...@@ -24,13 +24,12 @@ class ProductsController < ApplicationController ...@@ -24,13 +24,12 @@ class ProductsController < ApplicationController
render 'new', layout: "another_layout" render 'new', layout: "another_layout"
end end
end end
def destroy def destroy
@item.destroy @item.destroy
redirect_to current_user redirect_to current_user
end end
private
def correct_user def correct_user
@item = current_user.items.find_by_id(params[:id]) @item = current_user.items.find_by_id(params[:id])
redirect_to root_url if @item.nil? redirect_to root_url if @item.nil?
......
<div class="span9 categories"> <div class="span9 categories">
<% @items_of_category.each do |i| %> <% @items_of_category.each do |i| %>
<div class="span5 center"> <div class="span5 center">
<h4><%= i.name%></h4> <h4><%= i.name%></h4>
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
<div class="sidebar-nav-fixed"> <div class="sidebar-nav-fixed">
<div class="well"> <div class="well">
<ul class="nav nav-list"> <ul class="nav nav-list">
<li class="nav-header">Category</li> <li class="nav-header">Category</li>
<!--% category_list.each do |cat| %--> <!--% category_list.each do |cat| %-->
<li><a href='/categories/<%= cat.id%>'><%=cat.name%></a></li> <li><a href='/categories/<%= cat.id%>'><%=cat.name%></a></li>
<%end%> <!--%end%-->
</ul> </ul>
</div><!--/.well --> </div><!--/.well -->
</div> <!--/sidebar-nav-fixed --> </div> <!--/sidebar-nav-fixed -->
......
<div class="span8 center"> <div class="span8 center">
<h3>Name: </h3><%= @product.name%><br><br>
<h3>Name: </h3><%= @item.name%><br><br>
</div><!--/span--> </div><!--/span-->
\ No newline at end of file
...@@ -15,7 +15,7 @@ ActiveRecord::Schema.define(version: 20150721071537) do ...@@ -15,7 +15,7 @@ ActiveRecord::Schema.define(version: 20150721071537) do
create_table "categories", force: :cascade do |t| create_table "categories", force: :cascade do |t|
t.string "name", limit: 255 t.string "name", limit: 255
t.string "description", limit: 255 t.string "description", limit: 65535
t.string "image", limit: 255 t.string "image", limit: 255
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
...@@ -25,7 +25,7 @@ ActiveRecord::Schema.define(version: 20150721071537) do ...@@ -25,7 +25,7 @@ ActiveRecord::Schema.define(version: 20150721071537) do
t.string "name", limit: 255 t.string "name", limit: 255
t.string "image", limit: 255 t.string "image", limit: 255
t.integer "price", limit: 4 t.integer "price", limit: 4
t.string "description", limit: 255 t.string "description", limit: 65535
t.integer "category_id", limit: 4 t.integer "category_id", limit: 4
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
......
namespace :products do namespace :products do
desc 'Get products' desc 'Get products'
task import: :environment do task import: :environment do
ImportAmazon.new.import_product ImportAmazon.new.import_product
end end
end 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