Compare commits

...

2 commits

Author SHA1 Message Date
Devin Howard fc701cf485 rubocop 2017-10-16 18:15:47 -07:00
Devin Howard 2dc6a948c6 upgrade to rails 5.1 2017-10-16 18:04:44 -07:00
38 changed files with 246 additions and 106 deletions

View file

@ -2,7 +2,7 @@
source 'https://rubygems.org' source 'https://rubygems.org'
ruby '2.3.0' ruby '2.3.0'
gem 'rails', '~> 5.0.0' gem 'rails', '~> 5.1.0'
gem 'active_model_serializers' gem 'active_model_serializers'
gem 'aws-sdk', '~> 2.7.0' gem 'aws-sdk', '~> 2.7.0'

View file

@ -1,27 +1,27 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (5.0.5) actioncable (5.1.4)
actionpack (= 5.0.5) actionpack (= 5.1.4)
nio4r (>= 1.2, < 3.0) nio4r (~> 2.0)
websocket-driver (~> 0.6.1) websocket-driver (~> 0.6.1)
actionmailer (5.0.5) actionmailer (5.1.4)
actionpack (= 5.0.5) actionpack (= 5.1.4)
actionview (= 5.0.5) actionview (= 5.1.4)
activejob (= 5.0.5) activejob (= 5.1.4)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
actionpack (5.0.5) actionpack (5.1.4)
actionview (= 5.0.5) actionview (= 5.1.4)
activesupport (= 5.0.5) activesupport (= 5.1.4)
rack (~> 2.0) rack (~> 2.0)
rack-test (~> 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.5) actionview (5.1.4)
activesupport (= 5.0.5) activesupport (= 5.1.4)
builder (~> 3.1) builder (~> 3.1)
erubis (~> 2.7.0) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_model_serializers (0.10.6) active_model_serializers (0.10.6)
@ -29,23 +29,23 @@ GEM
activemodel (>= 4.1, < 6) activemodel (>= 4.1, < 6)
case_transform (>= 0.2) case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.2)
activejob (5.0.5) activejob (5.1.4)
activesupport (= 5.0.5) activesupport (= 5.1.4)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (5.0.5) activemodel (5.1.4)
activesupport (= 5.0.5) activesupport (= 5.1.4)
activerecord (5.0.5) activerecord (5.1.4)
activemodel (= 5.0.5) activemodel (= 5.1.4)
activesupport (= 5.0.5) activesupport (= 5.1.4)
arel (~> 7.0) arel (~> 8.0)
activesupport (5.0.5) activesupport (5.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7) i18n (~> 0.7)
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.5.2) addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0) public_suffix (>= 2.0.2, < 4.0)
arel (7.1.4) arel (8.0.0)
ast (2.3.0) ast (2.3.0)
aws-sdk (2.7.0) aws-sdk (2.7.0)
aws-sdk-resources (= 2.7.0) aws-sdk-resources (= 2.7.0)
@ -79,6 +79,7 @@ GEM
climate_control (>= 0.0.3, < 1.0) climate_control (>= 0.0.3, < 1.0)
coderay (1.1.2) coderay (1.1.2)
concurrent-ruby (1.0.5) concurrent-ruby (1.0.5)
crass (1.0.2)
debug_inspector (0.0.3) debug_inspector (0.0.3)
delayed_job (4.1.3) delayed_job (4.1.3)
activesupport (>= 3.0, < 5.2) activesupport (>= 3.0, < 5.2)
@ -100,7 +101,6 @@ GEM
dotenv (= 2.2.1) dotenv (= 2.2.1)
railties (>= 3.2, < 5.2) railties (>= 3.2, < 5.2)
erubi (1.6.1) erubi (1.6.1)
erubis (2.7.0)
exception_notification (4.2.2) exception_notification (4.2.2)
actionmailer (>= 4.0, < 6) actionmailer (>= 4.0, < 6)
activesupport (>= 4.0, < 6) activesupport (>= 4.0, < 6)
@ -117,7 +117,8 @@ GEM
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
httparty (0.15.6) httparty (0.15.6)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
i18n (0.8.6) i18n (0.9.0)
concurrent-ruby (~> 1.0)
jmespath (1.3.1) jmespath (1.3.1)
jquery-rails (4.3.1) jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
@ -141,7 +142,8 @@ GEM
activerecord activerecord
kaminari-core (= 1.0.1) kaminari-core (= 1.0.1)
kaminari-core (1.0.1) kaminari-core (1.0.1)
loofah (2.0.3) loofah (2.1.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.6.6) mail (2.6.6)
mime-types (>= 1.16, < 4) mime-types (>= 1.16, < 4)
@ -153,12 +155,12 @@ GEM
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521) mime-types-data (3.2016.0521)
mimemagic (0.3.2) mimemagic (0.3.2)
mini_portile2 (2.2.0) mini_portile2 (2.3.0)
minitest (5.10.3) minitest (5.10.3)
multi_xml (0.6.0) multi_xml (0.6.0)
nio4r (2.1.0) nio4r (2.1.0)
nokogiri (1.8.0) nokogiri (1.8.1)
mini_portile2 (~> 2.2.0) mini_portile2 (~> 2.3.0)
orm_adapter (0.5.0) orm_adapter (0.5.0)
paperclip (5.1.0) paperclip (5.1.0)
activemodel (>= 4.2.0) activemodel (>= 4.2.0)
@ -189,34 +191,34 @@ GEM
rack-attack (5.0.1) rack-attack (5.0.1)
rack rack
rack-cors (1.0.1) rack-cors (1.0.1)
rack-test (0.6.3) rack-test (0.7.0)
rack (>= 1.0) rack (>= 1.0, < 3)
rails (5.0.5) rails (5.1.4)
actioncable (= 5.0.5) actioncable (= 5.1.4)
actionmailer (= 5.0.5) actionmailer (= 5.1.4)
actionpack (= 5.0.5) actionpack (= 5.1.4)
actionview (= 5.0.5) actionview (= 5.1.4)
activejob (= 5.0.5) activejob (= 5.1.4)
activemodel (= 5.0.5) activemodel (= 5.1.4)
activerecord (= 5.0.5) activerecord (= 5.1.4)
activesupport (= 5.0.5) activesupport (= 5.1.4)
bundler (>= 1.3.0) bundler (>= 1.3.0)
railties (= 5.0.5) railties (= 5.1.4)
sprockets-rails (>= 2.0.0) sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3) rails-dom-testing (2.0.3)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
nokogiri (>= 1.6) nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3) rails-html-sanitizer (1.0.3)
loofah (~> 2.0) loofah (~> 2.0)
railties (5.0.5) railties (5.1.4)
actionpack (= 5.0.5) actionpack (= 5.1.4)
activesupport (= 5.0.5) activesupport (= 5.1.4)
method_source method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rainbow (2.2.2) rainbow (2.2.2)
rake rake
rake (12.0.0) rake (12.1.0)
rb-fsevent (0.10.2) rb-fsevent (0.10.2)
rb-inotify (0.9.10) rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2) ffi (>= 0.5.0, < 2)
@ -330,7 +332,7 @@ DEPENDENCIES
pundit_extra pundit_extra
rack-attack rack-attack
rack-cors rack-cors
rails (~> 5.0.0) rails (~> 5.1.0)
redis (~> 3.3.3) redis (~> 3.3.3)
rspec-rails rspec-rails
rubocop rubocop

