Commit da8a08d5 by vulehuan

import product category from yahoo

parent b6d0bbfe
class ProductCategory < ActiveRecord::Base
end
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
</div> </div>
</div> </div>
<%= render 'layouts/footer' %> <%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
<%= yield %> <%= yield %>
</div> </div>
<%= render 'layouts/footer' %> <%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
......
...@@ -8,3 +8,6 @@ RecaptchaMailhide.configure do |c| ...@@ -8,3 +8,6 @@ RecaptchaMailhide.configure do |c|
c.private_key = '6LfDL-kSAAAAAFDLOFADJ0GJql1-6tCTo0PlWz7L' c.private_key = '6LfDL-kSAAAAAFDLOFADJ0GJql1-6tCTo0PlWz7L'
c.public_key = '6LfDL-kSAAAAAG8JuwZhxLaT8X8iHZYpWu-7DAFe' c.public_key = '6LfDL-kSAAAAAG8JuwZhxLaT8X8iHZYpWu-7DAFe'
end end
YAHOO_SHOPPING_DATA_APP_ID = 'dj0zaiZpPXpIMzBsMUQyTk55dSZkPVlXazlZWGxzYjNoWU0yVW1jR285TUEtLSZzPWNvbnN1bWVyc2VjcmV0Jng9MzI-'
YAHOO_SHOPPING_DATA_SECRECT = '45b3584021d48d65984b515a2cd23623a3ec90cc'
\ No newline at end of file
...@@ -3,6 +3,7 @@ VenshopApp::Application.routes.draw do ...@@ -3,6 +3,7 @@ VenshopApp::Application.routes.draw do
resources :sessions, only: [:new, :create, :destroy] resources :sessions, only: [:new, :create, :destroy]
get "default_pages/home" get "default_pages/home"
get "users/new" get "users/new"
match '/testyahoo', to: 'users#testyahoo', via: 'get'
match '/signup', to: 'users#new', via: 'get' match '/signup', to: 'users#new', via: 'get'
match '/signin', to: 'sessions#new', via: 'get' match '/signin', to: 'sessions#new', via: 'get'
match '/signout', to: 'sessions#destroy', via: 'delete' match '/signout', to: 'sessions#destroy', via: 'delete'
......
class CreateProductCategories < ActiveRecord::Migration
def change
create_table :product_categories do |t|
t.string :name
t.integer :weight
t.boolean :status
t.timestamps
end
end
end
...@@ -11,7 +11,15 @@ ...@@ -11,7 +11,15 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20131023020942) do ActiveRecord::Schema.define(version: 20131023083438) do
create_table "product_categories", force: true do |t|
t.string "name"
t.integer "weight"
t.boolean "status"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "users", force: true do |t| create_table "users", force: true do |t|
t.string "name" t.string "name"
......
namespace :db do
desc "Fill database with Yahoo shopping data"
task populate: :environment do
# Product Category
category_url = 'http://dir.yahooapis.jp/Category/V1/Category'
category_path = '/Computers_and_Internet/Hardware/SmartPhone/'
request_url = category_url + '?appid=' + YAHOO_SHOPPING_DATA_APP_ID + '&path=' + category_path
require 'net/http'
require 'rexml/document'
# get the XML data as a string
xml_data = Net::HTTP.get_response(URI.parse(request_url)).body
# extract category information
doc = REXML::Document.new(xml_data)
doc.elements.each('CategoryResult/Category/Item') do |ele|
id = ele.elements['Id'].text
title = ele.elements['Title'].text
ProductCategory.create!(
id: id,
name: title,
weight: id,
status: true
)
end
end
end
\ No newline at end of file
require 'spec_helper'
describe ProductCategory do
pending "add some examples to (or delete) #{__FILE__}"
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