diff --git a/.gitignore b/.gitignore index c351f42..ba0a5d6 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,9 @@ # Ignore all logfiles and tempfiles. /log/*.log /tmp -/.idea/* +/.idea/** + +/db/.idea/** /export.txt /rails_best_practices_output.html diff --git a/Gemfile b/Gemfile index bf093d3..cc2d984 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ -source 'https://rubygems.org' +#source 'https://rubygems.org' -gem 'rails','3.2.11' +source 'http://ruby.taobao.org' + +gem 'rails','4.0.0' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' @@ -10,17 +12,8 @@ gem 'thin' gem 'slim' gem 'will_paginate' gem 'nokogiri' -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'coffee-rails', '~> 3.2.1' - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - # gem 'therubyracer', :platforms => :ruby - gem 'uglifier', '>= 1.0.3' -end gem 'jquery-rails' @@ -33,11 +26,13 @@ gem 'jquery-rails' # Use unicorn as the app server # gem 'unicorn' -# Deploy with Capistrano +# Deploy with CapistranoCapistrano # gem 'capistrano' # To use debugger # gem 'debugger' +gem 'protected_attributes' + group :development, :test do gem 'rspec-rails' gem 'tddium' diff --git a/Gemfile.lock b/Gemfile.lock index f61921b..f55db29 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,204 +1,187 @@ GEM - remote: https://rubygems.org/ + remote: http://ruby.taobao.org/ specs: - actionmailer (3.2.11) - actionpack (= 3.2.11) - mail (~> 2.4.4) - actionpack (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) - builder (~> 3.0.0) + actionmailer (4.0.0) + actionpack (= 4.0.0) + mail (~> 2.5.3) + actionpack (4.0.0) + activesupport (= 4.0.0) + builder (~> 3.1.0) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.0) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.11) - activesupport (= 3.2.11) - builder (~> 3.0.0) - activerecord (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) - activesupport (3.2.11) - i18n (~> 0.6) - multi_json (~> 1.0) - addressable (2.3.2) - arel (3.0.2) - awesome_print (1.1.0) - builder (3.0.4) - capybara (2.0.1) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + activemodel (4.0.0) + activesupport (= 4.0.0) + builder (~> 3.1.0) + activerecord (4.0.0) + activemodel (= 4.0.0) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.0) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.3) + activesupport (4.0.0) + i18n (~> 0.6, >= 0.6.4) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + addressable (2.3.5) + arel (4.0.1) + atomic (1.1.14) + awesome_print (1.2.0) + builder (3.1.4) + capybara (2.2.1) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) - selenium-webdriver (~> 2.0) - xpath (~> 1.0.0) - childprocess (0.3.6) - ffi (~> 1.0, >= 1.0.6) - code_analyzer (0.3.0) + xpath (~> 2.0) + childprocess (0.3.9) + ffi (~> 1.0, >= 1.0.11) + code_analyzer (0.4.4) sexp_processor - coffee-rails (3.2.2) - coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.2.0) - coffee-script-source - execjs - coffee-script-source (1.4.0) colored (1.2) - cucumber (1.2.1) + cucumber (1.3.10) builder (>= 2.1.2) diff-lcs (>= 1.1.3) - gherkin (~> 2.11.0) - json (>= 1.4.6) - cucumber-rails (1.3.0) + gherkin (~> 2.12) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.0.2) + cucumber-rails (1.4.0) capybara (>= 1.1.2) - cucumber (>= 1.1.8) + cucumber (>= 1.2.0) nokogiri (>= 1.5.0) + rails (>= 3.0.0) daemons (1.1.9) - database_cleaner (0.9.1) - diff-lcs (1.1.3) + database_cleaner (1.2.0) + diff-lcs (1.2.5) + docile (1.1.2) erubis (2.7.0) - eventmachine (1.0.0) - execjs (1.4.0) - multi_json (~> 1.0) - ffi (1.2.0) - flay (2.0.0) - ruby_parser (~> 3.0.0) + eventmachine (1.0.3) + ffi (1.9.3) + flay (2.4.0) + ruby_parser (~> 3.0) sexp_processor (~> 4.0) - gherkin (2.11.5) - json (>= 1.4.6) - highline (1.6.15) - hike (1.2.1) - httparty (0.8.3) - multi_json (~> 1.0) - multi_xml - i18n (0.6.1) - journey (1.0.4) - jquery-rails (2.1.4) + gherkin (2.12.2) + multi_json (~> 1.3) + highline (1.6.20) + hike (1.2.3) + httpclient (2.3.4.1) + i18n (0.6.9) + jquery-rails (3.0.4) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - json (1.7.6) - launchy (2.1.2) + json (1.8.1) + launchy (2.4.2) addressable (~> 2.3) - libwebsocket (0.1.7.1) - addressable - websocket machinist (2.0) - mail (2.4.4) - i18n (>= 0.4.0) + mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.19) - multi_json (1.5.0) - multi_xml (0.5.1) - nokogiri (1.5.5) - pg (0.14.1) + mime-types (1.25.1) + mini_portile (0.5.2) + minitest (4.7.5) + msgpack (0.5.6) + multi_json (1.8.4) + multi_test (0.0.3) + nokogiri (1.6.1) + mini_portile (~> 0.5.0) + pg (0.17.1) polyglot (0.3.3) - progressbar (0.11.0) - rack (1.4.3) - rack-cache (1.2) - rack (>= 0.4) - rack-ssl (1.3.2) - rack + protected_attributes (1.0.3) + activemodel (>= 4.0.0, < 5.0) + rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - rails (3.2.11) - actionmailer (= 3.2.11) - actionpack (= 3.2.11) - activerecord (= 3.2.11) - activeresource (= 3.2.11) - activesupport (= 3.2.11) - bundler (~> 1.0) - railties (= 3.2.11) - rails_best_practices (1.11.1) + rails (4.0.0) + actionmailer (= 4.0.0) + actionpack (= 4.0.0) + activerecord (= 4.0.0) + activesupport (= 4.0.0) + bundler (>= 1.3.0, < 2.0) + railties (= 4.0.0) + sprockets-rails (~> 2.0.0) + rails_best_practices (1.14.4) activesupport awesome_print - code_analyzer + code_analyzer (>= 0.4.3) colored erubis i18n - progressbar - railties (3.2.11) - actionpack (= 3.2.11) - activesupport (= 3.2.11) - rack-ssl (~> 1.3.2) + require_all + ruby-progressbar + railties (4.0.0) + actionpack (= 4.0.0) + activesupport (= 4.0.0) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (10.0.3) - rdoc (3.12) - json (~> 1.4) - rspec (2.11.0) - rspec-core (~> 2.11.0) - rspec-expectations (~> 2.11.0) - rspec-mocks (~> 2.11.0) - rspec-core (2.11.1) - rspec-expectations (2.11.3) - diff-lcs (~> 1.1.3) - rspec-mocks (2.11.2) - rspec-rails (2.11.0) + thor (>= 0.18.1, < 2.0) + rake (10.1.1) + require_all (1.3.2) + rspec-core (2.14.7) + rspec-expectations (2.14.4) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.14.4) + rspec-rails (2.14.1) actionpack (>= 3.0) + activemodel (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec (~> 2.11.0) - ruby_parser (3.0.1) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) + ruby-progressbar (1.4.0) + ruby_parser (3.3.0) sexp_processor (~> 4.1) - rubyzip (0.9.9) - sass (3.2.5) - sass-rails (3.2.5) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) - selenium-webdriver (2.27.2) + rubyzip (1.1.0) + selenium-webdriver (2.39.0) childprocess (>= 0.2.5) - libwebsocket (~> 0.1.3) multi_json (~> 1.0) - rubyzip - sexp_processor (4.1.2) - simplecov (0.7.1) - multi_json (~> 1.0) - simplecov-html (~> 0.7.1) - simplecov-html (0.7.1) - slim (1.3.0) - temple (~> 0.4.1) - tilt (~> 1.3.3) - sprockets (2.2.2) + rubyzip (~> 1.0) + websocket (~> 1.0.4) + sexp_processor (4.4.1) + simplecov (0.8.2) + docile (~> 1.1.0) + multi_json + simplecov-html (~> 0.8.0) + simplecov-html (0.8.0) + slim (2.0.2) + temple (~> 0.6.6) + tilt (>= 1.3.3, < 2.1) + sprockets (2.10.1) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - tddium (1.5.8) + sprockets-rails (2.0.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + tddium (1.16.2) highline json launchy - tddium_client (~> 0.2.0) + msgpack (= 0.5.6) + tddium_client (~> 0.4.2) thor - tddium_client (0.2.0) - httparty (>= 0.8.1) + tddium_client (0.4.3) + httpclient (>= 2.2.5) json - temple (0.4.1) - thin (1.5.0) + temple (0.6.7) + thin (1.6.1) daemons (>= 1.0.9) - eventmachine (>= 0.12.6) + eventmachine (>= 1.0.0) rack (>= 1.0.0) - thor (0.16.0) - tilt (1.3.3) - treetop (1.4.12) + thor (0.18.1) + thread_safe (0.1.3) + atomic + tilt (1.4.1) + treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.35) - uglifier (1.3.0) - execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - websocket (1.0.4) - will_paginate (3.0.4) - xpath (1.0.0) + tzinfo (0.3.38) + websocket (1.0.7) + will_paginate (3.0.5) + xpath (2.0.0) nokogiri (~> 1.3) PLATFORMS @@ -206,7 +189,6 @@ PLATFORMS DEPENDENCIES capybara - coffee-rails (~> 3.2.1) cucumber-rails database_cleaner flay @@ -214,14 +196,13 @@ DEPENDENCIES machinist nokogiri pg - rails (= 3.2.11) + protected_attributes + rails (= 4.0.0) rails_best_practices rspec-rails - sass-rails (~> 3.2.3) selenium-webdriver simplecov slim tddium thin - uglifier (>= 1.0.3) will_paginate diff --git a/config/application.rb b/config/application.rb index 56c089b..65c920f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -4,7 +4,8 @@ require 'rails/all' if defined?(Bundler) # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test))) + #Bundler.require(*Rails.groups(:assets => %w(development test))) + Bundler.require(:default, Rails.env) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end diff --git a/config/environments/development.rb b/config/environments/development.rb index 9c7d19f..fb8cb68 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -7,7 +7,7 @@ Libr::Application.configure do config.cache_classes = false # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + #config.whiny_nils = true # Show full error reports and disable caching config.consider_all_requests_local = true @@ -27,11 +27,14 @@ Libr::Application.configure do # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 + #config.active_record.auto_explain_threshold_in_seconds = 0.5 # Do not compress assets config.assets.compress = false # Expands the lines which load the assets config.assets.debug = true + + config.eager_load = false + end diff --git a/config/environments/production.rb b/config/environments/production.rb index 81ed6f2..68261ae 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -70,4 +70,6 @@ Libr::Application.configure do config.assets.precompile << '*.js' config.assets.precompile << '*.css' + config.eager_load = true + end diff --git a/config/environments/test.rb b/config/environments/test.rb index cd05dd6..057faa6 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,7 +12,7 @@ Libr::Application.configure do config.static_cache_control = "public, max-age=3600" # Log error messages when you accidentally call methods on nil - config.whiny_nils = true + #config.whiny_nils = true # Show full error reports and disable caching config.consider_all_requests_local = true @@ -34,4 +34,7 @@ Libr::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + config.eager_load = false + end diff --git a/config/routes.rb b/config/routes.rb index cc8f7e3..0e6e2a3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,9 +1,9 @@ Libr::Application.routes.draw do root to: 'home#index' - match 'books/new' => 'book#new' - match 'books/:id' => 'book#view' - match '/users/:id/books' => 'user#books' + get 'books/new' => 'book#new' + get 'books/:id' => 'book#view' + get '/users/:id/books' => 'user#books' put '/users/:id/borrowedbooks/:instance_id' => 'user#return_book' post 'books' => 'book#add_to_lib' get 'books' => 'book#list' diff --git a/db/schema.rb b/db/schema.rb index 6eba2b5..aa11639 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,69 +9,72 @@ # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # -# It's strongly recommended to 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 => 20130417050322) do +ActiveRecord::Schema.define(version: 20130417050322) do - create_table "auth_keys", :force => true do |t| + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "auth_keys", force: true do |t| t.integer "user_id" t.string "name" t.string "value" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "actived", :default => false + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "actived", default: false end - create_table "basic_messages", :force => true do |t| + create_table "basic_messages", force: true do |t| t.string "to_user" t.string "from_user" t.datetime "create_time" t.string "message_type" t.string "content" - t.integer "message_id", :limit => 8 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "message_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" t.string "pic_url" end - create_table "book_instances", :force => true do |t| + create_table "book_instances", force: true do |t| t.integer "user_id" t.integer "book_id" - t.boolean "public", :default => true - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.boolean "public", default: true + t.datetime "created_at" + t.datetime "updated_at" end - create_table "books", :force => true do |t| + create_table "books", force: true do |t| t.string "name" t.string "image" t.string "isbn" t.string "author" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" end - create_table "borrow_records", :force => true do |t| + create_table "borrow_records", force: true do |t| t.date "borrow_date" t.date "return_date" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "book_instance_id" t.integer "user_id" end - create_table "user_to_books", :force => true do |t| + create_table "user_to_books", force: true do |t| t.integer "user_id" t.integer "book_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + 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 "email" t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "avatar" t.string "location" t.string "preferred_name"