38
bin/setup Executable file
View file

@ -0,0 +1,38 @@
#!/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 starting point to setup your application.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system! 'bin/rails db:setup'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end

29
bin/update Executable file
View file

@ -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

11
bin/yarn Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env ruby
VENDOR_PATH = File.expand_path('..', __dir__)
Dir.chdir(VENDOR_PATH) do
begin
exec "yarnpkg #{ARGV.join(" ")}"
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require_relative 'boot' require_relative 'boot'
require 'csv' require 'csv'

View file

@ -1,16 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'rubygems'
require 'rails/commands/server'
module Rails
class Server
def default_options
super.merge(Host: '0.0.0.0', Port: 3000)
end
end
end
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' require 'bundler/setup' # Set up gems listed in the Gemfile.

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Load the Rails application. # Load the Rails application.
require_relative 'application' require_relative 'application'

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb
@ -24,7 +25,7 @@ Rails.application.configure do
# Print deprecation notices to the Rails logger # Print deprecation notices to the Rails logger
config.active_support.deprecation = :log config.active_support.deprecation = :log
config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews" config.action_mailer.preview_path = Rails.root.join('spec', 'mailers', 'previews')
# Expands the lines which load the assets # Expands the lines which load the assets
config.assets.debug = false config.assets.debug = false

