GithubHelp home page GithubHelp logo

data-importer's Introduction

README

This README would normally document whatever steps are necessary to get the application up and running.

Things you may want to cover:

  • Ruby version

  • System dependencies

  • Configuration

  • Database creation

  • Database initialization

  • How to run the test suite

  • Services (job queues, cache servers, search engines, etc.)

  • Deployment instructions

Please feel free to use a different markup language if you do not plan to run rake doc:app.

## Download and install

Using git to clone the repository to your local drive

# git clone github.com/ycchen/data-engineering

# cd to data-engineering folder and run bundle install

## Database setup

# rake db:migrate

## Run the webserver

# rails server

## View the webpage

# localhost:3000/

## run the test

# rake db:migrate RAILS_ENV=test

# rspec

## following steps are how I did this application

  1. create purchaser model

$ rails g scaffold purchaser name:string

  1. create item model

$ rails g scaffold item description:string price:float

  1. create merchant model

$ rails g scaffold merchant name:string address:string

  1. create sale model

$ rails g scaffold sale purchaser:references item:references merchant:references count:integer item_cost:decimal

  1. use devise to create user model

$ rails g devise:install

$ rails g devise User

$ rails g devise:views

  1. create import model

$ rails g scaffold import record_count:integer total_gross_revenue:decimal completed:boolean file:attachment

  1. update config/routes.rb to set the root ‘importers#index’

  2. rake db:migrate

  3. update models/import.rb with paperclip

has_attached_file :file validates_attachment :file, :presence => true, :content_type => { :content_type => %w(image/jpeg image/jpg image/png text/tab)}, :size => { :in => 0..100.kilobytes}

  1. create process_file method to parsing file, also include reqire ‘csv’ in configapplication.rb

require ‘csv’

  1. create import_detail model

$ rails g scaffold import_detail purchaser_name:string merchant_name:string merchant_address:string item_description:string item_price:decimal purchase_count:integer import:references

12.

rescue_from ActiveRecord::RecordNotFound, :with => :not_found
rescue_from AbstractController::ActionNotFound, :with => :not_found
rescue_from ActionController::RoutingError, :with => :not_found

13 start testiing with rspec

$ rails g rspec:install

data-importer's People

Contributors

ycchen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.