diff --git a/Gemfile b/Gemfile index 50ea0a6f..634d67c8 100755 --- a/Gemfile +++ b/Gemfile @@ -6,18 +6,17 @@ ruby File.read('.ruby-version').strip # the base rails libraries gem 'pg', '~> 0.21.0' -gem 'rails', '~> 3.2.16' +gem 'rails', '~> 4.0.13' gem 'rails_12factor' -gem 'thin' +gem 'puma' # for handling json objects with ruby gem 'json' - -gem 'bootstrap-sass', '~> 3.2.0' -gem 'coffee-rails', '~> 3.2.1' +gem 'protected_attributes' +gem 'bootstrap-sass', '~> 3.4.0' gem 'font-awesome-sass', '~> 4.4.0' gem 'jquery-rails', '2.1.4' -gem 'sass-rails', '~> 3.2.6' +gem 'sass-rails', '~> 5.0' gem 'simple_form' gem 'therubyracer', platforms: :ruby gem 'twitter-bootstrap-rails' @@ -46,17 +45,14 @@ end group :test do gem 'capybara' gem 'capybara-screenshot' - gem 'factory_girl_rails' + gem 'factory_bot_rails' gem 'poltergeist', '~> 1.12' gem 'rack-test' gem 'rspec-rails', '~> 3.5' end -# Temporary fix: https://stackoverflow.com/questions/13828889/rails-3-heroku-cannot-load-such-file-test-unit-testcase-loaderror -# Remove after upgrade of Rails from 3.2 is complete. -gem 'test-unit', '~> 3.0' # dynamic in-place editing for some admin tables -gem 'active_scaffold' +gem 'active_scaffold', '~> 3.4.43' # handles authentication gem 'devise', '~> 3.2.0' @@ -71,7 +67,7 @@ gem 'paperclip', git: 'https://github.com/thoughtbot/paperclip', ref: '523bd46c768226893f23889079a7aa9c73b57d68' # generate pdfs -gem 'prawn', '~> 2.1.0' +gem 'prawn', '~> 2.2.0' gem 'prawn-table', '~> 0.2.2' # used to geo-locate locations @@ -89,12 +85,13 @@ gem 'jquery-datatables-rails', git: 'https://github.com/rweng/jquery-datatables- gem 'cocoon' # set timezone to browser timezone -gem 'browser-timezone-rails', '~> 0.2.00' +gem 'browser-timezone-rails', '~> 1.0' +gem 'js_cookie_rails' gem 'ranked-model' # Send email when exception occurs. -gem 'exception_notification', '~> 3.0.1' -gem 'exception_notification-rake', '~> 0.0.6' +gem 'exception_notification', '~> 4.0.1' +gem 'exception_notification-rake', '~> 0.1.3' gem 'cancancan', '~> 1.15.0' gem 'interactor' diff --git a/Gemfile.lock b/Gemfile.lock index bd3b9d3f..3829ac98 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,39 +23,38 @@ GIT GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.22.5) - actionpack (= 3.2.22.5) - mail (~> 2.5.4) - actionpack (3.2.22.5) - activemodel (= 3.2.22.5) - activesupport (= 3.2.22.5) - builder (~> 3.0.0) + actionmailer (4.0.13) + actionpack (= 4.0.13) + mail (~> 2.5, >= 2.5.4) + actionpack (4.0.13) + activesupport (= 4.0.13) + builder (~> 3.1.0) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) + rack (~> 1.5.2) + rack-test (~> 0.6.2) active_scaffold (3.4.43) rails (>= 3.2.22.2, < 5) - activemodel (3.2.22.5) - activesupport (= 3.2.22.5) - builder (~> 3.0.0) - activerecord (3.2.22.5) - activemodel (= 3.2.22.5) - activesupport (= 3.2.22.5) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.22.5) - activemodel (= 3.2.22.5) - activesupport (= 3.2.22.5) - activesupport (3.2.22.5) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) + activemodel (4.0.13) + activesupport (= 4.0.13) + builder (~> 3.1.0) + activerecord (4.0.13) + activemodel (= 4.0.13) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.13) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.4) + activesupport (4.0.13) + i18n (~> 0.6, >= 0.6.9) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) addressable (2.6.0) public_suffix (>= 2.0.2, < 4.0) - arel (3.0.3) + arel (4.0.2) ast (2.4.0) + autoprefixer-rails (9.4.8) + execjs awesome_print (1.8.0) aws-sdk (2.11.227) aws-sdk-resources (= 2.11.227) @@ -72,15 +71,15 @@ GEM rack (>= 0.9.0) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) - bootstrap-sass (3.2.0.2) - sass (~> 3.2) - browser-timezone-rails (0.2.00) - jquery-cookie-rails - jquery-rails - jstz-rails + bootstrap-sass (3.4.1) + autoprefixer-rails (>= 5.2.1) + sassc (>= 2.0.0) + browser-timezone-rails (1.0.3) + js_cookie_rails + jstz-rails3-plus rails (>= 3.1) buftok (0.2.0) - builder (3.0.4) + builder (3.1.4) byebug (11.0.0) cancancan (1.15.0) capybara (2.18.0) @@ -100,16 +99,8 @@ GEM climate_control (>= 0.0.3, < 1.0) cocoon (1.2.12) coderay (1.1.2) - coffee-rails (3.2.2) - coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.12.2) commonjs (0.2.7) concurrent-ruby (1.1.4) - daemons (1.3.1) debug_inspector (0.0.3) devise (3.2.4) bcrypt (~> 3.0) @@ -127,21 +118,21 @@ GEM equalizer (0.0.11) erubi (1.8.0) erubis (2.7.0) - eventmachine (1.2.7) - exception_notification (3.0.1) + exception_notification (4.0.1) actionmailer (>= 3.0.4) - exception_notification-rake (0.0.7) - exception_notification (~> 3.0.1) + activesupport (>= 3.0.4) + exception_notification-rake (0.1.3) + exception_notification (~> 4.0.1) rake (>= 0.9.0) execjs (2.7.0) - factory_girl (4.9.0) + factory_bot (4.11.1) activesupport (>= 3.0.0) - factory_girl_rails (4.9.0) - factory_girl (~> 4.9.0) + factory_bot_rails (4.11.1) + factory_bot (~> 4.11.1) railties (>= 3.0.0) faker (1.7.3) i18n (~> 0.5) - ffi (1.10.0) + ffi (1.9.25) font-awesome-sass (4.4.0) sass (>= 3.2) formatador (0.2.5) @@ -163,7 +154,6 @@ GEM rspec (>= 2.99.0, < 4.0) highcharts-rails (3.0.10) railties (>= 3.1) - hike (1.2.3) http (3.3.0) addressable (~> 2.3) http-cookie (~> 1.0) @@ -179,38 +169,40 @@ GEM interception (0.5) jaro_winkler (1.5.2) jmespath (1.4.0) - journey (1.0.4) - jquery-cookie-rails (1.3.1.1) - railties (>= 3.2.0, < 5.0) jquery-rails (2.1.4) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) + js_cookie_rails (2.2.0) + railties (>= 3.1) json (2.2.0) - jstz-rails (1.0.4.1) - railties (~> 3.1) + jstz-rails3-plus (1.0.5) + railties (>= 3.1) launchy (2.4.3) addressable (~> 2.3) less (2.6.0) commonjs (~> 0.2.7) - less-rails (2.6.0) - actionpack (>= 3.1) + less-rails (4.0.0) + actionpack (>= 4) less (~> 2.6.0) + sprockets (>= 2) libv8 (3.16.14.19) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) lumberjack (1.0.13) - mail (2.5.5) - mime-types (~> 1.16) - treetop (~> 1.4.8) + mail (2.7.1) + mini_mime (>= 0.1.1) memoizable (0.4.2) thread_safe (~> 0.3, >= 0.3.1) method_source (0.9.2) - mime-types (1.25.1) + mime-types (3.2.2) + mime-types-data (~> 3.2015) + mime-types-data (3.2018.0812) mimemagic (0.3.0) mini_mime (1.0.1) mini_portile2 (2.4.0) + minitest (4.7.5) multi_json (1.13.1) multipart-post (2.0.0) naught (1.1.0) @@ -225,20 +217,20 @@ GEM parallel (1.13.0) parser (2.6.0.0) ast (~> 2.4.0) - pdf-core (0.6.1) + pdf-core (0.7.0) pg (0.21.0) poltergeist (1.18.1) capybara (>= 2.1, < 4) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) - polyglot (0.3.5) - power_assert (1.1.3) powerpack (0.1.2) - prawn (2.1.0) - pdf-core (~> 0.6.1) - ttfunk (~> 1.4.0) + prawn (2.2.2) + pdf-core (~> 0.7.0) + ttfunk (~> 1.5) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) + protected_attributes (1.1.4) + activemodel (>= 4.0.1, < 5.0) pry (0.12.2) coderay (~> 1.1.0) method_source (~> 0.9.0) @@ -255,21 +247,18 @@ GEM pry (>= 0.12.0) psych (3.1.0) public_suffix (3.0.3) - rack (1.4.7) - rack-cache (1.8.0) - rack (>= 0.4) - rack-ssl (1.3.4) - rack + puma (3.12.0) + rack (1.5.5) rack-test (0.6.3) rack (>= 1.0) - rails (3.2.22.5) - actionmailer (= 3.2.22.5) - actionpack (= 3.2.22.5) - activerecord (= 3.2.22.5) - activeresource (= 3.2.22.5) - activesupport (= 3.2.22.5) - bundler (~> 1.0) - railties (= 3.2.22.5) + rails (4.0.13) + actionmailer (= 4.0.13) + actionpack (= 4.0.13) + activerecord (= 4.0.13) + activesupport (= 4.0.13) + bundler (>= 1.3.0, < 2.0) + railties (= 4.0.13) + sprockets-rails (~> 2.0) rails-erd (1.5.2) activerecord (>= 3.2) activesupport (>= 3.2) @@ -280,13 +269,11 @@ GEM rails_stdout_logging rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) - railties (3.2.22.5) - actionpack (= 3.2.22.5) - activesupport (= 3.2.22.5) - rack-ssl (~> 1.3.2) + railties (4.0.13) + actionpack (= 4.0.13) + activesupport (= 4.0.13) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) + thor (>= 0.18.1, < 2.0) rainbow (3.0.0) rake (12.3.2) ranked-model (0.4.1) @@ -294,7 +281,6 @@ GEM rb-fsevent (0.9.8) rb-inotify (0.10.0) ffi (~> 1.0) - rdoc (3.9.5) ref (2.0.0) rspec (3.8.0) rspec-core (~> 3.8.0) @@ -334,38 +320,36 @@ GEM sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (3.2.6) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) + sass-rails (5.0.7) + railties (>= 4.0.0, < 6) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sassc (2.0.0) + ffi (~> 1.9.6) + rake shellany (0.0.1) - simple_form (2.1.3) - actionpack (~> 3.0) - activemodel (~> 3.0) + simple_form (4.0.0) + actionpack (> 4) + activemodel (> 4) simple_oauth (0.3.1) slop (3.6.0) - sprockets (2.2.3) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (2.3.3) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) sqlite3 (1.4.0) - test-unit (3.3.0) - power_assert therubyracer (0.12.3) libv8 (~> 3.16.14.15) ref - thin (1.7.2) - daemons (~> 1.0, >= 1.0.9) - eventmachine (~> 1.0, >= 1.0.4) - rack (>= 1, < 3) thor (0.20.3) thread_safe (0.3.6) - tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - ttfunk (1.4.0) + tilt (2.0.9) + ttfunk (1.5.1) twitter (6.2.0) addressable (~> 2.3) buftok (~> 0.2.0) @@ -404,24 +388,23 @@ PLATFORMS ruby DEPENDENCIES - active_scaffold + active_scaffold (~> 3.4.43) addressable awesome_print aws-sdk (~> 2.3) better_errors binding_of_caller - bootstrap-sass (~> 3.2.0) - browser-timezone-rails (~> 0.2.00) + bootstrap-sass (~> 3.4.0) + browser-timezone-rails (~> 1.0) cancancan (~> 1.15.0) capybara capybara-screenshot cocoon - coffee-rails (~> 3.2.1) devise (~> 3.2.0) dotenv-rails - exception_notification (~> 3.0.1) - exception_notification-rake (~> 0.0.6) - factory_girl_rails + exception_notification (~> 4.0.1) + exception_notification-rake (~> 0.1.3) + factory_bot_rails faker (~> 1.7.3) font-awesome-sass (~> 4.4.0) geocoder @@ -431,31 +414,32 @@ DEPENDENCIES interactor jquery-datatables-rails! jquery-rails (= 2.1.4) + js_cookie_rails json newrelic_rpm paperclip! pg (~> 0.21.0) poltergeist (~> 1.12) - prawn (~> 2.1.0) + prawn (~> 2.2.0) prawn-table (~> 0.2.2) + protected_attributes pry-byebug pry-rails pry-remote pry-rescue + puma rack-test - rails (~> 3.2.16) + rails (~> 4.0.13) rails-erd rails_12factor ranked-model rb-fsevent (~> 0.9.0) rspec-rails (~> 3.5) rubocop - sass-rails (~> 3.2.6) + sass-rails (~> 5.0) simple_form sqlite3 - test-unit (~> 3.0) therubyracer - thin twitter twitter-bootstrap-rails uglifier (>= 1.0.3) diff --git a/Procfile b/Procfile index 91f8d1f6..c2c566e8 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: bundle exec rails server thin -p \$PORT -e \$RACK_ENV +web: bundle exec puma -C config/puma.rb diff --git a/Procfile.dev b/Procfile.dev index 1110b7e0..4b593b4d 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,2 +1,2 @@ -web: bundle exec thin start -p $PORT +web: bundle exec puma -C config/puma.rb rails: tail -f log/development.log diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 352ccb83..4013d0fd 100755 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,11 +12,11 @@ // //= require jquery //= require jquery_ujs -//= require jquery.cookie //= require bootstrap-sprockets //= require dataTables/jquery.dataTables //= require highcharts //= require active_scaffold +//= require js.cookie //= require jstz //= require browser_timezone_rails/set_time_zone //= require cocoon diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.scss similarity index 55% rename from app/assets/stylesheets/application.css.scss rename to app/assets/stylesheets/application.scss index c7b6589c..d2b104b5 100755 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.scss @@ -16,6 +16,15 @@ @import "font-awesome-sprockets"; @import "font-awesome"; -@import "modules/**"; +@import "modules/buttons"; +@import "modules/charts"; +@import "modules/day_times"; +@import "modules/footer"; +@import "modules/forms"; +@import "modules/header"; +@import "modules/scrollbars"; +@import "modules/select2_bootstrap"; +@import "modules/tables"; +@import "modules/typography"; -@import "pages/**"; +@import "pages/home"; diff --git a/app/assets/stylesheets/base/_bootstrap_and_overrides.css.scss b/app/assets/stylesheets/base/_bootstrap_and_overrides.scss similarity index 100% rename from app/assets/stylesheets/base/_bootstrap_and_overrides.css.scss rename to app/assets/stylesheets/base/_bootstrap_and_overrides.scss diff --git a/app/assets/stylesheets/modules/_day_times.css.scss b/app/assets/stylesheets/modules/_day_times.scss similarity index 100% rename from app/assets/stylesheets/modules/_day_times.css.scss rename to app/assets/stylesheets/modules/_day_times.scss diff --git a/app/assets/stylesheets/pages/home.css.scss b/app/assets/stylesheets/pages/home.scss similarity index 100% rename from app/assets/stylesheets/pages/home.css.scss rename to app/assets/stylesheets/pages/home.scss diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 845cfae6..63e34c71 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,6 +8,9 @@ class ApplicationController < ActionController::Base before_filter :authenticate_user_from_token! respond_to :html, :json + layout :layout_by_resource + + alias_method :current_user, :current_volunteer def setup_headers headers['Access-Control-Allow-Origin'] = '*' @@ -35,18 +38,11 @@ def setup_headers end end - alias_method :current_user, :current_volunteer - - layout :layout_by_resource - protected def layout_by_resource - if devise_controller? - 'custom_devise' - else - 'application' - end + return 'custom_devise' if devise_controller? + 'application' end private @@ -54,8 +50,8 @@ def layout_by_resource # add in the variables needed by the form partial for schedules and logs def set_vars_for_form(region) @volunteers = Volunteer.all_for_region(region.id).collect{ |v| [v.name, v.id] } - @donors = Location.donors.where(:region_id=>region.id).collect{ |d| [d.name, d.id] } - @recipients = Location.recipients.where(:region_id=>region.id).collect{ |r| [r.name, r.id] } + @donors = Location.donors.where(region_id: region.id).collect{ |d| [d.name, d.id] } + @recipients = Location.recipients.where(region_id: region.id).collect{ |r| [r.name, r.id] } @transport_types = TransportType.all.collect{ |tt| [tt.name, tt.id] } @food_types = region.food_types.collect { |food_type| [food_type.name, food_type.id] } diff --git a/app/controllers/volunteers_controller.rb b/app/controllers/volunteers_controller.rb index afd947bd..8e68d0e0 100755 --- a/app/controllers/volunteers_controller.rb +++ b/app/controllers/volunteers_controller.rb @@ -25,8 +25,7 @@ def assign else Assignment.add_volunteer_to_region(volunteer, region) unless params[:send_welcome_email].nil? || params[:send_welcome_email].to_i != 1 - message = Notifier.region_welcome_email(region, volunteer) - message&.deliver + Notifier.region_welcome_email(region, volunteer)&.deliver end volunteer.save end @@ -34,7 +33,8 @@ def assign end def shiftless - @volunteers = Volunteer.active_but_shiftless(current_volunteer.region_ids) + @volunteers = Volunteer.includes(:absences, :transport_type, :regions) + .active_but_shiftless(current_volunteer.region_ids) @header = 'Shiftless Volunteers' render :index end @@ -52,7 +52,8 @@ def inactive end def need_training - @volunteers = Volunteer.not_super_admin.needing_training(current_volunteer.region_ids) + @volunteers = Volunteer.not_super_admin + .needing_training(current_volunteer.region_ids) @header = 'Volunteers Needing Training' render :index end diff --git a/app/models/log.rb b/app/models/log.rb index d24182a4..a3bc1e9e 100755 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -10,10 +10,8 @@ class Log < ActiveRecord::Base belongs_to :region has_many :log_volunteers - has_many :volunteers, through: :log_volunteers, - conditions: {'log_volunteers.active' => true} - has_many :inactive_volunteers, through: :log_volunteers, - conditions: {'log_volunteers.active' => false} + has_many :volunteers, -> { where(log_volunteers: { active: true }) }, through: :log_volunteers + has_many :inactive_volunteers, -> { where(log_volunteers: { active: false }) }, through: :log_volunteers has_many :log_recipients has_many :recipients, through: :log_recipients has_many :log_parts @@ -27,14 +25,14 @@ class Log < ActiveRecord::Base accepts_nested_attributes_for :log_volunteers accepts_nested_attributes_for :schedule_chain - validates :notes, presence: { if: Proc.new{ |a| a.complete and a.summed_weight == 0 and a.summed_count == 0 and a.why_zero == 2 }, + validates :notes, presence: { if: Proc.new{ |a| a.complete && a.summed_weight == 0 && a.summed_count == 0 && a.why_zero == 2 }, message: "can't be blank if weights/counts are all zero: let us know what happened!" } validates :transport_type_id, presence: { if: :complete } validates :donor_id, presence: { if: :complete } validates :scale_type_id, presence: { if: :complete } validates :when, presence: true validates :hours_spent, presence: { if: :complete } - validates :why_zero, presence: { if: Proc.new{ |a| a.complete and a.summed_weight == 0 and a.summed_count == 0 } } + validates :why_zero, presence: { if: Proc.new{ |a| a.complete && a.summed_weight == 0 && a.summed_count == 0 } } attr_accessible :region_id, :donor_id, :why_zero, :food_type_id, :transport_type_id, :flag_for_admin, :notes, @@ -46,7 +44,7 @@ class Log < ActiveRecord::Base # units conversion on scale type --- we always store in lbs in the database before_save { |record| return if record.region.nil? - record.scale_type = record.region.scale_types.first if record.scale_type.nil? and record.region.scale_types.length == 1 + record.scale_type = record.region.scale_types.first if record.scale_type.nil? && record.region.scale_types.length == 1 unless record.scale_type.nil? record.weight_unit = record.scale_type.weight_unit if record.weight_unit.nil? record.log_parts.each{ |lp| diff --git a/app/models/schedule.rb b/app/models/schedule.rb index c77c934c..b23404cb 100755 --- a/app/models/schedule.rb +++ b/app/models/schedule.rb @@ -2,13 +2,13 @@ class Schedule < ActiveRecord::Base include RankedModel + default_scope { order(position: :asc) } has_many :logs belongs_to :location belongs_to :schedule_chain ranks :position, with_same: :schedule_chain_id - default_scope order('position ASC') has_many :schedule_parts has_many :food_types, through: :schedule_parts diff --git a/app/models/schedule_chain.rb b/app/models/schedule_chain.rb index 0b0a06bc..db47cb3f 100755 --- a/app/models/schedule_chain.rb +++ b/app/models/schedule_chain.rb @@ -8,8 +8,7 @@ class ScheduleChain < ActiveRecord::Base belongs_to :region has_many :schedule_volunteers - has_many :volunteers, through: :schedule_volunteers, - conditions: { 'schedule_volunteers.active' => true } + has_many :volunteers, -> { where(schedule_volunteers: { active: true }) }, through: :schedule_volunteers has_many :schedules has_many :locations, through: :schedules diff --git a/app/models/schedule_volunteer.rb b/app/models/schedule_volunteer.rb index 907fc9b7..9c315f9e 100755 --- a/app/models/schedule_volunteer.rb +++ b/app/models/schedule_volunteer.rb @@ -7,4 +7,5 @@ class ScheduleVolunteer < ActiveRecord::Base attr_accessible :schedule_chain_id, :volunteer_id, :active accepts_nested_attributes_for :volunteer + scope :active, -> { where(active: true) } end diff --git a/app/models/volunteer.rb b/app/models/volunteer.rb index 5c4c1351..01c42941 100755 --- a/app/models/volunteer.rb +++ b/app/models/volunteer.rb @@ -25,22 +25,13 @@ class Volunteer < ActiveRecord::Base has_many :regions, through: :assignments has_many :schedule_volunteers - has_many :schedule_chains, through: :schedule_volunteers, - conditions: { 'schedule_volunteers.active' => true } - has_many :prior_schedules, through: :schedule_volunteers, - conditions: { 'schedule_volunteers.active' => false }, - class_name: 'ScheduleChain' + has_many :schedule_chains, -> { where(schedule_volunteers: { active: true }) }, through: :schedule_volunteers + has_many :prior_schedules, -> { where(schedule_volunteers: { active: false }) }, through: :schedule_volunteers, class_name: 'ScheduleChain' has_many :log_volunteers - has_many :logs, through: :log_volunteers, - conditions: { log_volunteers: { active: true } } - has_many :completed_logs, through: :log_volunteers, - conditions: { logs: { complete: true } }, - class_name: 'Log', source: :log - - has_many :prior_logs, through: :log_volunteers, - conditions: { 'log_volunteers.active' => false }, - class_name: 'Log' + has_many :logs, -> { where(log_volunteers: { active: true }) }, through: :log_volunteers + has_many :completed_logs, -> { where(logs: { complete: true }) }, through: :log_volunteers, class_name: 'Log', source: :log + has_many :prior_logs, -> { where(log_volunteers: { active: false }) }, through: :log_volunteers, class_name: 'Log', source: :log attr_accessible :pre_reminders_too, :region_ids, :password, :password_confirmation, :remember_me, :admin_notes, :email, diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb index fe620ef4..04922601 100755 --- a/app/views/devise/passwords/edit.html.erb +++ b/app/views/devise/passwords/edit.html.erb @@ -1,6 +1,6 @@

