From 819f47b450d729377d169fc8c8028a5b98051542 Mon Sep 17 00:00:00 2001 From: zmagod Date: Fri, 23 Jun 2017 15:19:08 +0200 Subject: [PATCH] setup sciNote for Rails 5.1 --- Gemfile | 3 +- Gemfile.lock | 16 ++++- {public => app/assets}/images/favicon-16.png | Bin {public => app/assets}/images/favicon-32.png | Bin {public => app/assets}/images/favicon-48.png | Bin {public => app/assets}/images/favicon.ico | Bin app/controllers/application_controller.rb | 2 +- app/models/activity.rb | 2 +- app/models/application_record.rb | 3 + app/models/asset.rb | 2 +- app/models/asset_text_datum.rb | 2 +- app/models/checklist.rb | 2 +- app/models/checklist_item.rb | 2 +- app/models/comment.rb | 2 +- app/models/connection.rb | 2 +- app/models/custom_field.rb | 2 +- app/models/experiment.rb | 2 +- app/models/my_module.rb | 2 +- app/models/my_module_group.rb | 2 +- app/models/my_module_repository_row.rb | 2 +- app/models/my_module_tag.rb | 2 +- app/models/notification.rb | 2 +- app/models/project.rb | 2 +- app/models/protocol.rb | 2 +- app/models/protocol_keyword.rb | 2 +- app/models/protocol_protocol_keyword.rb | 4 +- app/models/report.rb | 2 +- app/models/report_element.rb | 2 +- app/models/repository.rb | 2 +- app/models/repository_cell.rb | 2 +- app/models/repository_column.rb | 2 +- app/models/repository_date_value.rb | 2 +- app/models/repository_row.rb | 2 +- app/models/repository_table_state.rb | 2 +- app/models/repository_text_value.rb | 2 +- app/models/result.rb | 2 +- app/models/result_asset.rb | 2 +- app/models/result_table.rb | 2 +- app/models/result_text.rb | 2 +- app/models/sample.rb | 2 +- app/models/sample_custom_field.rb | 2 +- app/models/sample_group.rb | 2 +- app/models/sample_my_module.rb | 2 +- app/models/sample_type.rb | 2 +- app/models/samples_table.rb | 2 +- app/models/settings.rb | 2 +- app/models/step.rb | 2 +- app/models/step_asset.rb | 2 +- app/models/step_table.rb | 2 +- app/models/table.rb | 2 +- app/models/tag.rb | 2 +- app/models/team.rb | 2 +- app/models/temp_file.rb | 2 +- app/models/tiny_mce_asset.rb | 2 +- app/models/token.rb | 4 +- app/models/user.rb | 2 +- app/models/user_my_module.rb | 2 +- app/models/user_notification.rb | 2 +- app/models/user_project.rb | 2 +- app/models/user_team.rb | 2 +- app/models/wopi_action.rb | 2 +- app/models/wopi_app.rb | 2 +- app/models/wopi_discovery.rb | 2 +- app/models/zip_export.rb | 2 +- bin/bundle | 2 +- bin/delayed_job | 0 bin/rails | 4 +- bin/rake | 2 +- bin/setup | 35 +++++++---- bin/update | 29 +++++++++ bin/yarn | 11 ++++ config/application.rb | 15 ++--- config/boot.rb | 2 +- config/cable.yml | 10 +++ config/environment.rb | 2 +- config/environments/development.rb | 23 +++++++ config/environments/production.rb | 44 +++++++++++++- config/environments/test.rb | 6 ++ .../application_controller_renderer.rb | 6 ++ config/initializers/assets.rb | 10 ++- config/initializers/cookies_serializer.rb | 2 + config/initializers/devise_async.rb | 2 +- .../new_framework_defaults_5_1.rb | 14 +++++ config/initializers/wrap_parameters.rb | 4 +- config/locales/en.yml | 4 +- config/puma.rb | 57 ++++++++++++++++++ config/secrets.yml | 23 ++++++- config/spring.rb | 6 ++ 88 files changed, 351 insertions(+), 102 deletions(-) rename {public => app/assets}/images/favicon-16.png (100%) rename {public => app/assets}/images/favicon-32.png (100%) rename {public => app/assets}/images/favicon-48.png (100%) rename {public => app/assets}/images/favicon.ico (100%) create mode 100644 app/models/application_record.rb mode change 100644 => 100755 bin/bundle mode change 100644 => 100755 bin/delayed_job mode change 100644 => 100755 bin/rails mode change 100644 => 100755 bin/rake mode change 100644 => 100755 bin/setup create mode 100755 bin/update create mode 100755 bin/yarn create mode 100644 config/cable.yml create mode 100644 config/initializers/application_controller_renderer.rb create mode 100644 config/initializers/new_framework_defaults_5_1.rb create mode 100644 config/spring.rb diff --git a/Gemfile b/Gemfile index 3fa979c63..f7b15775b 100644 --- a/Gemfile +++ b/Gemfile @@ -43,7 +43,7 @@ gem 'logging', '~> 2.0.0' gem 'aspector' # Aspect-oriented programming for Rails gem 'rgl' # Graph framework for project diagram calculations gem 'nested_form_fields' -gem 'ajax-datatables-rails', '~> 0.4.0' +gem 'ajax-datatables-rails', '~> 0.3.1' gem 'commit_param_routing' # Enables different submit actions in the same form to route to different actions in controller gem 'kaminari' gem "i18n-js", ">= 3.0.0.rc11" # Localization in javascript files @@ -73,6 +73,7 @@ gem 'base62' # Used for smart annotations gem 'newrelic_rpm' group :development, :test do + gem 'listen', '~> 3.0' gem 'byebug' gem 'better_errors' gem 'binding_of_caller' diff --git a/Gemfile.lock b/Gemfile.lock index 55028d6c1..99c347f92 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -52,8 +52,8 @@ GEM i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) - ajax-datatables-rails (0.4.0) - railties (>= 4.0) + ajax-datatables-rails (0.3.1) + railties (>= 3.1) ansi (1.5.0) arel (8.0.0) aspector (0.14.0) @@ -139,6 +139,7 @@ GEM execjs (2.7.0) faker (1.7.3) i18n (~> 0.5) + ffi (1.9.18) figaro (1.1.1) thor (~> 0.14) font-awesome-rails (4.7.0.2) @@ -178,6 +179,10 @@ GEM kaminari-core (= 1.0.1) kaminari-core (1.0.1) lazy_priority_queue (0.1.1) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) little-plugger (1.1.4) logging (2.0.0) little-plugger (~> 1.1) @@ -260,6 +265,9 @@ GEM rainbow (2.2.2) rake rake (12.0.0) + rb-fsevent (0.9.8) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) rdoc (4.3.0) recaptcha (4.3.1) json @@ -283,6 +291,7 @@ GEM unicode-display_width (~> 1.0, >= 1.0.1) ruby-graphviz (1.2.3) ruby-progressbar (1.8.1) + ruby_dep (1.5.0) rubyzip (1.2.1) sanitize (4.5.0) crass (~> 1.0.2) @@ -358,7 +367,7 @@ PLATFORMS ruby DEPENDENCIES - ajax-datatables-rails (~> 0.4.0) + ajax-datatables-rails (~> 0.3.1) aspector auto_strip_attributes (~> 2.1) autosize-rails @@ -393,6 +402,7 @@ DEPENDENCIES jquery-ui-rails js_cookie_rails kaminari + listen (~> 3.0) logging (~> 2.0.0) minitest-reporters (~> 1.1) momentjs-rails (~> 2.17.1) diff --git a/public/images/favicon-16.png b/app/assets/images/favicon-16.png similarity index 100% rename from public/images/favicon-16.png rename to app/assets/images/favicon-16.png diff --git a/public/images/favicon-32.png b/app/assets/images/favicon-32.png similarity index 100% rename from public/images/favicon-32.png rename to app/assets/images/favicon-32.png diff --git a/public/images/favicon-48.png b/app/assets/images/favicon-48.png similarity index 100% rename from public/images/favicon-48.png rename to app/assets/images/favicon-48.png diff --git a/public/images/favicon.ico b/app/assets/images/favicon.ico similarity index 100% rename from public/images/favicon.ico rename to app/assets/images/favicon.ico diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 60bfa9b06..e0e50c25b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base acts_as_token_authentication_handler_for User # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. - protect_from_forgery with: :exception + protect_from_forgery with: :exception, prepend: true before_action :authenticate_user! helper_method :current_team before_action :generate_intro_tutorial, if: :is_current_page_root? diff --git a/app/models/activity.rb b/app/models/activity.rb index 7cc63f143..67f0c137f 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -1,4 +1,4 @@ -class Activity < ActiveRecord::Base +class Activity < ApplicationRecord include InputSanitizeHelper after_create :generate_notification diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 000000000..10a4cba84 --- /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/asset.rb b/app/models/asset.rb index ffd2b0432..0a9c7c752 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -1,4 +1,4 @@ -class Asset < ActiveRecord::Base +class Asset < ApplicationRecord include SearchableModel include DatabaseHelper include Encryptor diff --git a/app/models/asset_text_datum.rb b/app/models/asset_text_datum.rb index e4471e4e0..9f8db238a 100644 --- a/app/models/asset_text_datum.rb +++ b/app/models/asset_text_datum.rb @@ -1,4 +1,4 @@ -class AssetTextDatum < ActiveRecord::Base +class AssetTextDatum < ApplicationRecord include SearchableModel validates :data, presence: true diff --git a/app/models/checklist.rb b/app/models/checklist.rb index 2d06bfe61..12f8e7cc0 100644 --- a/app/models/checklist.rb +++ b/app/models/checklist.rb @@ -1,4 +1,4 @@ -class Checklist < ActiveRecord::Base +class Checklist < ApplicationRecord include SearchableModel auto_strip_attributes :name, nullify: false diff --git a/app/models/checklist_item.rb b/app/models/checklist_item.rb index 4c61ef6f0..e3fe7804e 100644 --- a/app/models/checklist_item.rb +++ b/app/models/checklist_item.rb @@ -1,4 +1,4 @@ -class ChecklistItem < ActiveRecord::Base +class ChecklistItem < ApplicationRecord auto_strip_attributes :text, nullify: false validates :text, presence: true, diff --git a/app/models/comment.rb b/app/models/comment.rb index 20cb791c9..63cca8c96 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,4 +1,4 @@ -class Comment < ActiveRecord::Base +class Comment < ApplicationRecord include SearchableModel auto_strip_attributes :message, nullify: false diff --git a/app/models/connection.rb b/app/models/connection.rb index e2c68652b..eaee3a1e6 100644 --- a/app/models/connection.rb +++ b/app/models/connection.rb @@ -1,4 +1,4 @@ -class Connection < ActiveRecord::Base +class Connection < ApplicationRecord belongs_to :to, :class_name => 'MyModule', :foreign_key => 'input_id', inverse_of: :inputs belongs_to :from, :class_name => 'MyModule', :foreign_key => 'output_id', inverse_of: :outputs end diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index ce2a40668..6d706617c 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -1,4 +1,4 @@ -class CustomField < ActiveRecord::Base +class CustomField < ApplicationRecord auto_strip_attributes :name, nullify: false validates :name, presence: true, diff --git a/app/models/experiment.rb b/app/models/experiment.rb index 3ad412694..e1301c790 100644 --- a/app/models/experiment.rb +++ b/app/models/experiment.rb @@ -1,4 +1,4 @@ -class Experiment < ActiveRecord::Base +class Experiment < ApplicationRecord include ArchivableModel include SearchableModel diff --git a/app/models/my_module.rb b/app/models/my_module.rb index 27937bfeb..7316c80c7 100644 --- a/app/models/my_module.rb +++ b/app/models/my_module.rb @@ -1,4 +1,4 @@ -class MyModule < ActiveRecord::Base +class MyModule < ApplicationRecord include ArchivableModel, SearchableModel enum state: Extends::TASKS_STATES diff --git a/app/models/my_module_group.rb b/app/models/my_module_group.rb index f965876c4..e025da745 100644 --- a/app/models/my_module_group.rb +++ b/app/models/my_module_group.rb @@ -1,4 +1,4 @@ -class MyModuleGroup < ActiveRecord::Base +class MyModuleGroup < ApplicationRecord include SearchableModel auto_strip_attributes :name, nullify: false diff --git a/app/models/my_module_repository_row.rb b/app/models/my_module_repository_row.rb index 48b536ffb..068fefca7 100644 --- a/app/models/my_module_repository_row.rb +++ b/app/models/my_module_repository_row.rb @@ -1,4 +1,4 @@ -class MyModuleRepositoryRow < ActiveRecord::Base +class MyModuleRepositoryRow < ApplicationRecord belongs_to :assigned_by, foreign_key: 'assigned_by_id', class_name: 'User' belongs_to :repository_row belongs_to :my_module diff --git a/app/models/my_module_tag.rb b/app/models/my_module_tag.rb index f64bedbcc..733cdb027 100644 --- a/app/models/my_module_tag.rb +++ b/app/models/my_module_tag.rb @@ -1,4 +1,4 @@ -class MyModuleTag < ActiveRecord::Base +class MyModuleTag < ApplicationRecord validates :my_module, :tag, presence: true validates :tag_id, uniqueness: { scope: :my_module_id } diff --git a/app/models/notification.rb b/app/models/notification.rb index 84d609e1f..5e51539f6 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -1,4 +1,4 @@ -class Notification < ActiveRecord::Base +class Notification < ApplicationRecord has_many :user_notifications, inverse_of: :notification, dependent: :destroy has_many :users, through: :user_notifications belongs_to :generator_user, class_name: 'User' diff --git a/app/models/project.rb b/app/models/project.rb index 0baab5d64..05bae2dfd 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1,4 +1,4 @@ -class Project < ActiveRecord::Base +class Project < ApplicationRecord include ArchivableModel, SearchableModel enum visibility: { hidden: 0, visible: 1 } diff --git a/app/models/protocol.rb b/app/models/protocol.rb index 8f4049561..316e47fb4 100644 --- a/app/models/protocol.rb +++ b/app/models/protocol.rb @@ -1,4 +1,4 @@ -class Protocol < ActiveRecord::Base +class Protocol < ApplicationRecord include SearchableModel include RenamingUtil diff --git a/app/models/protocol_keyword.rb b/app/models/protocol_keyword.rb index 4ba135dbd..951839f89 100644 --- a/app/models/protocol_keyword.rb +++ b/app/models/protocol_keyword.rb @@ -1,4 +1,4 @@ -class ProtocolKeyword < ActiveRecord::Base +class ProtocolKeyword < ApplicationRecord auto_strip_attributes :name, nullify: false validates :name, length: { minimum: Constants::NAME_MIN_LENGTH, diff --git a/app/models/protocol_protocol_keyword.rb b/app/models/protocol_protocol_keyword.rb index 2662c3615..44256d43b 100644 --- a/app/models/protocol_protocol_keyword.rb +++ b/app/models/protocol_protocol_keyword.rb @@ -1,4 +1,4 @@ -class ProtocolProtocolKeyword < ActiveRecord::Base +class ProtocolProtocolKeyword < ApplicationRecord after_create :increment_protocols_count after_destroy :decrement_protocols_count @@ -20,4 +20,4 @@ class ProtocolProtocolKeyword < ActiveRecord::Base self.protocol_keyword.destroy end end -end \ No newline at end of file +end diff --git a/app/models/report.rb b/app/models/report.rb index 651ccc486..2735a56fb 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -1,4 +1,4 @@ -class Report < ActiveRecord::Base +class Report < ApplicationRecord include SearchableModel auto_strip_attributes :name, :description, nullify: false diff --git a/app/models/report_element.rb b/app/models/report_element.rb index fd83a9cc0..6b05b99a8 100644 --- a/app/models/report_element.rb +++ b/app/models/report_element.rb @@ -1,4 +1,4 @@ -class ReportElement < ActiveRecord::Base +class ReportElement < ApplicationRecord enum type_of: Extends::REPORT_ELEMENT_TYPES # This is only used by certain elements diff --git a/app/models/repository.rb b/app/models/repository.rb index 40664560d..533c1bfde 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1,4 +1,4 @@ -class Repository < ActiveRecord::Base +class Repository < ApplicationRecord belongs_to :team belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User' has_many :repository_columns diff --git a/app/models/repository_cell.rb b/app/models/repository_cell.rb index e89887c94..62983bf70 100644 --- a/app/models/repository_cell.rb +++ b/app/models/repository_cell.rb @@ -1,4 +1,4 @@ -class RepositoryCell < ActiveRecord::Base +class RepositoryCell < ApplicationRecord belongs_to :repository_row belongs_to :repository_column belongs_to :value, polymorphic: true, dependent: :destroy diff --git a/app/models/repository_column.rb b/app/models/repository_column.rb index 8c3b10b3b..00aa90bf3 100644 --- a/app/models/repository_column.rb +++ b/app/models/repository_column.rb @@ -1,4 +1,4 @@ -class RepositoryColumn < ActiveRecord::Base +class RepositoryColumn < ApplicationRecord belongs_to :repository belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User' has_many :repository_cells, dependent: :destroy diff --git a/app/models/repository_date_value.rb b/app/models/repository_date_value.rb index 619cc431f..0d2e6e397 100644 --- a/app/models/repository_date_value.rb +++ b/app/models/repository_date_value.rb @@ -1,4 +1,4 @@ -class RepositoryDateValue < ActiveRecord::Base +class RepositoryDateValue < ApplicationRecord belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User' belongs_to :last_modified_by, foreign_key: :last_modified_by_id, class_name: 'User' diff --git a/app/models/repository_row.rb b/app/models/repository_row.rb index d20404e1d..bd04f98f8 100644 --- a/app/models/repository_row.rb +++ b/app/models/repository_row.rb @@ -1,4 +1,4 @@ -class RepositoryRow < ActiveRecord::Base +class RepositoryRow < ApplicationRecord belongs_to :repository belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User' belongs_to :last_modified_by, foreign_key: :last_modified_by_id, diff --git a/app/models/repository_table_state.rb b/app/models/repository_table_state.rb index 6e40e2ea7..643dcd5e7 100644 --- a/app/models/repository_table_state.rb +++ b/app/models/repository_table_state.rb @@ -1,4 +1,4 @@ -class RepositoryTableState < ActiveRecord::Base +class RepositoryTableState < ApplicationRecord belongs_to :user, inverse_of: :repository_table_states belongs_to :repository, inverse_of: :repository_table_states diff --git a/app/models/repository_text_value.rb b/app/models/repository_text_value.rb index 22486b004..699f1ed18 100644 --- a/app/models/repository_text_value.rb +++ b/app/models/repository_text_value.rb @@ -1,4 +1,4 @@ -class RepositoryTextValue < ActiveRecord::Base +class RepositoryTextValue < ApplicationRecord belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User' belongs_to :last_modified_by, foreign_key: :last_modified_by_id, class_name: 'User' diff --git a/app/models/result.rb b/app/models/result.rb index 1af0e7c3d..87e55efc0 100644 --- a/app/models/result.rb +++ b/app/models/result.rb @@ -1,4 +1,4 @@ -class Result < ActiveRecord::Base +class Result < ApplicationRecord include ArchivableModel, SearchableModel auto_strip_attributes :name, nullify: false diff --git a/app/models/result_asset.rb b/app/models/result_asset.rb index 0d5fe32dc..020a554f8 100644 --- a/app/models/result_asset.rb +++ b/app/models/result_asset.rb @@ -1,4 +1,4 @@ -class ResultAsset < ActiveRecord::Base +class ResultAsset < ApplicationRecord validates :result, :asset, presence: true belongs_to :result, inverse_of: :result_asset diff --git a/app/models/result_table.rb b/app/models/result_table.rb index c1abb0233..215974f14 100644 --- a/app/models/result_table.rb +++ b/app/models/result_table.rb @@ -1,4 +1,4 @@ -class ResultTable < ActiveRecord::Base +class ResultTable < ApplicationRecord validates :result, :table, presence: true belongs_to :result, inverse_of: :result_table diff --git a/app/models/result_text.rb b/app/models/result_text.rb index 542ba2c34..a54ff9981 100644 --- a/app/models/result_text.rb +++ b/app/models/result_text.rb @@ -1,4 +1,4 @@ -class ResultText < ActiveRecord::Base +class ResultText < ApplicationRecord auto_strip_attributes :text, nullify: false validates :text, presence: true, diff --git a/app/models/sample.rb b/app/models/sample.rb index c668ba2a6..a5e98ee8d 100644 --- a/app/models/sample.rb +++ b/app/models/sample.rb @@ -1,4 +1,4 @@ -class Sample < ActiveRecord::Base +class Sample < ApplicationRecord include SearchableModel auto_strip_attributes :name, nullify: false diff --git a/app/models/sample_custom_field.rb b/app/models/sample_custom_field.rb index 95d1989a8..8610a9ac9 100644 --- a/app/models/sample_custom_field.rb +++ b/app/models/sample_custom_field.rb @@ -1,4 +1,4 @@ -class SampleCustomField < ActiveRecord::Base +class SampleCustomField < ApplicationRecord include SearchableModel auto_strip_attributes :value, nullify: false diff --git a/app/models/sample_group.rb b/app/models/sample_group.rb index 0e647012c..b094d5999 100644 --- a/app/models/sample_group.rb +++ b/app/models/sample_group.rb @@ -1,4 +1,4 @@ -class SampleGroup < ActiveRecord::Base +class SampleGroup < ApplicationRecord include SearchableModel auto_strip_attributes :name, :color, nullify: false diff --git a/app/models/sample_my_module.rb b/app/models/sample_my_module.rb index e74ba3b68..0337cd7ae 100644 --- a/app/models/sample_my_module.rb +++ b/app/models/sample_my_module.rb @@ -1,4 +1,4 @@ -class SampleMyModule < ActiveRecord::Base +class SampleMyModule < ApplicationRecord after_create :increment_nr_of_module_samples after_destroy :decrement_nr_of_module_samples diff --git a/app/models/sample_type.rb b/app/models/sample_type.rb index 9cf1f883f..302904cfe 100644 --- a/app/models/sample_type.rb +++ b/app/models/sample_type.rb @@ -1,4 +1,4 @@ -class SampleType < ActiveRecord::Base +class SampleType < ApplicationRecord include SearchableModel auto_strip_attributes :name, nullify: false diff --git a/app/models/samples_table.rb b/app/models/samples_table.rb index e1ca4e2e3..25e77cf0c 100644 --- a/app/models/samples_table.rb +++ b/app/models/samples_table.rb @@ -1,4 +1,4 @@ -class SamplesTable < ActiveRecord::Base +class SamplesTable < ApplicationRecord validates :user, :team, presence: true belongs_to :user, inverse_of: :samples_tables diff --git a/app/models/settings.rb b/app/models/settings.rb index 06fb121d9..a5aa0bd62 100644 --- a/app/models/settings.rb +++ b/app/models/settings.rb @@ -1,4 +1,4 @@ -class Settings < ActiveRecord::Base +class Settings < ApplicationRecord def self.instance @instance ||= first @instance ||= new diff --git a/app/models/step.rb b/app/models/step.rb index 05ee2b3ee..bddb065f1 100644 --- a/app/models/step.rb +++ b/app/models/step.rb @@ -1,4 +1,4 @@ -class Step < ActiveRecord::Base +class Step < ApplicationRecord include SearchableModel auto_strip_attributes :name, :description, nullify: false diff --git a/app/models/step_asset.rb b/app/models/step_asset.rb index 51b415082..a5627b33b 100644 --- a/app/models/step_asset.rb +++ b/app/models/step_asset.rb @@ -1,4 +1,4 @@ -class StepAsset < ActiveRecord::Base +class StepAsset < ApplicationRecord validates :step, :asset, presence: true belongs_to :step, inverse_of: :step_assets diff --git a/app/models/step_table.rb b/app/models/step_table.rb index ee1e1eeed..7df22ed65 100644 --- a/app/models/step_table.rb +++ b/app/models/step_table.rb @@ -1,4 +1,4 @@ -class StepTable < ActiveRecord::Base +class StepTable < ApplicationRecord validates :step, :table, presence: true belongs_to :step, inverse_of: :step_tables diff --git a/app/models/table.rb b/app/models/table.rb index 437dcd99c..8c9fab158 100644 --- a/app/models/table.rb +++ b/app/models/table.rb @@ -1,4 +1,4 @@ -class Table < ActiveRecord::Base +class Table < ApplicationRecord include SearchableModel auto_strip_attributes :name, nullify: false diff --git a/app/models/tag.rb b/app/models/tag.rb index 27e044cf4..b937696c4 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,4 +1,4 @@ -class Tag < ActiveRecord::Base +class Tag "public, max-age=#{2.days.seconds.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end end diff --git a/config/environments/production.rb b/config/environments/production.rb index 4778a5637..a6485ce69 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -48,7 +48,7 @@ Rails.application.configure do # 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.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -119,4 +119,46 @@ Rails.application.configure do # Enable user registrations config.x.enable_user_registration = ENV['ENABLE_USER_REGISTRATION'] == 'false' ? false : true + + # 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 + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # 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 = "scinote_#{Rails.env}" + config.action_mailer.perform_caching = false + + # `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.*/ ] + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + + # Attempt to read encrypted secrets from `config/secrets.yml.enc`. + # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or + # `config/secrets.yml.key`. + config.read_encrypted_secrets = true end diff --git a/config/environments/test.rb b/config/environments/test.rb index 3196c32ef..2fee112e6 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,6 +1,12 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # 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=#{1.hour.seconds.to_i}" + } + # Enable this to be able to output stuff to STDOUT during tests # via Rails::logger.info "..." config.logger = Logger.new(STDOUT) diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 000000000..51639b67a --- /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 index fd171d627..3ea3a01af 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,12 +3,16 @@ # 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 +# Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. -# application.js application.css, and all non-JS/CSS -# in app/assets folder are already added. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) + Rails.application.config.assets.precompile += %w(underscore.js) Rails.application.config.assets.precompile += %w(jsPlumb-2.0.4-min.js) Rails.application.config.assets.precompile += %w(jsnetworkx.js) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7f70458de..5a6a32d37 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +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 = :json diff --git a/config/initializers/devise_async.rb b/config/initializers/devise_async.rb index 9cd6ee8ad..ca94fa499 100644 --- a/config/initializers/devise_async.rb +++ b/config/initializers/devise_async.rb @@ -1,4 +1,4 @@ Devise::Async.enabled = true Devise::Async.backend = :delayed_job Devise::Async.queue = :devise_email -Devise::Async.priority = 10 +# Devise::Async.priority = 10 diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb new file mode 100644 index 000000000..9010abd5c --- /dev/null +++ b/config/initializers/new_framework_defaults_5_1.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.1 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Make `form_with` generate non-remote forms. +Rails.application.config.action_view.form_with_generates_remote_forms = false + +# Unknown asset fallback will return the path passed in when the given +# asset is not present in the asset pipeline. +# Rails.application.config.assets.unknown_asset_fallback = false diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 33725e95f..bbfc3961b 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/locales/en.yml b/config/locales/en.yml index 58a217610..75d8b3e7c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -910,8 +910,8 @@ en: column_create: "Create" columns_delete: "Delete" columns_visibility: "Visible columns" - view_all_records: "View all records" - view_assigned_records: "View assigned records" + view_all_records: "View all items" + view_assigned_records: "View assigned items" modal_delete_record: title: "Delete record" notice: "Are you sure you want to delete the selected records?" diff --git a/config/puma.rb b/config/puma.rb index afdb99a38..abcb03447 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -13,3 +13,60 @@ on_worker_boot do # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot ActiveRecord::Base.establish_connection end + +# 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 } +# threads threads_count, threads_count +# +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +# port ENV.fetch("PORT") { 3000 } +# +# 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! + +# If you are preloading your application and using Active Record, it's +# recommended that you close any connections to the database before workers +# are forked to prevent connection leakage. +# +# before_fork do +# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) +# end + +# 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 the `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, as Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end +# + +# Allow puma to be restarted by `rails restart` command. +# plugin :tmp_restart diff --git a/config/secrets.yml b/config/secrets.yml index 831480ff7..95be2004e 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -1,5 +1,23 @@ # Be sure to restart your server when you modify this file. +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rails secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +# Shared secrets are available across all environments. + +# shared: +# api_key: a1B2c3D4e5F6 + +# Environmental secrets are only available for that specific environment. +# Be sure to restart your server when you modify this file. + common: &common # ====================================================================== @@ -39,10 +57,13 @@ common: &common # ====================================================================== development: + secret_key_base: 22f2adf8f5cb73351da28f2292daa840cc2a414ae00ae605b175a8d5c73932f7e5b8ff8ef8f1554a7f1064f9869b15347f7709f0daa6ccb24c50f3cace304f64 <<: *common test: + secret_key_base: f3719934e04fa8871cf5d33d5c60f05e1b8995e0315265aef9f8b878da49bd2d386eb25ce35545b469a94ccf22f91e0052b93a15194b4f57b0c8d6ce8b150e1e <<: *common production: - <<: *common \ No newline at end of file + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> + <<: *common diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 000000000..c9119b40c --- /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) }