Commit 193525ad by Dao Minh Nhut

fix code convention

parent 2cbd592f
class HomeController < ApplicationController
def index
@products = Product.all
@products = Product.all
end
end
......@@ -3,34 +3,33 @@ class ProductsController < ApplicationController
#before_filter :correct_user, only: :destroy
#def show
#@item = Product.find(params[:id])
#@item = Product.find(params[:id])
#end
def index
@item = Product.find(:all)
#@items = Product.all.select do |i|
# i.category==params[:id]
#end
#@items = Product.all.select do |i|
#i.category==params[:id]
#end
end
def new
@item= Product.new
render layout: "another_layout"
@item= Product.new
render layout: "another_layout"
end
def create
@item = current_user.items.new(params[:item])
if @item.save
flash[:success] = "Your item has successfully posted!"
flash[:success] = "Your item has successfully posted!"
redirect_to current_user, layout: "another_layout"
else
render 'new', layout: "another_layout"
end
end
def destroy
@item.destroy
redirect_to current_user
end
private
def correct_user
@item = current_user.items.find_by_id(params[:id])
redirect_to root_url if @item.nil?
......
<div class="span9 categories">
<% @items_of_category.each do |i| %>
<div class="span5 center">
<h4><%= i.name%></h4>
......
<div class="span3">
<div class="sidebar-nav-fixed">
<div class="well">
<ul class="nav nav-list">
<li class="nav-header">Category</li>
<!--% category_list.each do |cat| %-->
<li><a href='/categories/<%= cat.id%>'><%=cat.name%></a></li>
<%end%>
</ul>
<ul class="nav nav-list">
<li class="nav-header">Category</li>
<!--% category_list.each do |cat| %-->
<li><a href='/categories/<%= cat.id%>'><%=cat.name%></a></li>
<!--%end%-->
</ul>
</div><!--/.well -->
</div> <!--/sidebar-nav-fixed -->
</div><!--/span-->
\ No newline at end of file
<div class="span8 center">
<h3>Name: </h3><%= @item.name%><br><br>
<h3>Name: </h3><%= @product.name%><br><br>
</div><!--/span-->
\ No newline at end of file
......@@ -15,7 +15,7 @@ ActiveRecord::Schema.define(version: 20150721071537) do
create_table "categories", force: :cascade do |t|
t.string "name", limit: 255
t.string "description", limit: 255
t.string "description", limit: 65535
t.string "image", limit: 255
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
......@@ -25,7 +25,7 @@ ActiveRecord::Schema.define(version: 20150721071537) do
t.string "name", limit: 255
t.string "image", limit: 255
t.integer "price", limit: 4
t.string "description", limit: 255
t.string "description", limit: 65535
t.integer "category_id", limit: 4
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
......
......@@ -33,15 +33,15 @@ class ImportAmazon
end
def get_response(page)
response = @request.item_search(
query: {
'Keywords' => '*',
'SearchIndex' => 'Blended',
'ResponseGroup' => 'Medium',
'ItemPage' => page,
}
)
response = @request.item_search(
query: {
'Keywords' => '*',
'SearchIndex' => 'Blended',
'ResponseGroup' => 'Medium',
'ItemPage' => page,
}
)
response.to_h["ItemSearchResponse"].to_h["Items"].to_h["Item"]
end
end
\ No newline at end of file
namespace :products do
desc 'Get products'
namespace :products do
desc 'Get products'
task import: :environment do
ImportAmazon.new.import_product
end
end
end
......@@ -6,4 +6,4 @@ class HomeControllerTest < ActionController::TestCase
assert_response :success
end
end
end
\ No newline at end of file
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