diff --git a/Procfile b/Procfile index 84cab0c9..8b9e764c 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -web: bundle exec puma -C config/puma.rb +web: bundle exec rails server -b 0.0.0.0 worker: bundle exec rails jobs:work diff --git a/app/controllers/admin/commercials_controller.rb b/app/controllers/admin/commercials_controller.rb index 003e04bf..0680b436 100644 --- a/app/controllers/admin/commercials_controller.rb +++ b/app/controllers/admin/commercials_controller.rb @@ -70,7 +70,7 @@ module Admin flash[:error] = errors_text end - redirect_to :back + redirect_back(fallback_location: root_path) end private diff --git a/app/controllers/openids_controller.rb b/app/controllers/openids_controller.rb index 3bccba2f..82af86d0 100644 --- a/app/controllers/openids_controller.rb +++ b/app/controllers/openids_controller.rb @@ -6,6 +6,6 @@ class OpenidsController < ApplicationController def destroy @openid.destroy - redirect_to :back + redirect_back(fallback_location: root_path) end end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index d59cc2d8..692b4db0 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -104,7 +104,7 @@ class ProposalsController < ApplicationController @event.event_schedules.destroy_all end rescue Transitions::InvalidTransition - redirect_to :back, error: "Event can't be withdrawn" + redirect_back(fallback_location: root_path, error: "Event can't be withdrawn") return end @@ -124,7 +124,7 @@ class ProposalsController < ApplicationController begin @event.confirm rescue Transitions::InvalidTransition - redirect_to :back, error: "Event can't be confirmed" + redirect_back(fallback_location: root_path, error: "Event can't be confirmed") return end diff --git a/app/controllers/surveys_controller.rb b/app/controllers/surveys_controller.rb index 5c0af57e..349bc34b 100644 --- a/app/controllers/surveys_controller.rb +++ b/app/controllers/surveys_controller.rb @@ -40,6 +40,6 @@ class SurveysController < ApplicationController end end - redirect_to :back + redirect_back(fallback_location: root_path) end end diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 03ae4044..8d0f80dd 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -2,7 +2,7 @@ module Users class OmniauthCallbacksController < Devise::OmniauthCallbacksController - skip_before_filter :verify_authenticity_token + skip_before_action :verify_authenticity_token skip_authorization_check User.omniauth_providers.each do |provider| diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 36adbb0b..c8b9acbe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -88,10 +88,9 @@ module ApplicationHelper end end - # Same as redirect_to(:back) if there is a valid HTTP referer, otherwise redirect_to() def redirect_back_or_to(options = {}, response_status = {}) if request.env['HTTP_REFERER'] - redirect_to :back + redirect_back(fallback_location: root_path) else redirect_to options, response_status end diff --git a/app/models/conference.rb b/app/models/conference.rb index 89ca5d19..ca37e6d0 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -1120,7 +1120,6 @@ class Conference < ApplicationRecord # def create_email_settings build_email_settings - true end ## diff --git a/app/models/program.rb b/app/models/program.rb index 6c3a3b4a..0dadee15 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -211,7 +211,6 @@ class Program < ApplicationRecord EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice', minimum_abstract_length: 0, maximum_abstract_length: 500, program_id: id) - true end ## @@ -227,7 +226,6 @@ class Program < ApplicationRecord DifficultyLevel.create(title: 'Hard', description: 'Events require expert knowledge of the topic.', color: '#EF6E69', program_id: id) - true end ## diff --git a/app/models/registration.rb b/app/models/registration.rb index f7c032ea..a071af28 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -76,7 +76,7 @@ class Registration < ApplicationRecord end def registration_limit_not_exceed - if conference.registration_limit > 0 && conference.registrations(:reload).count >= conference.registration_limit + if conference.registration_limit > 0 && conference.registrations.count >= conference.registration_limit errors.add(:base, 'Registration limit exceeded') end end diff --git a/app/models/role.rb b/app/models/role.rb index d759f47d..2be87d7b 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -18,6 +18,6 @@ class Role < ApplicationRecord # Needed to ensure that removing all user from role doesn't remove role. def cancel - false + throw(:abort) end end diff --git a/app/models/user.rb b/app/models/user.rb index bc71f61f..ec3132e1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -11,6 +11,7 @@ class User < ApplicationRecord # prevent N+1 queries with has_cached_role? by preloading roles *always* default_scope { preload(:roles) } + has_many :ticket_purchases, dependent: :destroy has_many :physical_tickets, through: :ticket_purchases do def by_conference(conference) where('ticket_purchases.conference_id = ?', conference) @@ -67,7 +68,6 @@ class User < ApplicationRecord end end has_many :events_registrations, through: :registrations - has_many :ticket_purchases, dependent: :destroy has_many :payments, dependent: :destroy has_many :tickets, through: :ticket_purchases, source: :ticket do def for_registration conference diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index cbf423a8..534a2396 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -20,6 +20,3 @@ 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/puma.rb b/config/puma.rb index fa11fb8f..9886e1e5 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -21,7 +21,7 @@ environment ENV.fetch("RAILS_ENV") { "development" } # Workers do not work on JRuby or Windows (both of which do not support # processes). # -workers ENV.fetch("WEB_CONCURRENCY") { 2 } +workers ENV.fetch("WEB_CONCURRENCY") { 1 } # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb index 1d2c60a4..58c2e287 100644 --- a/spec/models/role_spec.rb +++ b/spec/models/role_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' describe Role do let(:conference) { create(:conference) } - let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } - let!(:cfp_role) { Role.find_by(name: 'cfp', resource: conference) } + let!(:organizer_role) { Role.find_or_create_by(name: 'organizer', resource: conference) } + let!(:cfp_role) { Role.find_or_create_by(name: 'cfp', resource: conference) } let!(:organizer) { create(:organizer, resource: conference) } let(:user) { create(:user) }