diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb
new file mode 100644
index 0000000000000000000000000000000000000000..a009ace51ccf46bab4ac06100a225a1fa1801e65
--- /dev/null
+++ b/app/jobs/application_job.rb
@@ -0,0 +1,2 @@
+class ApplicationJob < ActiveJob::Base
+end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
new file mode 100644
index 0000000000000000000000000000000000000000..286b2239d139960190594225e0134fe1a5c05370
--- /dev/null
+++ b/app/mailers/application_mailer.rb
@@ -0,0 +1,4 @@
+class ApplicationMailer < ActionMailer::Base
+  default from: 'from@example.com'
+  layout 'mailer'
+end
diff --git a/app/models/application.rb b/app/models/application.rb
index b3b3e346824b6be7bca87ea54da90e2fda5b56c7..8156eaddb364b9d39901f7c4d8ad79d0e442814f 100644
--- a/app/models/application.rb
+++ b/app/models/application.rb
@@ -1,4 +1,4 @@
-class Application < ActiveRecord::Base
+class Application < ApplicationRecord
   belongs_to :user
 
   validates :domain, presence: true, uniqueness: true
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
new file mode 100644
index 0000000000000000000000000000000000000000..10a4cba84df37181f4cf310fd85d8f0aaa5d90ba
--- /dev/null
+++ b/app/models/application_record.rb
@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+  self.abstract_class = true
+end
diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb
index d49ca0269e01b952814ce0c8de0df78dbac95c4a..df1fc1901295b1397bc0f446464b9f0fa7e47ba9 100644
--- a/app/models/bookmark.rb
+++ b/app/models/bookmark.rb
@@ -10,7 +10,7 @@
 #  updated_at        :datetime         not null
 #
 
-class Bookmark < ActiveRecord::Base
+class Bookmark < ApplicationRecord
   # Example of Trackable:
   # *current_user* create bookmark *bookmarkable*
   include Trackable
diff --git a/app/models/carousel.rb b/app/models/carousel.rb
index e44675b5c95350bc06b265bc90645b9c75812bd9..5959c79b4323867755b23d3d64ba70a57a7a577b 100644
--- a/app/models/carousel.rb
+++ b/app/models/carousel.rb
@@ -13,7 +13,7 @@
 #  image_updated_at   :datetime
 #
 