View file

@ -1,9 +1,12 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb
config.action_cable.allowed_request_origins = ['https://metamaps.herokuapp.com', 'http://metamaps.herokuapp.com', 'https://metamaps.cc'] config.action_cable.allowed_request_origins = [
'https://metamaps.herokuapp.com', 'http://metamaps.herokuapp.com', 'https://metamaps.cc'
]
# log to stdout # log to stdout
logger = Logger.new(STDOUT) logger = Logger.new(STDOUT)

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Metamaps::Application.configure do Metamaps::Application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
$codes = [] $codes = []
if ActiveRecord::Base.connection.data_source_exists? 'users' if ActiveRecord::Base.connection.data_source_exists? 'users'
$codes = ActiveRecord::Base.connection $codes = ActiveRecord::Base.connection

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true # frozen_string_literal: true
ActiveModelSerializers.config.adapter = :json ActiveModelSerializers.config.adapter = :json

View file

@ -1,7 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!( # ActiveSupport::Reloader.to_prepare do
# http_host: 'example.org', # ApplicationController.renderer.defaults.merge!(
# https: false # http_host: 'example.org',
# ) # https: false
# )
# end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
config.assets.version = '2.0' config.assets.version = '2.0'
@ -9,5 +10,7 @@ Rails.application.configure do
# Precompile additional assets. # 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 app/assets folder are already added.
config.assets.precompile += %w( application-secret.css application-secret.js webpacked/metamaps.bundle.js ) config.assets.precompile += %w[
application-secret.css application-secret.js webpacked/metamaps.bundle.js
]
end end

View file

@ -1,10 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't # You can add backtrace silencers for libraries that you're using but don't wish
# wish to see in your backtraces. # to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem # You can also remove all the silencers if you're trying to debug a problem that
# that might stem from framework code. # might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers! # Rails.backtrace_cleaner.remove_silencers!

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars. # Specify a serializer for the signed and encrypted cookie jars.

View file

@ -1,9 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.config.middleware.insert_before 0, Rack::Cors do Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do allow do
origins '*' origins '*'
resource '/api/*', resource '/api/*',
headers: :any, headers: :any,
methods: [:get, :post, :put, :delete, :options, :head] methods: %i[get post put delete options head]
end end
end end

View file

@ -1,9 +1,12 @@
Delayed::Worker.class_eval do # frozen_string_literal: true
def handle_failed_job_with_notification(job, error)
handle_failed_job_without_notification(job, error)
ExceptionNotifier.notify_exception(error)
end
alias_method_chain :handle_failed_job, :notification
module ExceptionNotifierInDelayedJob
def handle_failed_job(job, error)
super
ExceptionNotfier.notify_exception(error)
end
end
Delayed::Worker.class_eval do
prepend ExceptionNotifierInDelayedJob
end end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Use this hook to configure devise mailer, warden hooks and so forth. # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model. # Many of these configuration options can be set straight in your model.
Devise.setup do |config| Devise.setup do |config|

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Doorkeeper.configure do Doorkeeper.configure do
# Change the ORM that doorkeeper will use (needs plugins) # Change the ORM that doorkeeper will use (needs plugins)
orm :active_record orm :active_record

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'exception_notification/rails' require 'exception_notification/rails'
module ExceptionNotifier module ExceptionNotifier
@ -50,11 +51,11 @@ ExceptionNotification.configure do |config|
# Ignore additional exception types. # Ignore additional exception types.
# ActiveRecord::RecordNotFound, AbstractController::ActionNotFound and # ActiveRecord::RecordNotFound, AbstractController::ActionNotFound and
# ActionController::RoutingError are already added. # ActionController::RoutingError are already added.
config.ignored_exceptions += %w( config.ignored_exceptions += %w[
ActionView::TemplateError CustomError UnauthorizedException ActionView::TemplateError CustomError UnauthorizedException
InvalidArgumentException InvalidEntityException InvalidRequestException InvalidArgumentException InvalidEntityException InvalidRequestException
NotFoundException ValidationException NotFoundException ValidationException
) ]
# Adds a condition to decide when an exception must be ignored or not. # Adds a condition to decide when an exception must be ignored or not.
# The ignore_if method can be invoked multiple times to add extra conditions. # The ignore_if method can be invoked multiple times to add extra conditions.

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file. # Configure sensitive parameters which will be filtered from the log file.

View file

@ -1,3 +1,12 @@
# frozen_string_literal: true
TESTER_EMAILS = %w[
connorturland@gmail.com devin@callysto.com chessscholar@gmail.com solaureum@gmail.com
ishanshapiro@gmail.com
].freeze
# rubocop:disable Style/PredicateName
def is_tester(user) def is_tester(user)
user && %w(connorturland@gmail.com devin@callysto.com chessscholar@gmail.com solaureum@gmail.com ishanshapiro@gmail.com).include?(user.email) user && TESTER_EMAILS.include?(user.email)
end end
# rubocop:enable Style/PredicateName

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Kaminari.configure do |config| Kaminari.configure do |config|
# config.default_per_page = 25 # config.default_per_page = 25
# config.max_per_page = nil # config.max_per_page = nil

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks: # Add new mime types for use in respond_to blocks:

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# #
# This file contains migration options to ease your Rails 5.0 upgrade. # This file contains migration options to ease your Rails 5.0 upgrade.

View file

@ -0,0 +1,16 @@
# frozen_string_literal: true
# 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

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
Paperclip::Attachment.default_options[:url] = ':s3_domain_url' Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename' Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module Rack module Rack
class Attack class Attack
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies. # Your secret key for verifying the integrity of signed cookies.

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_Metamaps_session' Rails.application.config.session_store :cookie_store, key: '_Metamaps_session'

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
METAMAPS_VERSION = '3.5' METAMAPS_VERSION = '3.5'
METAMAPS_BUILD = `git log -1 --pretty=%H`.chomp[0..11].freeze METAMAPS_BUILD = `git log -1 --pretty=%H`.chomp[0..11].freeze
METAMAPS_LAST_UPDATED = `git log -1 --pretty='%ad'`.split(' ').values_at(1, 2, 4).join(' ').freeze METAMAPS_LAST_UPDATED = `git log -1 --pretty='%ad'`.split(' ').values_at(1, 2, 4).join(' ').freeze

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
Warden::Manager.after_set_user do |user, auth, opts| Warden::Manager.after_set_user do |user, auth, opts|
scope = opts[:scope] scope = opts[:scope]
auth.cookies.signed["#{scope}.id"] = user.id auth.cookies.signed["#{scope}.id"] = user.id

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# #
# This file contains settings for ActionController::ParamsWrapper which # This file contains settings for ActionController::ParamsWrapper which

View file

@ -1,14 +1,15 @@
# frozen_string_literal: true # frozen_string_literal: true
# Puma can serve each request in a thread from an internal thread pool. # Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum. # The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match # 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 # 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. # and maximum; this matches the default thread size of Active Record.
# #
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
threads threads_count, threads_count threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is 3000. # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
# #
port ENV.fetch('PORT') { 3000 } port ENV.fetch('PORT') { 3000 }
@ -33,16 +34,25 @@ environment ENV.fetch('RAILS_ENV') { 'development' }
# #
# preload_app! # 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 # 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 # 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!` # 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 # option, you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, Ruby # or connections that may have been created at application boot, as Ruby
# cannot share connections between processes. # cannot share connections between processes.
# #
# on_worker_boot do # on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end # end
#
# Allow puma to be restarted by `rails restart` command. # Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart plugin :tmp_restart

View file

@ -1,4 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
# rubocop:disable Metrics/BlockLength
Metamaps::Application.routes.draw do Metamaps::Application.routes.draw do
use_doorkeeper use_doorkeeper
mount ActionCable.server => '/cable' mount ActionCable.server => '/cable'
@ -16,7 +18,7 @@ Metamaps::Application.routes.draw do
end end
get :explore, to: redirect('/') get :explore, to: redirect('/')
resources :maps, except: [:index, :edit] do resources :maps, except: %i[index edit] do
member do member do
get :conversation get :conversation
get :export get :export
@ -54,10 +56,10 @@ Metamaps::Application.routes.draw do
end end
end end
resources :mappings, except: [:index, :new, :edit] resources :mappings, except: %i[index new edit]
resources :messages, only: [:show, :create, :update, :destroy] resources :messages, only: %i[show create update destroy]
resources :notifications, only: [:index, :show] do resources :notifications, only: %i[index show] do
collection do collection do
get :unsubscribe get :unsubscribe
end end
@ -79,9 +81,9 @@ Metamaps::Application.routes.draw do
get :synapses get :synapses
end end
resources :synapses, except: [:index, :new, :edit] resources :synapses, except: %i[index new edit]
resources :topics, except: [:index, :new, :edit] do resources :topics, except: %i[index new edit] do
member do member do
get :network get :network
get :relative_numbers get :relative_numbers
@ -110,7 +112,7 @@ Metamaps::Application.routes.draw do
get 'join' => 'users/registrations#new', :as => :sign_up get 'join' => 'users/registrations#new', :as => :sign_up
end end
resources :users, except: [:index, :destroy] do resources :users, except: %i[index destroy] do
member do member do
get :details get :details
end end
@ -120,16 +122,16 @@ Metamaps::Application.routes.draw do
namespace :api, path: '/api', default: { format: :json } do namespace :api, path: '/api', default: { format: :json } do
namespace :v2, path: '/v2' do namespace :v2, path: '/v2' do
resources :metacodes, only: [:index, :show] resources :metacodes, only: %i[index show]
resources :mappings, only: [:index, :create, :show, :update, :destroy] resources :mappings, only: %i[index create show update destroy]
resources :maps, only: [:index, :create, :show, :update, :destroy] do resources :maps, only: %i[index create show update destroy] do
post :stars, to: 'stars#create', on: :member post :stars, to: 'stars#create', on: :member
delete :stars, to: 'stars#destroy', on: :member delete :stars, to: 'stars#destroy', on: :member
end end
resources :synapses, only: [:index, :create, :show, :update, :destroy] resources :synapses, only: %i[index create show update destroy]
resources :tokens, only: [:index, :create, :destroy] resources :tokens, only: %i[index create destroy]
resources :topics, only: [:index, :create, :show, :update, :destroy] resources :topics, only: %i[index create show update destroy]
resources :users, only: [:index, :show] do resources :users, only: %i[index show] do
get :current, on: :collection get :current, on: :collection
end end
match '*path', to: 'restful#catch_404', via: :all match '*path', to: 'restful#catch_404', via: :all
@ -145,4 +147,4 @@ Metamaps::Application.routes.draw do
get 'load_url_title' get 'load_url_title'
end end
end end
# rubocop:enable Rubocop/Metrics/BlockLength # rubocop:enable Metrics/BlockLength

View file

@ -1,8 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
%w(
%w[
.ruby-version .ruby-version
.ruby-gemset .ruby-gemset
.rbenv-vars .rbenv-vars
tmp/restart.txt tmp/restart.txt
tmp/caching-dev.txt tmp/caching-dev.txt
).each { |path| Spring.watch(path) } ].each { |path| Spring.watch(path) }