diff --git a/.gitignore b/.gitignore
index 050c9d9..710f92d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@
# Ignore bundler config.
/.bundle
+/.ruby-version
# Ignore the default SQLite database.
/db/*.sqlite3
diff --git a/Gemfile b/Gemfile
index 7c08a04..71e18a4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,17 +1,21 @@
source 'https://rubygems.org'
-gem 'rails', '~> 4.2.0'
+gem 'rails', '~> 5.0.0'
+gem 'coffee-script'
+gem 'jbuilder'
+gem 'jquery-rails'
gem 'sass-rails'
gem 'uglifier'
-gem 'coffee-rails'
-gem 'jquery-rails'
-gem 'jbuilder'
gem 'activerecord-sqlserver-adapter'
gem 'tiny_tds'
+group :development do
+ gem 'better_errors'
+ gem 'web-console', github: 'rails/web-console'
+end
+
group :development, :test do
gem 'byebug'
- gem 'web-console', '~> 2.0'
gem 'spring'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 39f13d8..4084702 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,51 +1,63 @@
+GIT
+ remote: git://github.com/rails/web-console.git
+ revision: 8753a1056c62da296fb0062d3bdb99f4a83d3631
+ specs:
+ web-console (3.4.0)
+ actionview (>= 5.0)
+ activemodel (>= 5.0)
+ debug_inspector
+ railties (>= 5.0)
+
GEM
remote: https://rubygems.org/
specs:
- actionmailer (4.2.7.1)
- actionpack (= 4.2.7.1)
- actionview (= 4.2.7.1)
- activejob (= 4.2.7.1)
+ actioncable (5.0.1)
+ actionpack (= 5.0.1)
+ nio4r (~> 1.2)
+ websocket-driver (~> 0.6.1)
+ actionmailer (5.0.1)
+ actionpack (= 5.0.1)
+ actionview (= 5.0.1)
+ activejob (= 5.0.1)
mail (~> 2.5, >= 2.5.4)
- rails-dom-testing (~> 1.0, >= 1.0.5)
- actionpack (4.2.7.1)
- actionview (= 4.2.7.1)
- activesupport (= 4.2.7.1)
- rack (~> 1.6)
- rack-test (~> 0.6.2)
- rails-dom-testing (~> 1.0, >= 1.0.5)
+ rails-dom-testing (~> 2.0)
+ actionpack (5.0.1)
+ actionview (= 5.0.1)
+ activesupport (= 5.0.1)
+ rack (~> 2.0)
+ rack-test (~> 0.6.3)
+ rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
- actionview (4.2.7.1)
- activesupport (= 4.2.7.1)
+ actionview (5.0.1)
+ activesupport (= 5.0.1)
builder (~> 3.1)
erubis (~> 2.7.0)
- rails-dom-testing (~> 1.0, >= 1.0.5)
+ rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
- activejob (4.2.7.1)
- activesupport (= 4.2.7.1)
- globalid (>= 0.3.0)
- activemodel (4.2.7.1)
- activesupport (= 4.2.7.1)
- builder (~> 3.1)
- activerecord (4.2.7.1)
- activemodel (= 4.2.7.1)
- activesupport (= 4.2.7.1)
- arel (~> 6.0)
- activerecord-sqlserver-adapter (4.2.16)
- activerecord (~> 4.2.1)
- activesupport (4.2.7.1)
+ activejob (5.0.1)
+ activesupport (= 5.0.1)
+ globalid (>= 0.3.6)
+ activemodel (5.0.1)
+ activesupport (= 5.0.1)
+ activerecord (5.0.1)
+ activemodel (= 5.0.1)
+ activesupport (= 5.0.1)
+ arel (~> 7.0)
+ activerecord-sqlserver-adapter (5.0.1)
+ activerecord (~> 5.0.0)
+ activesupport (5.0.1)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
- json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
- thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
- arel (6.0.4)
- binding_of_caller (0.7.2)
- debug_inspector (>= 0.0.1)
+ arel (7.1.4)
+ better_errors (2.1.1)
+ coderay (>= 1.0.0)
+ erubis (>= 2.6.6)
+ rack (>= 0.9.0)
builder (3.2.3)
byebug (9.0.6)
- coffee-rails (4.2.1)
- coffee-script (>= 2.2.0)
- railties (>= 4.0.0, < 5.2.x)
+ coderay (1.1.1)
coffee-script (2.4.1)
coffee-script-source
execjs
@@ -64,44 +76,44 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
- json (1.8.6)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
+ method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
+ nio4r (1.2.1)
nokogiri (1.7.0.1)
mini_portile2 (~> 2.1.0)
- rack (1.6.5)
+ rack (2.0.1)
rack-test (0.6.3)
rack (>= 1.0)
- rails (4.2.7.1)
- actionmailer (= 4.2.7.1)
- actionpack (= 4.2.7.1)
- actionview (= 4.2.7.1)
- activejob (= 4.2.7.1)
- activemodel (= 4.2.7.1)
- activerecord (= 4.2.7.1)
- activesupport (= 4.2.7.1)
+ rails (5.0.1)
+ actioncable (= 5.0.1)
+ actionmailer (= 5.0.1)
+ actionpack (= 5.0.1)
+ actionview (= 5.0.1)
+ activejob (= 5.0.1)
+ activemodel (= 5.0.1)
+ activerecord (= 5.0.1)
+ activesupport (= 5.0.1)
bundler (>= 1.3.0, < 2.0)
- railties (= 4.2.7.1)
- sprockets-rails
- rails-deprecated_sanitizer (1.0.3)
- activesupport (>= 4.2.0.alpha)
- rails-dom-testing (1.0.8)
- activesupport (>= 4.2.0.beta, < 5.0)
+ railties (= 5.0.1)
+ sprockets-rails (>= 2.0.0)
+ rails-dom-testing (2.0.2)
+ activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6)
- rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
- railties (4.2.7.1)
- actionpack (= 4.2.7.1)
- activesupport (= 4.2.7.1)
+ railties (5.0.1)
+ actionpack (= 5.0.1)
+ activesupport (= 5.0.1)
+ method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
@@ -130,27 +142,26 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.4)
execjs (>= 0.3.0, < 3)
- web-console (2.3.0)
- activemodel (>= 4.0)
- binding_of_caller (>= 0.7.2)
- railties (>= 4.0)
- sprockets-rails (>= 2.0, < 4.0)
+ websocket-driver (0.6.5)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.2)
PLATFORMS
ruby
DEPENDENCIES
activerecord-sqlserver-adapter
+ better_errors
byebug
- coffee-rails
+ coffee-script
jbuilder
jquery-rails
- rails (~> 4.2.0)
+ rails (~> 5.0.0)
sass-rails
spring
tiny_tds
uglifier
- web-console (~> 2.0)
+ web-console!
BUNDLED WITH
1.13.6
diff --git a/README.md b/README.md
index 352ae44..0a14eb1 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,12 @@ Now create the DB and setup the app.
```shell
$ bundle install
-$ ./bin/rake db:setup
+$ ./bin/rails db:setup
+```
+
+We can also drop
+
+```shell
+$ ./bin/rails db:drop:all
```
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index d83690e..b97ed57 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,5 +1,11 @@
class ApplicationController < ActionController::Base
- # Prevent CSRF attacks by raising an exception.
- # For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
+
+ def index
+ User.first
+ User.last
+ Person.first
+ Person.last
+ render html: '
Test
'.html_safe
+ end
end
diff --git a/app/models/person.rb b/app/models/person.rb
new file mode 100644
index 0000000..2f2e286
--- /dev/null
+++ b/app/models/person.rb
@@ -0,0 +1,2 @@
+class Person < ActiveRecord::Base
+end
diff --git a/config/application.rb b/config/application.rb
index b77d41f..3c18f4d 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -11,19 +11,5 @@ class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
-
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
- # config.time_zone = 'Central Time (US & Canada)'
-
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
- # config.i18n.default_locale = :de
-
- # Do not swallow errors in after_commit/after_rollback callbacks.
- config.active_record.raise_in_transactional_callbacks = true
-
- config.active_record.schema_format = :sql
-
end
end
diff --git a/config/environments/development.rb b/config/environments/development.rb
index b55e214..844f9dd 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -9,9 +9,20 @@
# Do not eager load code on boot.
config.eager_load = false
- # Show full error reports and disable caching.
- config.consider_all_requests_local = true
- config.action_controller.perform_caching = false
+ # Show full error reports.
+ config.consider_all_requests_local = true
+
+ # Enable/disable caching. By default caching is disabled.
+ if Rails.root.join('tmp/caching-dev.txt').exist?
+ config.action_controller.perform_caching = true
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ 'Cache-Control' => 'public, max-age=172800'
+ }
+ else
+ config.action_controller.perform_caching = false
+ config.cache_store = :null_store
+ end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
@@ -25,7 +36,7 @@
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
- config.assets.debug = true
+ config.assets.debug = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
@@ -38,4 +49,11 @@
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
+
+ # Use an evented file watcher to asynchronously detect changes in source code,
+ # routes, locales, etc. This feature depends on the listen gem.
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+
+ # OUR APP
+ config.log_level = :debug
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 5c1b32e..36663e3 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -14,15 +14,9 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
- # Enable Rack::Cache to put a simple HTTP cache in front of your application
- # Add `rack-cache` to your Gemfile before enabling this.
- # For large-scale production use, consider using a caching reverse proxy like
- # NGINX, varnish or squid.
- # config.action_dispatch.rack_cache = true
-
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
- config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
@@ -37,28 +31,37 @@
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.action_controller.asset_host = 'http://assets.example.com'
+
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+ # Action Cable endpoint configuration
+ # config.action_cable.url = 'wss://example.com/cable'
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
- config.log_level = :debug
+ # config.log_level = :debug
# Prepend all log lines with the following tags.
- # config.log_tags = [ :subdomain, :uuid ]
+ config.log_tags = [:request_id]
# Use a different logger for distributed setups.
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
+ # require 'syslog/logger'
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
- # config.action_controller.asset_host = 'http://assets.example.com'
+ # Use a real queuing backend for Active Job (and separate queues per environment)
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "cachetest2_#{Rails.env}"
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 1c19f08..1f90453 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -12,9 +12,11 @@
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
- # Configure static file server for tests with Cache-Control for performance.
- config.serve_static_files = true
- config.static_cache_control = 'public, max-age=3600'
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ 'Cache-Control' => 'public, max-age=3600'
+ }
# Show full error reports and disable caching.
config.consider_all_requests_local = true
diff --git a/config/routes.rb b/config/routes.rb
index 3f66539..29d55a9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,56 +1,3 @@
Rails.application.routes.draw do
- # The priority is based upon order of creation: first created -> highest priority.
- # See how all your routes lay out with "rake routes".
-
- # You can have the root of your site routed with "root"
- # root 'welcome#index'
-
- # Example of regular route:
- # get 'products/:id' => 'catalog#view'
-
- # Example of named route that can be invoked with purchase_url(id: product.id)
- # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
-
- # Example resource route (maps HTTP verbs to controller actions automatically):
- # resources :products
-
- # Example resource route with options:
- # resources :products do
- # member do
- # get 'short'
- # post 'toggle'
- # end
- #
- # collection do
- # get 'sold'
- # end
- # end
-
- # Example resource route with sub-resources:
- # resources :products do
- # resources :comments, :sales
- # resource :seller
- # end
-
- # Example resource route with more complex sub-resources:
- # resources :products do
- # resources :comments
- # resources :sales do
- # get 'recent', on: :collection
- # end
- # end
-
- # Example resource route with concerns:
- # concern :toggleable do
- # post 'toggle'
- # end
- # resources :posts, concerns: :toggleable
- # resources :photos, concerns: :toggleable
-
- # Example resource route within a namespace:
- # namespace :admin do
- # # Directs /admin/products/* to Admin::ProductsController
- # # (app/controllers/admin/products_controller.rb)
- # resources :products
- # end
+ root 'application#index'
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 4edb1e8..3194439 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,7 +1,20 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
-#
-# Examples:
-#
-# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
-# Mayor.create(name: 'Emanuel', city: cities.first)
+
+@con = ActiveRecord::Base.connection
+
+@con.execute "IF EXISTS (
+ SELECT TABLE_NAME
+ FROM INFORMATION_SCHEMA.VIEWS
+ WHERE TABLE_NAME = 'people'
+) DROP VIEW people"
+
+@con.execute <<-SQL
+ CREATE VIEW people AS
+ SELECT id, name, email
+ FROM users
+SQL
+
+100.times do |n|
+ User.create name: "User #{n}", email: "user#{n}@example.com"
+end
diff --git a/db/structure.sql b/db/structure.sql
deleted file mode 100644
index ddc454c..0000000
--- a/db/structure.sql
+++ /dev/null
@@ -1,25 +0,0 @@
- /* No constraints are defined on object 'dbo.schema_migrations', or you do not have permissions. */
- /* No foreign keys reference table 'dbo.schema_migrations', or you do not have permissions on referencing tables. */
- /* No views with schema binding reference table 'dbo.schema_migrations'. */
-
-CREATE TABLE dbo.schema_migrations
- ( version nvarchar(4000) NOT NULL
- )
-
-CREATE unique nonclustered INDEX unique_schema_migrations on dbo.schema_migrations(version)
-
- /* No foreign keys reference table 'dbo.users', or you do not have permissions on referencing tables. */
- /* No views with schema binding reference table 'dbo.users'. */
-
-CREATE TABLE dbo.users
- ( id int NOT NULL
- , email nvarchar(4000) NULL
- , name nvarchar(4000) NULL
- , created_at datetime NOT NULL
- , updated_at datetime NOT NULL
- )
-
-ALTER TABLE dbo.users ADD CONSTRAINT PK__users__3213E83FC2BE8309 PRIMARY KEY clustered (id)
-
-INSERT INTO schema_migrations (version) VALUES ('20150202011847');
-