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
## run the test
# rake db:migrate RAILS_ENV=test
# rspec
## following steps are how I did this application
-
create purchaser model
$ rails g scaffold purchaser name:string
-
create item model
$ rails g scaffold item description:string price:float
-
create merchant model
$ rails g scaffold merchant name:string address:string
-
create sale model
$ rails g scaffold sale purchaser:references item:references merchant:references count:integer item_cost:decimal
-
use devise to create user model
$ rails g devise:install
$ rails g devise User
$ rails g devise:views
-
create import model
$ rails g scaffold import record_count:integer total_gross_revenue:decimal completed:boolean file:attachment
-
update config/routes.rb to set the root ‘importers#index’
-
rake db:migrate
-
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}
-
create process_file method to parsing file, also include reqire ‘csv’ in configapplication.rb
require ‘csv’
-
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