-class Carousel < ActiveRecord::Base
+class Carousel < ApplicationRecord
   has_attached_file :image, styles: {
     larger: "600x600>",
     thumbnail: "100x100>"
diff --git a/app/models/collection.rb b/app/models/collection.rb
index ae5893b540b25d6c94757bf55d2290c92ff0f126..4d342778492d5663d1d3e9f01e68e03e8b158e75 100644
--- a/app/models/collection.rb
+++ b/app/models/collection.rb
@@ -22,7 +22,7 @@
 #  thumbnail_updated_at   :datetime
 #
 
-class Collection < ActiveRecord::Base
+class Collection < ApplicationRecord
   include Reviewable
   include Sociable
   include Followable
diff --git a/app/models/collection_item.rb b/app/models/collection_item.rb
index 02eedcbe136a7ebce9f84bec02936ab12979d384..3a7241ea0579dd8d444b813acba512ba127795b9 100644
--- a/app/models/collection_item.rb
+++ b/app/models/collection_item.rb
@@ -11,7 +11,7 @@
 #  updated_at          :datetime         not null
 #
 
-class CollectionItem < ActiveRecord::Base
+class CollectionItem < ApplicationRecord
   # *current_user* add item *collectionable* to *collection*
   include Trackable
 
diff --git a/app/models/complaint.rb b/app/models/complaint.rb
index abe53017eedeb87cb3bbdcbf2539d3c4dc441727..9dc2333ece0f936c8a98fa7d248914a42e1bc5d9 100644
--- a/app/models/complaint.rb
+++ b/app/models/complaint.rb
@@ -12,7 +12,7 @@
 #  updated_at          :datetime         not null
 #
 
-class Complaint < ActiveRecord::Base
+class Complaint < ApplicationRecord
   # *current_user* create complaint about *complaint_reason* for *complaintable*
   include Trackable
 
diff --git a/app/models/complaint_reason.rb b/app/models/complaint_reason.rb
index 468f59d301d629ba342ff9b1678b7717b2a6549b..9a94b700587aee6d0f9379be4fe2385b33bad735 100644
--- a/app/models/complaint_reason.rb
+++ b/app/models/complaint_reason.rb
@@ -8,7 +8,7 @@
 #  updated_at :datetime         not null
 #
 
-class ComplaintReason < ActiveRecord::Base
+class ComplaintReason < ApplicationRecord
   # *current_user* create complaint reason
   # Only admins can create complaint reasons
   include Trackable
diff --git a/app/models/download.rb b/app/models/download.rb
index 3435d9bcf3182bf23530c60549dbd0e8c29cbaa7..4b64617e7f6353d90023ff4bbfc71fcd84386261 100644
--- a/app/models/download.rb
+++ b/app/models/download.rb
@@ -10,7 +10,7 @@
 #  updated_at        :datetime         not null
 #
 
-class Download < ActiveRecord::Base
+class Download < ApplicationRecord
   # *current_user* download *downloadable*
   include Trackable
 
diff --git a/app/models/follow.rb b/app/models/follow.rb
index 7c32adc1ba5ba1a449d0e355de90b901e356613e..cbdb5fcfdb46b63deff787fdb1470502ead2b716 100644
--- a/app/models/follow.rb
+++ b/app/models/follow.rb
@@ -10,7 +10,7 @@
 #  updated_at      :datetime         not null
 #
 
-class Follow < ActiveRecord::Base
+class Follow < ApplicationRecord
   # *current_user* follows *followable*
   include Trackable
 
diff --git a/app/models/institution.rb b/app/models/institution.rb
index 5c380822a1db59c0c7f5603403b1581425ceef45..3d04651fd1a6409c97b56093ccc2bd3d4a83788a 100644
--- a/app/models/institution.rb
+++ b/app/models/institution.rb
@@ -12,7 +12,7 @@
 #  updated_at  :datetime         not null
 #
 
-class Institution < ActiveRecord::Base
+class Institution < ApplicationRecord
   include Tagger
 
   # *current_user* add member for instituion *name*
diff --git a/app/models/language.rb b/app/models/language.rb
index b9370bc7df571cd556d97bc011b92f7d6a453fe5..4b91ae32e82980bd0a6bdaae34d2ed78b9e77322 100644
--- a/app/models/language.rb
+++ b/app/models/language.rb
@@ -9,7 +9,7 @@
 #  code       :string
 #
 
-class Language < ActiveRecord::Base
+class Language < ApplicationRecord
   has_many :learning_objects
 
   validates_uniqueness_of :code
diff --git a/app/models/learning_object.rb b/app/models/learning_object.rb
index d2fa453d118d977c34957722ae911815d75fb0fb..d86ea428afb15d3cd417783472b9492a999ef128 100644
--- a/app/models/learning_object.rb
+++ b/app/models/learning_object.rb
@@ -30,7 +30,7 @@
 #  attachment_id          :integer
 #
 
-class LearningObject < ActiveRecord::Base
+class LearningObject < ApplicationRecord
   include Metadatable
   include Reviewable
   include Sociable
diff --git a/app/models/learning_object/attachment.rb b/app/models/learning_object/attachment.rb
index d947f39bbe941f51cfa305ec66df3292a5fec885..532fb009ea680fa9f714877c4dd60f802c9b018f 100644
--- a/app/models/learning_object/attachment.rb
+++ b/app/models/learning_object/attachment.rb
@@ -22,7 +22,7 @@
 #  cache_link             :string
 #
 
-class LearningObject::Attachment < ActiveRecord::Base
+class LearningObject::Attachment < ApplicationRecord
   include ::Thumbnailable
   belongs_to :learning_object
   scope :unknown_mime_type, ->() { where(format: 'Unknown') }
diff --git a/app/models/license.rb b/app/models/license.rb
index 5bc15243c08c0d622808a74920fa68bba4ca0776..fd00603014f00b6fd5376c5ae153b449789be93f 100644
--- a/app/models/license.rb
+++ b/app/models/license.rb
@@ -1,3 +1,3 @@
-class License < ActiveRecord::Base
+class License < ApplicationRecord
   validates :name, presence: true
 end
diff --git a/app/models/like.rb b/app/models/like.rb
index d9e98d20d3b90bf2faff5c0a566ada4d20a90684..10ba05dd5a99971b41694bb9c98532c990234fdc 100644
--- a/app/models/like.rb
+++ b/app/models/like.rb
@@ -10,7 +10,7 @@
 #  updated_at    :datetime         not null
 #
 
-class Like < ActiveRecord::Base
+class Like < ApplicationRecord
   # *current_user* likes *likeable*
   # *current_user* unlikes *likeable*
   include Trackable
diff --git a/app/models/mime_type.rb b/app/models/mime_type.rb
index 6c6baa1acb6a9d75f3d582c7c937fd6342d82393..6de9f904041b2c384cc843d1e34f531b8c0a64bf 100644
--- a/app/models/mime_type.rb
+++ b/app/models/mime_type.rb
@@ -7,6 +7,6 @@
 #  mime_type :string
 #
 
-class MimeType < ActiveRecord::Base
+class MimeType < ApplicationRecord
   has_and_belongs_to_many :object_types
 end
diff --git a/app/models/object_type.rb b/app/models/object_type.rb
index 0aedd137ed47c2fdb9b1b9dbb8a797c498a5bfa0..e652def2c0d4157eff5957cda716eb97b29d5a12 100644
--- a/app/models/object_type.rb
+++ b/app/models/object_type.rb
@@ -1,4 +1,4 @@
-class ObjectType < ActiveRecord::Base
+class ObjectType < ApplicationRecord
   has_many :learning_objects
   has_and_belongs_to_many :mime_types
 
diff --git a/app/models/rate.rb b/app/models/rate.rb
index 5b7a27e6372608dd1d3124d3f8e5adf989fe04c8..7bf069868e9e8c04c60a51b015eabf6ec41fb9f2 100644
--- a/app/models/rate.rb
+++ b/app/models/rate.rb
@@ -8,7 +8,7 @@
 #  review_id  :integer
 #  created_at :datetime         not null
 #  updated_at :datetime         not null
-class Rate < ActiveRecord::Base
+class Rate < ApplicationRecord
   # *current_user* rate a review *review*
   include Trackable
 
diff --git a/app/models/rating.rb b/app/models/rating.rb
index a28b192f5a8b3f440154cbde5ab075df466c7cfd..89bbc66d167cf78632aea63d99099663091c5390 100644
--- a/app/models/rating.rb
+++ b/app/models/rating.rb
@@ -9,7 +9,7 @@
 #  description :string
 #
 
-class Rating < ActiveRecord::Base
+class Rating < ApplicationRecord
   has_many :review_ratings
   has_many :reviews, through: :review_ratings
 end
diff --git a/app/models/review.rb b/app/models/review.rb
index cb8cdb03aa96a1b7f9cab31041cf63cdcce4ba53..3f5b085434e74823159cb49b003f37cf8597387c 100644
--- a/app/models/review.rb
+++ b/app/models/review.rb
@@ -15,7 +15,7 @@
 #  rates_count     :integer          default("0")
 #
 
-class Review < ActiveRecord::Base
+class Review < ApplicationRecord
   # *current_user* review *reviewable*
   include Trackable
 
diff --git a/app/models/review_rating.rb b/app/models/review_rating.rb
index d356332f0e0033a65c59ccf6151924a984044a00..65f4e9f674912e01b6f17ba49b82895d06fc2603 100644
--- a/app/models/review_rating.rb
+++ b/app/models/review_rating.rb
@@ -10,7 +10,7 @@
 #  updated_at :datetime         not null
 #
 
-class ReviewRating < ActiveRecord::Base
+class ReviewRating < ApplicationRecord
   belongs_to :review
   belongs_to :rating
 
diff --git a/app/models/role.rb b/app/models/role.rb
index 52eefd8a80155e4b6905d79c52d41600065dce9f..890aa26750776b84e240a75301073d955d9224a9 100644
--- a/app/models/role.rb
+++ b/app/models/role.rb
@@ -9,7 +9,7 @@
 #  updated_at  :datetime         not null
 #
 
-class Role < ActiveRecord::Base
+class Role < ApplicationRecord
   has_and_belongs_to_many :users
 
   validates_presence_of :name
diff --git a/app/models/score.rb b/app/models/score.rb
index d7e98121091fa868e3ce6b0fb9b39441dc63bb48..c6d7ddea5d604ef4a7cd1f8a8cfb299caf95ddc1 100644
--- a/app/models/score.rb
+++ b/app/models/score.rb
@@ -12,7 +12,7 @@
 #  score_type :string           default("{}"), is an Array
 #
 
-class Score < ActiveRecord::Base
+class Score < ApplicationRecord
   has_many :score_user_categories
   has_many :user_categories, through: :score_user_categories
 
diff --git a/app/models/score_user_category.rb b/app/models/score_user_category.rb
index f249ec23cf02005b4c2c68777e50cd83ab627be0..29eb10b1991b71e87160dd1f311a87b1da3bacf3 100644
--- a/app/models/score_user_category.rb
+++ b/app/models/score_user_category.rb
@@ -10,7 +10,7 @@
 #  updated_at       :datetime         not null
 #
 
-class ScoreUserCategory < ActiveRecord::Base
+class ScoreUserCategory < ApplicationRecord
   belongs_to :score
   belongs_to :user_category
 
diff --git a/app/models/share.rb b/app/models/share.rb
index 4816f94a60291f7f2d42166a8ce70c8bd0a08221..94e3682eff7c55ec011f7547a6255fcb259fb747 100644
--- a/app/models/share.rb
+++ b/app/models/share.rb
@@ -10,7 +10,7 @@
 #  updated_at     :datetime         not null
 #
 
-class Share < ActiveRecord::Base
+class Share < ApplicationRecord
   # *current_user* shares *shareable*
   include Trackable
 
diff --git a/app/models/tag.rb b/app/models/tag.rb
index ed25f592cfd5fa53e046e8519cb2d8692d641e42..d2745a06e1fb23c14e9b036fec7fdaf9bc7958b3 100644
--- a/app/models/tag.rb
+++ b/app/models/tag.rb
@@ -1,4 +1,4 @@
-class Tag < ActiveRecord::Base
+class Tag < ApplicationRecord
   has_many :taggings
   validates_presence_of :name
 end
diff --git a/app/models/tagging.rb b/app/models/tagging.rb
index d926c6db5500dfe223cf7643c3b13915166c0d25..613a8e9c29cca3346afa774f3f3f0c603a0b15e4 100644
--- a/app/models/tagging.rb
+++ b/app/models/tagging.rb
@@ -1,4 +1,4 @@
-class Tagging < ActiveRecord::Base
+class Tagging < ApplicationRecord
   # *current_user* tag *taggable* with *tag*
   include Trackable
 
diff --git a/app/models/user.rb b/app/models/user.rb
index ecfd182636edbbb67ccb4da6b24f65aa3a6e85f7..9147299a8d087cfc4ceda98b1edd12582a5b993d 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -33,7 +33,7 @@
 #  follows_count          :integer          default("0")
 #
 
-class User < ActiveRecord::Base
+class User < ApplicationRecord
   include Followable
   include Reputationable
   include Tagger
diff --git a/app/models/user_category.rb b/app/models/user_category.rb
index d4603f14fb70376f16fff61bcb8f29834a7e7254..bf0567cbb0cfd443d7a8c4f5b47e877c7ae23ca3 100644
--- a/app/models/user_category.rb
+++ b/app/models/user_category.rb
@@ -9,7 +9,7 @@
 #  updated_at :datetime         not null
 #
 
-class UserCategory < ActiveRecord::Base
+class UserCategory < ApplicationRecord
   has_many :score_user_categories
   has_many :scores, through: :score_user_categories
 
diff --git a/app/models/view.rb b/app/models/view.rb
index 94f27f19e255fa086dc2f5ade9e92f851e2d7ec2..3f80ab25bce2eeb4a6e4d7936036aca8dc7733c8 100644
--- a/app/models/view.rb
+++ b/app/models/view.rb
@@ -10,7 +10,7 @@
 #  updated_at    :datetime         not null
 #
 
-class View < ActiveRecord::Base
+class View < ApplicationRecord
   # *current_user* views *viewable*
   include Trackable
 
diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb
new file mode 100644
index 0000000000000000000000000000000000000000..91431f1204ab4701949186f5afe46e0633af2bcf
--- /dev/null
+++ b/app/views/layouts/mailer.html.erb
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <style>/* Email styles need to be inline */</style>
+  </head>
+  <body><%= yield %></body>
+</html>
diff --git a/bin/rails b/bin/rails
index 0138d79b751b9668a1036329a9ef29a213836162..073966023774750c90fe9c89910c769a92da604b 100755
--- a/bin/rails
+++ b/bin/rails
@@ -1,9 +1,4 @@
 #!/usr/bin/env ruby
-begin
-  load File.expand_path('../spring', __FILE__)
-rescue LoadError => e
-  raise unless e.message.include?('spring')
-end
-APP_PATH = File.expand_path('../../config/application', __FILE__)
+APP_PATH = File.expand_path('../config/application', __dir__)
 require_relative '../config/boot'
 require 'rails/commands'
diff --git a/bin/rake b/bin/rake
index d87d5f578104597c1d1b951b55942e37f8af1277..17240489f64832c9ce080088e27780d3dc3ee29a 100755
--- a/bin/rake
+++ b/bin/rake
@@ -1,9 +1,4 @@
 #!/usr/bin/env ruby
-begin
-  load File.expand_path('../spring', __FILE__)
-rescue LoadError => e
-  raise unless e.message.include?('spring')
-end
 require_relative '../config/boot'
 require 'rake'
 Rake.application.run
diff --git a/bin/setup b/bin/setup
index c54141a04c2dfe0f92be58fc8ab9d9def2e23995..ca5ca8bdf819a065ce71729fc30e20c3e958e505 100755
--- a/bin/setup
+++ b/bin/setup
@@ -1,30 +1,34 @@
 #!/usr/bin/env ruby
 require 'pathname'
+require 'fileutils'
+include FileUtils
 
 # path to your application root.
-APP_ROOT = Pathname.new File.expand_path('../../',  __FILE__)
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
 
-Dir.chdir APP_ROOT do
+def system!(*args)
+  system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
   # This script is a starting point to setup your application.
-  # Add necessary setup steps to this file:
+  # Add necessary setup steps to this file.
 
-  puts "== Installing dependencies =="
-  system "gem install bundler --conservative"
-  system "bundle check || bundle install --jobs $(nproc)"
+  puts '== Installing dependencies =='
+  system! 'gem install bundler --conservative'
+  system('bundle check') || system!('bundle install')
 
-  puts "\n== Checks database config file =="
-  unless File.exist?("config/database.yml")
-    puts "\n You need create config/database.yml. Please follow our README"
-    exit
-  end
+  # puts "\n== Copying sample files =="
+  # unless File.exist?('config/database.yml')
+  #   cp 'config/database.yml.sample', 'config/database.yml'
+  # end
 
-  puts "\n== Preparing databases, importing data and setup PortalMEC =="
-  system "bundle exec rake portalmec:setup"
+  puts "\n== Preparing database =="
+  system! 'bundle exec rake portalmec:setup'
 
   puts "\n== Removing old logs and tempfiles =="
-  system "rm -f log/*"
-  system "rm -rf tmp/cache"
+  system! 'bin/rails log:clear tmp:clear'
 
   puts "\n== Restarting application server =="
-  system "touch tmp/restart.txt"
+  system! 'bin/rails restart'
 end
diff --git a/bin/update b/bin/update
new file mode 100755
index 0000000000000000000000000000000000000000..a8e4462f20340b73db6df04da3a3fa0dd842713f
--- /dev/null
+++ b/bin/update
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+  system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+  # This script is a way to update your development environment automatically.
+  # Add necessary update steps to this file.
+
+  puts '== Installing dependencies =='
+  system! 'gem install bundler --conservative'
+  system('bundle check') || system!('bundle install')
+
+  puts "\n== Updating database =="
+  system! 'bin/rails db:migrate'
+
+  puts "\n== Removing old logs and tempfiles =="
+  system! 'bin/rails log:clear tmp:clear'
+
+  puts "\n== Restarting application server =="
+  system! 'bin/rails restart'
+end
diff --git a/config/application.rb b/config/application.rb
index 5226631d44df2a8d63374357475e50df7d1ad3ef..dde53ed5d8bd8e0283ad3d0cf49caa261244cc4a 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,9 +1,14 @@
-require File.expand_path('../boot', __FILE__)
+require_relative 'boot'
 
-# require 'rails/all'
+require 'rails'
+require 'active_model/railtie'
+# require 'active_job/railtie'
 require 'active_record/railtie'
 require 'action_controller/railtie'
 require 'action_mailer/railtie'
+require 'action_view/railtie'
+# require 'action_cable/engine'
+# require 'sprockets/railtie'
 require 'rails/test_unit/railtie'
 require 'rack/redis_throttle'
 
diff --git a/config/boot.rb b/config/boot.rb
index 6b750f00b1dff4d94937b97ae0dbf76784b02164..30f5120df6986349c532c8ece3c170726118a703 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,3 +1,3 @@
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
 
 require 'bundler/setup' # Set up gems listed in the Gemfile.
diff --git a/config/cable.yml b/config/cable.yml
new file mode 100644
index 0000000000000000000000000000000000000000..0bbde6f74fe1216e2e76c2cac2e8a5901b2107b0
--- /dev/null
+++ b/config/cable.yml
@@ -0,0 +1,9 @@
+development:
+  adapter: async
+
+test:
+  adapter: async
+
+production:
+  adapter: redis
+  url: redis://localhost:6379/1
diff --git a/config/database.yml b/config/database.yml
index b398a1ba4ecef08c6c798f4e4ef2047709f743d6..d369a1d5c1950478ed0a3d7612438ec906a2e762 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -15,7 +15,7 @@ test:
   database: portalmec_test
   username: portalmec
   password: 123mudar
-  host: postgres
+  # host: postgres
 
 production:
   <<: *defaults
diff --git a/config/environment.rb b/config/environment.rb
index ee8d90dc651948269f1b869953ff04774e737307..426333bb46978d897be4cc6fac77b9fcaacf59d0 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,5 +1,5 @@
 # Load the Rails application.
-require File.expand_path('../application', __FILE__)
+require_relative 'application'
 
 # Initialize the Rails application.
 Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 987efaf25f29e895293756ea1e7bc3c1703b2bad..38cf023ef20145b6d690e226aaeec9e84ddee984 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -21,32 +21,55 @@ Rails.application.configure do
   # 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
 
+  config.action_mailer.perform_caching = false
+
   # Print deprecation notices to the Rails logger.
   config.active_support.deprecation = :log
 
   # Raise an error on page load if there are pending migrations.
   config.active_record.migration_error = :page_load
 
+
+  # 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
+
   # 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 = true
 
   # 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.
-  config.assets.digest = true
+  # config.assets.digest = true
 
   # Adds additional error checking when serving assets at runtime.
   # Checks for improperly declared sprockets dependencies.
   # Raises helpful error messages.
-  config.assets.raise_runtime_errors = true
+  # config.assets.raise_runtime_errors = true
 
   # Raises error for missing translations
   # config.action_view.raise_on_missing_translations = true
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 8aa3f99704008ff519c6803a5cfec7f8e0d6cace..25fb84be81036125a093ed3bedf35da1a726d446 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -14,33 +14,23 @@ Rails.application.configure do
   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?
-
-  # Compress JavaScripts and CSS.
-  config.assets.js_compressor = :uglifier
-  # config.assets.css_compressor = :sass
-
-  # Do not fallback to assets pipeline if a precompiled asset is missed.
-  config.assets.compile = true
+  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
 
-  # 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.
-  config.assets.digest = true
 
-  # `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
 
+  # Mount Action Cable outside main process or domain
+  # config.action_cable.mount_path = nil
+  # 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
 
@@ -49,32 +39,19 @@ Rails.application.configure do
   config.log_level = :debug
 
   # Prepend all log lines with the following tags.
-  # config.log_tags = [ :subdomain, :uuid ]
-
-  # Use a different logger for distributed setups.
-  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
+  config.log_tags = [ :request_id ]
 
   # Use a different cache store in production.
   # config.cache_store = :mem_cache_store
-  # memcached server specified in ENV["MEMCACHE_SERVERS"]
-  config.cache_store = :dalli_store, nil, { :namespace => 'portalmec', :expires_in => 1.day, :compress => true, :pool_size => 5 }
 
-  # 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 = "portalmec_#{Rails.env}"
+  config.action_mailer.perform_caching = false
 
   # 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.
   # config.action_mailer.raise_delivery_errors = false
-  config.action_mailer.default_url_options = { host: ENV['ACTION_MAILER_HOST'] }
-
-  config.action_mailer.delivery_method = :smtp
-  config.action_mailer.smtp_settings = {
-      address: ENV['SMTP_ADDRESS'],
-      port: ENV['SMTP_PORT'],
-      openssl_verify_mode: 'none',
-      domain: ENV['ACTION_MAILER_HOST']
-  }
-
 
   # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
   # the I18n.default_locale when a translation cannot be found).
@@ -86,6 +63,31 @@ Rails.application.configure do
   # Use default logging formatter so that PID and timestamp are not suppressed.
   config.log_formatter = ::Logger::Formatter.new
 
+  # Use a different logger for distributed setups.
+  # require 'syslog/logger'
+  # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
+
+  if ENV["RAILS_LOG_TO_STDOUT"].present?
+    logger           = ActiveSupport::Logger.new(STDOUT)
+    logger.formatter = config.log_formatter
+    config.logger = ActiveSupport::TaggedLogging.new(logger)
+  end
+
   # Do not dump schema after migrations.
   config.active_record.dump_schema_after_migration = false
+
+  config.cache_store = :dalli_store, nil, { :namespace => 'portalmec', :expires_in => 1.day, :compress => true, :pool_size => 5 }
+
+  # 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.
+  # config.action_mailer.raise_delivery_errors = false
+  config.action_mailer.default_url_options = { host: ENV['ACTION_MAILER_HOST'] }
+
+  config.action_mailer.delivery_method = :smtp
+  config.action_mailer.smtp_settings = {
+      address: ENV['SMTP_ADDRESS'],
+      port: ENV['SMTP_PORT'],
+      openssl_verify_mode: 'none',
+      domain: ENV['ACTION_MAILER_HOST']
+  }
 end
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 1c19f08b28341c59bd4cfe1834e29f877e5fc22e..6e619ea8168311437d6fa9c2f450bdbce1c0b13d 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -14,7 +14,10 @@ Rails.application.configure do
 
   # Configure static file server for tests with Cache-Control for performance.
   config.serve_static_files   = true
-  config.static_cache_control = 'public, max-age=3600'
+  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/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb
new file mode 100644
index 0000000000000000000000000000000000000000..51639b67a00ddba973a92d59ec277f5d97b63ef6
--- /dev/null
+++ b/config/initializers/application_controller_renderer.rb
@@ -0,0 +1,6 @@
+# Be sure to restart your server when you modify this file.
+
+# ApplicationController.renderer.defaults.merge!(
+#   http_host: 'example.org',
+#   https: false
+# )
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
new file mode 100644
index 0000000000000000000000000000000000000000..ff2d2299abf9395fec6df2f5dd32c546e2b7c149
--- /dev/null
+++ b/config/initializers/assets.rb
@@ -0,0 +1,11 @@
+# Be sure to restart your server when you modify this file.
+
+# Version of your assets, change this if you want to expire all your assets.
+# Rails.application.config.assets.version = '1.0'
+
+# Add additional assets to the asset load path
+# Rails.application.config.assets.paths << Emoji.images_path
+
+# Precompile additional assets.
+# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
+# Rails.application.config.assets.precompile += %w( search.js )
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb
new file mode 100644
index 0000000000000000000000000000000000000000..1389e86a34a7e992b8761b4b2b9b789b5647a406
--- /dev/null
+++ b/config/initializers/cookies_serializer.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Specify a serializer for the signed and encrypted cookie jars.
+# Valid options are :json, :marshal, and :hybrid.
+Rails.application.config.action_dispatch.cookies_serializer = :marshal
diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb
new file mode 100644
index 0000000000000000000000000000000000000000..9c24995941304ae513f4c1a8e74037cd54eb5030
--- /dev/null
+++ b/config/initializers/new_framework_defaults.rb
@@ -0,0 +1,17 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains migration options to ease your Rails 5.0 upgrade.
+#
+# Once upgraded flip defaults one by one to migrate to the new default.
+#
+# Read the Rails 5.0 release notes for more info on each option.
+
+# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
+# Previous versions had false.
+ActiveSupport.to_time_preserves_timezone = false
+
+# Require `belongs_to` associations by default. Previous versions had false.
+Rails.application.config.active_record.belongs_to_required_by_default = false
+
+# Do not halt callback chains when a callback returns false. Previous versions had true.
+ActiveSupport.halt_callback_chains_on_return_false = true
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
index 33725e95fd22b9053f75ef6626aa1af781ebe947..bbfc3961bffef15dabb35fe0de4c409d6efb58c5 100644
--- a/config/initializers/wrap_parameters.rb
+++ b/config/initializers/wrap_parameters.rb
@@ -5,10 +5,10 @@
 
 # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
 ActiveSupport.on_load(:action_controller) do
-  wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
+  wrap_parameters format: [:json]
 end
 
 # To enable root element in JSON for ActiveRecord objects.
 # ActiveSupport.on_load(:active_record) do
-#  self.include_root_in_json = true
+#   self.include_root_in_json = true
 # end
diff --git a/config/puma.rb b/config/puma.rb
index 0e238cb77435c535865667b859eab3d67ecefc3e..f4d68e83b504561802ce45097477d7998800fcd3 100644
--- a/config/puma.rb
+++ b/config/puma.rb
@@ -1,15 +1,53 @@
-# Change to match your CPU core count
-workers 2
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum, this matches the default thread size of Active Record.
+#
+threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
+threads threads_count, threads_count
 
-# Min and Max threads per worker
-threads 1, 6
+# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
+#
+port        ENV.fetch('PORT') { 3000 }
 
-app_dir = File.expand_path("../..", __FILE__)
-shared_dir = "#{app_dir}/shared"
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch('RAILS_ENV') { 'development' }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked webserver processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+workers ENV.fetch('WEB_CONCURRENCY') { 2 }
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory. If you use this option
+# you need to make sure to reconnect any threads in the `on_worker_boot`
+# block.
+#
+preload_app!
+
+# The code in the `on_worker_boot` will be called if you are using
+# clustered mode by specifying a number of `workers`. After each worker
+# process is booted this block will be run, if you are using `preload_app!`
+# option you will want to use this block to reconnect to any threads
+# or connections that may have been created at application boot, Ruby
+# cannot share connections between processes.
+#
+on_worker_boot do
+  ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
+end
 
-# Default to production
-rails_env = ENV['RAILS_ENV'] || "production"
-environment rails_env
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
+
+app_dir = File.expand_path('../..', __FILE__)
+shared_dir = "#{app_dir}/shared"
 
 # Set up socket location
 bind "unix://#{shared_dir}/sockets/puma.sock"
@@ -23,9 +61,3 @@ end
 pidfile "#{shared_dir}/pids/puma.pid"
 state_path "#{shared_dir}/pids/puma.state"
 activate_control_app
-
-on_worker_boot do
-  require "active_record"
-  ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
-  ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env])
-end
diff --git a/config/routes.rb b/config/routes.rb
index 4b045a9eb95bb5f4d2c8d84a188b34fb7ff89cd8..797ca0bffc62e4895c9f435edd599e87869e65f6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,6 +1,6 @@
 Rails.application.routes.draw do
-  require 'sidekiq/web'
-  mount Sidekiq::Web, at: '/sidekiq'
+  # require 'sidekiq/web'
+  # mount Sidekiq::Web, at: '/sidekiq'
 
   concern :deletable do
     collection do
diff --git a/config/spring.rb b/config/spring.rb
new file mode 100644
index 0000000000000000000000000000000000000000..c9119b40c08eff8aef2d607f5bf42424483cbd15
--- /dev/null
+++ b/config/spring.rb
@@ -0,0 +1,6 @@
+%w(
+  .ruby-version
+  .rbenv-vars
+  tmp/restart.txt
+  tmp/caching-dev.txt
+).each { |path| Spring.watch(path) }