Change your password

-<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %> +<%= form_for(resource, as: resource_name, url: password_path(resource_name), method: :put) do |f| %> <%= devise_error_messages! %> <%= f.hidden_field :reset_password_token %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 8288825b..86113515 100755 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,10 +1,10 @@

Edit <%= resource_name.to_s.humanize %>

-<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> +<%= form_for(resource, as: resource_name, url: registration_path(resource_name), method: :put) do |f| %> <%= devise_error_messages! %>
<%= f.label :password, "New Password" %> - <%= f.password_field :password, :autocomplete => "off" %>
+ <%= f.password_field :password, autocomplete: "off" %>
<%= f.label :password_confirmation , "New Password Confirmation"%> <%= f.password_field :password_confirmation %>
@@ -17,6 +17,6 @@

Unhappy?

-

<%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>

+

<%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>

<%= link_to "Back", :back %> diff --git a/app/views/layouts/custom_devise.html.erb b/app/views/layouts/custom_devise.html.erb index 1e5c3492..8e29e3c5 100755 --- a/app/views/layouts/custom_devise.html.erb +++ b/app/views/layouts/custom_devise.html.erb @@ -5,7 +5,7 @@ - <%= stylesheet_link_tag "application", :media => "all" %> + <%= stylesheet_link_tag "application", media: "all" %> <%= csrf_meta_tags %> @@ -31,7 +31,7 @@

Facts

- <% cache("login_page_stats",:expires_in => 12.hours) do %> + <% cache("login_page_stats", expires_in: 12.hours) do %>