diff --git a/.browserslistrc b/.browserslistrc
new file mode 100644
index 0000000..e94f814
--- /dev/null
+++ b/.browserslistrc
@@ -0,0 +1 @@
+defaults
diff --git a/.gitignore b/.gitignore
index f0fa30c..0d463aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,11 @@
db/*.sqlite3
log/*.log
tmp/
+/public/system
+/public/uploads
+/public/packs
+/public/packs-test
+/node_modules
+/yarn-error.log
+yarn-debug.log*
+.yarn-integrity
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..4af7cfd
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,28 @@
+require:
+ - rubocop-performance
+ - rubocop-rails
+
+AllCops:
+ TargetRailsVersion: 6.0
+ TargetRubyVersion: 2.7
+ NewCops: enable
+ Exclude:
+ - 'bin/*'
+ - 'db/**/*'
+ - 'node_modules/**/*'
+ - 'public/**/*'
+ - 'tmp/**/*'
+ - 'vendor/bundle/**/*'
+
+Layout/LineLength:
+ Enabled: false
+
+Metrics/BlockLength:
+ Exclude:
+ - 'config/**/*'
+
+Rails/HasAndBelongsToMany:
+ Enabled: false
+
+Style/Documentation:
+ Enabled: false
diff --git a/Gemfile b/Gemfile
index 23f6c74..6d3a696 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,22 +1,47 @@
-source 'http://rubygems.org'
-
-gem 'rails', '~> 3.1'
-gem 'cancan'
-gem 'devise', '~> 1.4'
-gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
-gem 'mlb', '~> 0.5'
-gem 'paperclip', '~> 2.4'
-gem 'mini_magick'
-gem 'carrierwave'
-gem 'dragonfly'
-group :production do
- gem 'pg'
-end
+# frozen_string_literal: true
+
+source 'https://rubygems.org'
+
+ruby '2.7.2'
+
+gem 'rails', '6.0.3.4'
+
+gem 'bootsnap', '~> 1.4', require: false
+gem 'puma', '~> 5.0'
+
+gem 'webpacker', '~> 5.2'
+
+gem 'cancancan', '~> 3.1'
+gem 'carrierwave', '~> 2.1'
+gem 'devise', '~> 4.7'
+gem 'dragonfly', '~> 1.2'
+gem 'kt-paperclip', '~> 6.3'
+gem 'mini_magick', '~> 4.10'
+gem 'mlb', '~> 0.7.0'
+gem 'paper_trail', '~> 11.0'
+gem 'paper_trail-association_tracking', '~> 2.1'
+gem 'rails_admin', github: 'sferik/rails_admin'
+
+gem 'sassc-rails', '~> 2.1'
+gem 'uglifier', '~> 4.2'
+
group :development, :test do
- gem 'sqlite3'
+ gem 'sqlite3', '~> 1.4'
end
-group :assets do
- gem 'sass-rails', '~> 3.1'
- gem 'coffee-rails', '~> 3.1'
- gem 'uglifier', '~> 1.0'
+
+group :development do
+ gem 'listen', '~> 3.2'
+ gem 'rubocop', '~> 1.0', require: false
+ gem 'rubocop-performance', '~> 1.8', require: false
+ gem 'rubocop-rails', '~> 2.8', require: false
+ gem 'spring', '~> 2.1'
+ gem 'spring-watcher-listen', '~> 2.0'
+ gem 'web-console', '~> 4.0'
end
+
+group :production do
+ gem 'pg', '~> 1.2'
+end
+
+# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
+gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
diff --git a/Gemfile.lock b/Gemfile.lock
index e90df35..11a8264 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,191 +1,345 @@
GIT
- remote: git://github.com/sferik/rails_admin.git
- revision: c7a6a176f7ac083c2fad39ae087f76c4785e5010
+ remote: https://github.com/sferik/rails_admin.git
+ revision: a2fd16b9f3684b434a3b28bbae5303cceb536e49
specs:
- rails_admin (0.3.0)
- bootstrap-sass (~> 2.1)
- builder (~> 3.0)
- coffee-rails (~> 3.1)
- font-awesome-sass-rails (~> 2.0)
- haml (~> 3.1)
- jquery-rails (~> 2.1)
- jquery-ui-rails (~> 2.0)
- kaminari (~> 0.14)
- nested_form (~> 0.2)
- rack-pjax (~> 0.6)
- rails (~> 3.1)
- remotipart (~> 1.0)
- sass-rails (~> 3.1)
+ rails_admin (2.0.2)
+ activemodel-serializers-xml (>= 1.0)
+ builder (~> 3.1)
+ haml (>= 4.0, < 6)
+ jquery-rails (>= 3.0, < 5)
+ jquery-ui-rails (>= 5.0, < 7)
+ kaminari (>= 0.14, < 2.0)
+ nested_form (~> 0.3)
+ rack-pjax (>= 0.7)
+ rails (>= 5.0, < 7)
+ remotipart (~> 1.3)
+ sassc-rails (>= 1.3, < 3)
GEM
- remote: http://rubygems.org/
+ remote: https://rubygems.org/
specs:
- actionmailer (3.2.9)
- actionpack (= 3.2.9)
- mail (~> 2.4.4)
- actionpack (3.2.9)
- activemodel (= 3.2.9)
- activesupport (= 3.2.9)
- builder (~> 3.0.0)
- erubis (~> 2.7.0)
- journey (~> 1.0.4)
- rack (~> 1.4.0)
- rack-cache (~> 1.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.2.1)
- activemodel (3.2.9)
- activesupport (= 3.2.9)
- builder (~> 3.0.0)
- activerecord (3.2.9)
- activemodel (= 3.2.9)
- activesupport (= 3.2.9)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activeresource (3.2.9)
- activemodel (= 3.2.9)
- activesupport (= 3.2.9)
- activesupport (3.2.9)
- i18n (~> 0.6)
+ actioncable (6.0.3.4)
+ actionpack (= 6.0.3.4)
+ nio4r (~> 2.0)
+ websocket-driver (>= 0.6.1)
+ actionmailbox (6.0.3.4)
+ actionpack (= 6.0.3.4)
+ activejob (= 6.0.3.4)
+ activerecord (= 6.0.3.4)
+ activestorage (= 6.0.3.4)
+ activesupport (= 6.0.3.4)
+ mail (>= 2.7.1)
+ actionmailer (6.0.3.4)
+ actionpack (= 6.0.3.4)
+ actionview (= 6.0.3.4)
+ activejob (= 6.0.3.4)
+ mail (~> 2.5, >= 2.5.4)
+ rails-dom-testing (~> 2.0)
+ actionpack (6.0.3.4)
+ actionview (= 6.0.3.4)
+ activesupport (= 6.0.3.4)
+ rack (~> 2.0, >= 2.0.8)
+ rack-test (>= 0.6.3)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
+ actiontext (6.0.3.4)
+ actionpack (= 6.0.3.4)
+ activerecord (= 6.0.3.4)
+ activestorage (= 6.0.3.4)
+ activesupport (= 6.0.3.4)
+ nokogiri (>= 1.8.5)
+ actionview (6.0.3.4)
+ activesupport (= 6.0.3.4)
+ builder (~> 3.1)
+ erubi (~> 1.4)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
+ activejob (6.0.3.4)
+ activesupport (= 6.0.3.4)
+ globalid (>= 0.3.6)
+ activemodel (6.0.3.4)
+ activesupport (= 6.0.3.4)
+ activemodel-serializers-xml (1.0.2)
+ activemodel (> 5.x)
+ activesupport (> 5.x)
+ builder (~> 3.1)
+ activerecord (6.0.3.4)
+ activemodel (= 6.0.3.4)
+ activesupport (= 6.0.3.4)
+ activestorage (6.0.3.4)
+ actionpack (= 6.0.3.4)
+ activejob (= 6.0.3.4)
+ activerecord (= 6.0.3.4)
+ marcel (~> 0.3.1)
+ activesupport (6.0.3.4)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ i18n (>= 0.7, < 2)
+ minitest (~> 5.1)
+ tzinfo (~> 1.1)
+ zeitwerk (~> 2.2, >= 2.2.2)
+ addressable (2.7.0)
+ public_suffix (>= 2.0.2, < 5.0)
+ ast (2.4.1)
+ bcrypt (3.1.16)
+ bindex (0.8.1)
+ bootsnap (1.4.8)
+ msgpack (~> 1.0)
+ builder (3.2.4)
+ cancancan (3.1.0)
+ carrierwave (2.1.0)
+ activemodel (>= 5.0.0)
+ activesupport (>= 5.0.0)
+ addressable (~> 2.6)
+ image_processing (~> 1.1)
+ mimemagic (>= 0.3.0)
+ mini_mime (>= 0.1.3)
+ climate_control (0.2.0)
+ concurrent-ruby (1.1.7)
+ crass (1.0.6)
+ devise (4.7.3)
+ bcrypt (~> 3.0)
+ orm_adapter (~> 0.1)
+ railties (>= 4.1.0)
+ responders
+ warden (~> 1.2.3)
+ dragonfly (1.2.1)
+ addressable (~> 2.3)
multi_json (~> 1.0)
- arel (3.0.2)
- bcrypt-ruby (3.0.1)
- bootstrap-sass (2.2.1.1)
- sass (~> 3.2)
- builder (3.0.4)
- cancan (1.6.7)
- carrierwave (0.6.2)
- activemodel (>= 3.2.0)
- activesupport (>= 3.2.0)
- cocaine (0.2.1)
- coffee-rails (3.2.2)
- coffee-script (>= 2.2.0)
- railties (~> 3.2.0)
- coffee-script (2.2.0)
- coffee-script-source
- execjs
- coffee-script-source (1.4.0)
- devise (1.5.3)
- bcrypt-ruby (~> 3.0)
- orm_adapter (~> 0.0.3)
- warden (~> 1.1)
- dragonfly (0.9.12)
- rack
- erubis (2.7.0)
- execjs (1.4.0)
- multi_json (~> 1.0)
- faraday (0.8.0)
- multipart-post (~> 1.1)
- faraday_middleware (0.8.7)
- faraday (>= 0.7.4, < 0.9)
- font-awesome-sass-rails (2.0.0.0)
- railties (>= 3.1.1)
- sass-rails (>= 3.1.1)
- haml (3.1.7)
- hike (1.2.1)
- i18n (0.6.1)
- journey (1.0.4)
- jquery-rails (2.1.4)
- railties (>= 3.0, < 5.0)
+ rack (>= 1.3)
+ erubi (1.9.0)
+ execjs (2.7.0)
+ faraday (0.9.2)
+ multipart-post (>= 1.2, < 3)
+ faraday_middleware (0.14.0)
+ faraday (>= 0.7.4, < 1.0)
+ ffi (1.13.1)
+ globalid (0.4.2)
+ activesupport (>= 4.2.0)
+ haml (5.2.0)
+ temple (>= 0.8.0)
+ tilt
+ i18n (1.8.5)
+ concurrent-ruby (~> 1.0)
+ image_processing (1.12.0)
+ mini_magick (>= 4.9.5, < 5)
+ ruby-vips (>= 2.0.17, < 3)
+ jquery-rails (4.4.0)
+ rails-dom-testing (>= 1, < 3)
+ railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
- jquery-ui-rails (2.0.2)
- jquery-rails
- railties (>= 3.1.0)
- json (1.7.5)
- kaminari (0.14.1)
- actionpack (>= 3.0.0)
- activesupport (>= 3.0.0)
- mail (2.4.4)
- i18n (>= 0.4.0)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
- mime-types (1.19)
- mini_magick (3.4)
- subexec (~> 0.2.1)
- mlb (0.6.1)
- faraday (~> 0.8)
- faraday_middleware (~> 0.8)
- json (~> 1.7)
- multi_json (~> 1.3)
- multi_json (1.4.0)
- multipart-post (1.1.5)
- nested_form (0.3.1)
- nokogiri (1.5.5)
- orm_adapter (0.0.7)
- paperclip (2.7.0)
- activerecord (>= 2.3.0)
- activesupport (>= 2.3.2)
- cocaine (>= 0.0.2)
+ jquery-ui-rails (6.0.1)
+ railties (>= 3.2.16)
+ json (1.8.6)
+ kaminari (1.2.1)
+ activesupport (>= 4.1.0)
+ kaminari-actionview (= 1.2.1)
+ kaminari-activerecord (= 1.2.1)
+ kaminari-core (= 1.2.1)
+ kaminari-actionview (1.2.1)
+ actionview
+ kaminari-core (= 1.2.1)
+ kaminari-activerecord (1.2.1)
+ activerecord
+ kaminari-core (= 1.2.1)
+ kaminari-core (1.2.1)
+ kt-paperclip (6.3.0)
+ activemodel (>= 4.2.0)
+ activesupport (>= 4.2.0)
mime-types
- pg (0.13.2)
- polyglot (0.3.3)
- rack (1.4.1)
- rack-cache (1.2)
- rack (>= 0.4)
- rack-pjax (0.6.0)
+ mimemagic (~> 0.3.0)
+ terrapin (~> 0.6.0)
+ listen (3.2.1)
+ rb-fsevent (~> 0.10, >= 0.10.3)
+ rb-inotify (~> 0.9, >= 0.9.10)
+ loofah (2.7.0)
+ crass (~> 1.0.2)
+ nokogiri (>= 1.5.9)
+ mail (2.7.1)
+ mini_mime (>= 0.1.1)
+ marcel (0.3.3)
+ mimemagic (~> 0.3.2)
+ method_source (1.0.0)
+ mime-types (3.3.1)
+ mime-types-data (~> 3.2015)
+ mime-types-data (3.2020.0512)
+ mimemagic (0.3.5)
+ mini_magick (4.10.1)
+ mini_mime (1.0.2)
+ mini_portile2 (2.4.0)
+ minitest (5.14.2)
+ mlb (0.7.0)
+ faraday (~> 0.8, < 0.10)
+ faraday_middleware (~> 0.9)
+ json (~> 1.8)
+ msgpack (1.3.3)
+ multi_json (1.15.0)
+ multipart-post (2.1.1)
+ nested_form (0.3.2)
+ nio4r (2.5.4)
+ nokogiri (1.10.10)
+ mini_portile2 (~> 2.4.0)
+ orm_adapter (0.5.0)
+ paper_trail (11.0.0)
+ activerecord (>= 5.2)
+ request_store (~> 1.1)
+ paper_trail-association_tracking (2.1.1)
+ parallel (1.19.2)
+ parser (2.7.2.0)
+ ast (~> 2.4.1)
+ pg (1.2.3)
+ public_suffix (4.0.6)
+ puma (5.0.2)
+ nio4r (~> 2.0)
+ rack (2.2.3)
+ rack-pjax (1.1.0)
nokogiri (~> 1.5)
- rack (~> 1.3)
- rack-ssl (1.3.2)
+ rack (>= 1.1)
+ rack-proxy (0.6.5)
rack
- rack-test (0.6.2)
- rack (>= 1.0)
- rails (3.2.9)
- actionmailer (= 3.2.9)
- actionpack (= 3.2.9)
- activerecord (= 3.2.9)
- activeresource (= 3.2.9)
- activesupport (= 3.2.9)
- bundler (~> 1.0)
- railties (= 3.2.9)
- railties (3.2.9)
- actionpack (= 3.2.9)
- activesupport (= 3.2.9)
- rack-ssl (~> 1.3.2)
+ rack-test (1.1.0)
+ rack (>= 1.0, < 3)
+ rails (6.0.3.4)
+ actioncable (= 6.0.3.4)
+ actionmailbox (= 6.0.3.4)
+ actionmailer (= 6.0.3.4)
+ actionpack (= 6.0.3.4)
+ actiontext (= 6.0.3.4)
+ actionview (= 6.0.3.4)
+ activejob (= 6.0.3.4)
+ activemodel (= 6.0.3.4)
+ activerecord (= 6.0.3.4)
+ activestorage (= 6.0.3.4)
+ activesupport (= 6.0.3.4)
+ bundler (>= 1.3.0)
+ railties (= 6.0.3.4)
+ sprockets-rails (>= 2.0.0)
+ rails-dom-testing (2.0.3)
+ activesupport (>= 4.2.0)
+ nokogiri (>= 1.6)
+ rails-html-sanitizer (1.3.0)
+ loofah (~> 2.3)
+ railties (6.0.3.4)
+ actionpack (= 6.0.3.4)
+ activesupport (= 6.0.3.4)
+ method_source
rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (>= 0.14.6, < 2.0)
- rake (10.0.2)
- rdoc (3.12)
- json (~> 1.4)
- remotipart (1.0.2)
- sass (3.2.3)
- sass-rails (3.2.5)
- railties (~> 3.2.0)
- sass (>= 3.1.10)
- tilt (~> 1.3)
- sprockets (2.2.2)
- hike (~> 1.2)
- multi_json (~> 1.0)
- rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.6)
- subexec (0.2.2)
- thor (0.16.0)
- tilt (1.3.3)
- treetop (1.4.12)
- polyglot
- polyglot (>= 0.3.1)
- tzinfo (0.3.35)
- uglifier (1.2.4)
- execjs (>= 0.3.0)
- multi_json (>= 1.0.2)
- warden (1.1.1)
- rack (>= 1.0)
+ thor (>= 0.20.3, < 2.0)
+ rainbow (3.0.0)
+ rake (13.0.1)
+ rb-fsevent (0.10.4)
+ rb-inotify (0.10.1)
+ ffi (~> 1.0)
+ regexp_parser (1.8.2)
+ remotipart (1.4.4)
+ request_store (1.5.0)
+ rack (>= 1.4)
+ responders (3.0.1)
+ actionpack (>= 5.0)
+ railties (>= 5.0)
+ rexml (3.2.4)
+ rubocop (1.0.0)
+ parallel (~> 1.10)
+ parser (>= 2.7.1.5)
+ rainbow (>= 2.2.2, < 4.0)
+ regexp_parser (>= 1.8)
+ rexml
+ rubocop-ast (>= 0.6.0)
+ ruby-progressbar (~> 1.7)
+ unicode-display_width (>= 1.4.0, < 2.0)
+ rubocop-ast (1.0.1)
+ parser (>= 2.7.1.5)
+ rubocop-performance (1.8.1)
+ rubocop (>= 0.87.0)
+ rubocop-ast (>= 0.4.0)
+ rubocop-rails (2.8.1)
+ activesupport (>= 4.2.0)
+ rack (>= 1.1)
+ rubocop (>= 0.87.0)
+ ruby-progressbar (1.10.1)
+ ruby-vips (2.0.17)
+ ffi (~> 1.9)
+ sassc (2.4.0)
+ ffi (~> 1.9)
+ sassc-rails (2.1.2)
+ railties (>= 4.0.0)
+ sassc (>= 2.0)
+ sprockets (> 3.0)
+ sprockets-rails
+ tilt
+ semantic_range (2.3.0)
+ spring (2.1.1)
+ spring-watcher-listen (2.0.1)
+ listen (>= 2.7, < 4.0)
+ spring (>= 1.2, < 3.0)
+ sprockets (4.0.2)
+ concurrent-ruby (~> 1.0)
+ rack (> 1, < 3)
+ sprockets-rails (3.2.2)
+ actionpack (>= 4.0)
+ activesupport (>= 4.0)
+ sprockets (>= 3.0.0)
+ sqlite3 (1.4.2)
+ temple (0.8.2)
+ terrapin (0.6.0)
+ climate_control (>= 0.0.3, < 1.0)
+ thor (1.0.1)
+ thread_safe (0.3.6)
+ tilt (2.0.10)
+ tzinfo (1.2.7)
+ thread_safe (~> 0.1)
+ uglifier (4.2.0)
+ execjs (>= 0.3.0, < 3)
+ unicode-display_width (1.7.0)
+ warden (1.2.9)
+ rack (>= 2.0.9)
+ web-console (4.0.4)
+ actionview (>= 6.0.0)
+ activemodel (>= 6.0.0)
+ bindex (>= 0.4.0)
+ railties (>= 6.0.0)
+ webpacker (5.2.1)
+ activesupport (>= 5.2)
+ rack-proxy (>= 0.6.1)
+ railties (>= 5.2)
+ semantic_range (>= 2.3.0)
+ websocket-driver (0.7.3)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.5)
+ zeitwerk (2.4.0)
PLATFORMS
ruby
DEPENDENCIES
- cancan
- carrierwave
- coffee-rails (~> 3.1)
- devise (~> 1.4)
- dragonfly
- mini_magick
- mlb (~> 0.5)
- paperclip (~> 2.4)
- pg
- rails (~> 3.1)
+ bootsnap (~> 1.4)
+ cancancan (~> 3.1)
+ carrierwave (~> 2.1)
+ devise (~> 4.7)
+ dragonfly (~> 1.2)
+ kt-paperclip (~> 6.3)
+ listen (~> 3.2)
+ mini_magick (~> 4.10)
+ mlb (~> 0.7.0)
+ paper_trail (~> 11.0)
+ paper_trail-association_tracking (~> 2.1)
+ pg (~> 1.2)
+ puma (~> 5.0)
+ rails (= 6.0.3.4)
rails_admin!
- sass-rails (~> 3.1)
- sqlite3
- uglifier (~> 1.0)
+ rubocop (~> 1.0)
+ rubocop-performance (~> 1.8)
+ rubocop-rails (~> 2.8)
+ sassc-rails (~> 2.1)
+ spring (~> 2.1)
+ spring-watcher-listen (~> 2.0)
+ sqlite3 (~> 1.4)
+ tzinfo-data
+ uglifier (~> 4.2)
+ web-console (~> 4.0)
+ webpacker (~> 5.2)
+
+RUBY VERSION
+ ruby 2.7.2p137
+
+BUNDLED WITH
+ 2.1.4
diff --git a/README b/README
deleted file mode 100644
index fe7013d..0000000
--- a/README
+++ /dev/null
@@ -1,256 +0,0 @@
-== Welcome to Rails
-
-Rails is a web-application framework that includes everything needed to create
-database-backed web applications according to the Model-View-Control pattern.
-
-This pattern splits the view (also called the presentation) into "dumb"
-templates that are primarily responsible for inserting pre-built data in between
-HTML tags. The model contains the "smart" domain objects (such as Account,
-Product, Person, Post) that holds all the business logic and knows how to
-persist themselves to a database. The controller handles the incoming requests
-(such as Save New Account, Update Product, Show Post) by manipulating the model
-and directing data to the view.
-
-In Rails, the model is handled by what's called an object-relational mapping
-layer entitled Active Record. This layer allows you to present the data from
-database rows as objects and embellish these data objects with business logic
-methods. You can read more about Active Record in
-link:files/vendor/rails/activerecord/README.html.
-
-The controller and view are handled by the Action Pack, which handles both
-layers by its two parts: Action View and Action Controller. These two layers
-are bundled in a single package due to their heavy interdependence. This is
-unlike the relationship between the Active Record and Action Pack that is much
-more separate. Each of these packages can be used independently outside of
-Rails. You can read more about Action Pack in
-link:files/vendor/rails/actionpack/README.html.
-
-
-== Getting Started
-
-1. At the command prompt, create a new Rails application:
- rails new myapp (where myapp is the application name)
-
-2. Change directory to myapp and start the web server:
- cd myapp; rails server (run with --help for options)
-
-3. Go to http://localhost:3000/ and you'll see:
- "Welcome aboard: You're riding Ruby on Rails!"
-
-4. Follow the guidelines to start developing your application. You can find
-the following resources handy:
-
-* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
-* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
-
-
-== Debugging Rails
-
-Sometimes your application goes wrong. Fortunately there are a lot of tools that
-will help you debug it and get it back on the rails.
-
-First area to check is the application log files. Have "tail -f" commands
-running on the server.log and development.log. Rails will automatically display
-debugging and runtime information to these files. Debugging info will also be
-shown in the browser on requests from 127.0.0.1.
-
-You can also log your own messages directly into the log file from your code
-using the Ruby logger class from inside your controllers. Example:
-
- class WeblogController < ActionController::Base
- def destroy
- @weblog = Weblog.find(params[:id])
- @weblog.destroy
- logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
- end
- end
-
-The result will be a message in your log file along the lines of:
-
- Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
-
-More information on how to use the logger is at http://www.ruby-doc.org/core/
-
-Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
-several books available online as well:
-
-* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
-* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
-
-These two books will bring you up to speed on the Ruby language and also on
-programming in general.
-
-
-== Debugger
-
-Debugger support is available through the debugger command when you start your
-Mongrel or WEBrick server with --debugger. This means that you can break out of
-execution at any point in the code, investigate and change the model, and then,
-resume execution! You need to install ruby-debug to run the server in debugging
-mode. With gems, use sudo gem install ruby-debug. Example:
-
- class WeblogController < ActionController::Base
- def index
- @posts = Post.find(:all)
- debugger
- end
- end
-
-So the controller will accept the action, run the first line, then present you
-with a IRB prompt in the server window. Here you can do things like:
-
- >> @posts.inspect
- => "[#nil, "body"=>nil, "id"=>"1"}>,
- #"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
- >> @posts.first.title = "hello from a debugger"
- => "hello from a debugger"
-
-...and even better, you can examine how your runtime objects actually work:
-
- >> f = @posts.first
- => #nil, "body"=>nil, "id"=>"1"}>
- >> f.
- Display all 152 possibilities? (y or n)
-
-Finally, when you're ready to resume execution, you can enter "cont".
-
-
-== Console
-
-The console is a Ruby shell, which allows you to interact with your
-application's domain model. Here you'll have all parts of the application
-configured, just like it is when the application is running. You can inspect
-domain models, change values, and save to the database. Starting the script
-without arguments will launch it in the development environment.
-
-To start the console, run rails console from the application
-directory.
-
-Options:
-
-* Passing the -s, --sandbox argument will rollback any modifications
- made to the database.
-* Passing an environment name as an argument will load the corresponding
- environment. Example: rails console production.
-
-To reload your controllers and models after launching the console run
-reload!
-
-More information about irb can be found at:
-link:http://www.rubycentral.com/pickaxe/irb.html
-
-
-== dbconsole
-
-You can go to the command line of your database directly through rails
-dbconsole. You would be connected to the database with the credentials
-defined in database.yml. Starting the script without arguments will connect you
-to the development database. Passing an argument will connect you to a different
-database, like rails dbconsole production. Currently works for MySQL,
-PostgreSQL and SQLite 3.
-
-== Description of Contents
-
-The default directory structure of a generated Ruby on Rails application:
-
- |-- app
- | |-- controllers
- | |-- helpers
- | |-- mailers
- | |-- models
- | `-- views
- | `-- layouts
- |-- config
- | |-- environments
- | |-- initializers
- | `-- locales
- |-- db
- |-- doc
- |-- lib
- | `-- tasks
- |-- log
- |-- public
- | |-- images
- | |-- javascripts
- | `-- stylesheets
- |-- script
- |-- test
- | |-- fixtures
- | |-- functional
- | |-- integration
- | |-- performance
- | `-- unit
- |-- tmp
- | |-- cache
- | |-- pids
- | |-- sessions
- | `-- sockets
- `-- vendor
- `-- plugins
-
-app
- Holds all the code that's specific to this particular application.
-
-app/controllers
- Holds controllers that should be named like weblogs_controller.rb for
- automated URL mapping. All controllers should descend from
- ApplicationController which itself descends from ActionController::Base.
-
-app/models
- Holds models that should be named like post.rb. Models descend from
- ActiveRecord::Base by default.
-
-app/views
- Holds the template files for the view that should be named like
- weblogs/index.html.erb for the WeblogsController#index action. All views use
- eRuby syntax by default.
-
-app/views/layouts
- Holds the template files for layouts to be used with views. This models the
- common header/footer method of wrapping views. In your views, define a layout
- using the layout :default and create a file named default.html.erb.
- Inside default.html.erb, call <% yield %> to render the view using this
- layout.
-
-app/helpers
- Holds view helpers that should be named like weblogs_helper.rb. These are
- generated for you automatically when using generators for controllers.
- Helpers can be used to wrap functionality for your views into methods.
-
-config
- Configuration files for the Rails environment, the routing map, the database,
- and other dependencies.
-
-db
- Contains the database schema in schema.rb. db/migrate contains all the
- sequence of Migrations for your schema.
-
-doc
- This directory is where your application documentation will be stored when
- generated using rake doc:app
-
-lib
- Application specific libraries. Basically, any kind of custom code that
- doesn't belong under controllers, models, or helpers. This directory is in
- the load path.
-
-public
- The directory available for the web server. Contains subdirectories for
- images, stylesheets, and javascripts. Also contains the dispatchers and the
- default HTML files. This should be set as the DOCUMENT_ROOT of your web
- server.
-
-script
- Helper scripts for automation and generation.
-
-test
- Unit and functional tests along with fixtures. When using the rails generate
- command, template test files will be generated for you and placed in this
- directory.
-
-vendor
- External libraries that the application depends on. Also includes the plugins
- subdirectory. If the app has frozen rails, those gems also go here, under
- vendor/rails/. This directory is in the load path.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5bf12d5
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+# Rails Admin Demo
+
+[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
diff --git a/Rakefile b/Rakefile
index cc8b49a..488c551 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,7 +1,8 @@
+# frozen_string_literal: true
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
-require File.expand_path('../config/application', __FILE__)
-require 'rake'
+require_relative 'config/application'
-DummyApp::Application.load_tasks
+Rails.application.load_tasks
diff --git a/app.json b/app.json
new file mode 100644
index 0000000..fc32a71
--- /dev/null
+++ b/app.json
@@ -0,0 +1,47 @@
+{
+ "name": "Rails Admin Dummy App",
+ "description": "Demo Application for Rails Admin",
+ "keywords": [
+ "Rails Admin",
+ "Ruby 2.7",
+ "Rails 6.0",
+ "Bootstrap 3"
+ ],
+ "website": "https://rails-admin-demo.herokuapp.com/",
+ "repository": "https://github.com/tagliala/dummy_app",
+ "success_url": "/",
+ "scripts": {
+ "postdeploy": "bundle exec rails db:schema:load db:seed"
+ },
+ "env": {
+ "DRAGONFLY_SECRET": {
+ "description": "This gets generated",
+ "generator": "secret"
+ },
+ "RAILS_ENV": "production",
+ "RAILS_SERVE_STATIC_FILES": "enabled",
+ "RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR": {
+ "description": "Reduces RGenGC's memory consumption",
+ "value": "1.3"
+ },
+ "SECRET_KEY_BASE": {
+ "description": "This gets generated",
+ "generator": "secret"
+ }
+ },
+ "addons": [
+ "heroku-postgresql:hobby-dev",
+ "papertrail"
+ ],
+ "buildpacks": [
+ {
+ "url": "https://github.com/heroku/heroku-buildpack-activestorage-preview"
+ },
+ {
+ "url": "heroku/nodejs"
+ },
+ {
+ "url": "heroku/ruby"
+ }
+ ]
+}
diff --git a/app/.DS_Store b/app/.DS_Store
deleted file mode 100644
index ecc4ccd..0000000
Binary files a/app/.DS_Store and /dev/null differ
diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js
new file mode 100644
index 0000000..1f88c80
--- /dev/null
+++ b/app/assets/config/manifest.js
@@ -0,0 +1,2 @@
+//= link_tree ../images
+//= link application.css
diff --git a/vendor/plugins/.gitkeep b/app/assets/images/.keep
similarity index 100%
rename from vendor/plugins/.gitkeep
rename to app/assets/images/.keep
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
new file mode 100644
index 0000000..d05ea0f
--- /dev/null
+++ b/app/assets/stylesheets/application.css
@@ -0,0 +1,15 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
+ * files in this directory. Styles in this file should be added after the last require_* statement.
+ * It is generally better to create a new file per style scope.
+ *
+ *= require_tree .
+ *= require_self
+ */
diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb
new file mode 100644
index 0000000..9aec230
--- /dev/null
+++ b/app/channels/application_cable/channel.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+
+module ApplicationCable
+ class Channel < ActionCable::Channel::Base
+ end
+end
diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb
new file mode 100644
index 0000000..8d6c2a1
--- /dev/null
+++ b/app/channels/application_cable/connection.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+
+module ApplicationCable
+ class Connection < ActionCable::Connection::Base
+ end
+end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e8065d9..9c4e35b 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ApplicationController < ActionController::Base
protect_from_forgery
end
diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index de6be79..15b06f0 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
module ApplicationHelper
end
diff --git a/app/javascript/channels/consumer.js b/app/javascript/channels/consumer.js
new file mode 100644
index 0000000..0eceb59
--- /dev/null
+++ b/app/javascript/channels/consumer.js
@@ -0,0 +1,6 @@
+// Action Cable provides the framework to deal with WebSockets in Rails.
+// You can generate new channels where WebSocket features live using the `rails generate channel` command.
+
+import { createConsumer } from "@rails/actioncable"
+
+export default createConsumer()
diff --git a/app/javascript/channels/index.js b/app/javascript/channels/index.js
new file mode 100644
index 0000000..0cfcf74
--- /dev/null
+++ b/app/javascript/channels/index.js
@@ -0,0 +1,5 @@
+// Load all the channels within this directory and all subdirectories.
+// Channel files must be named *_channel.js.
+
+const channels = require.context('.', true, /_channel\.js$/)
+channels.keys().forEach(channels)
diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js
new file mode 100644
index 0000000..c5c71d5
--- /dev/null
+++ b/app/javascript/packs/application.js
@@ -0,0 +1,16 @@
+// This file is automatically compiled by Webpack, along with any other files
+// present in this directory. You're encouraged to place your actual application logic in
+// a relevant structure within app/javascript and only use these pack files to reference
+// that code so it'll be compiled.
+
+require("@rails/ujs").start()
+require("@rails/activestorage").start()
+require("channels")
+
+
+// Uncomment to copy all static images under ../images to the output folder and reference
+// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
+// or the `imagePath` JavaScript helper below.
+//
+// const images = require.context('../images', true)
+// const imagePath = (name) => images(name, true)
diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb
new file mode 100644
index 0000000..bef3959
--- /dev/null
+++ b/app/jobs/application_job.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class ApplicationJob < ActiveJob::Base
+ # Automatically retry jobs that encountered a deadlock
+ # retry_on ActiveRecord::Deadlocked
+
+ # Most jobs are safe to ignore if the underlying records are no longer available
+ # discard_on ActiveJob::DeserializationError
+end
diff --git a/app/locales/models.en.yml b/app/locales/models.en.yml
deleted file mode 100644
index 53adb97..0000000
--- a/app/locales/models.en.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-en:
- activerecord:
- attributes:
- fan:
- name: His Name
- team:
- manager: Team Manager
- fans: Some Fans
\ No newline at end of file
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
new file mode 100644
index 0000000..d84cb6e
--- /dev/null
+++ b/app/mailers/application_mailer.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+
+class ApplicationMailer < ActionMailer::Base
+ default from: 'from@example.com'
+ layout 'mailer'
+end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 8ec4776..6c402ce 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -1,8 +1,10 @@
+# frozen_string_literal: true
+
class Ability
include CanCan::Ability
- def initialize(user)
+ def initialize(_user)
can :manage, :all
- cannot [:update, :destroy], User, :email => 'username@example.com'
+ cannot %i[update destroy], User, email: 'username@example.com'
end
end
diff --git a/app/models/abstract.rb b/app/models/abstract.rb
index 54c5fa2..c77e032 100644
--- a/app/models/abstract.rb
+++ b/app/models/abstract.rb
@@ -1,5 +1,5 @@
-class Abstract < ActiveRecord::Base
-
- self.abstract_class = true
+# frozen_string_literal: true
+class Abstract < ApplicationRecord
+ self.abstract_class = true
end
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
new file mode 100644
index 0000000..71fbba5
--- /dev/null
+++ b/app/models/application_record.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+class ApplicationRecord < ActiveRecord::Base
+ self.abstract_class = true
+end
diff --git a/app/models/ball.rb b/app/models/ball.rb
index fd0de14..4cddb68 100644
--- a/app/models/ball.rb
+++ b/app/models/ball.rb
@@ -1,8 +1,11 @@
-class Ball < ActiveRecord::Base
+# frozen_string_literal: true
- validates_presence_of :color
+class Ball < ApplicationRecord
+ has_paper_trail
+
+ validates :color, presence: true
def to_param
- color.present? ? color.downcase.gsub(" ", "-") : id
+ color.present? ? color.downcase.tr(' ', '-') : id
end
end
diff --git a/app/models/cms.rb b/app/models/cms.rb
index a868656..bb97036 100644
--- a/app/models/cms.rb
+++ b/app/models/cms.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
module Cms
def self.table_name_prefix
'cms_'
diff --git a/app/models/cms/basic_page.rb b/app/models/cms/basic_page.rb
index 4292222..b940f22 100644
--- a/app/models/cms/basic_page.rb
+++ b/app/models/cms/basic_page.rb
@@ -1,7 +1,11 @@
+# frozen_string_literal: true
+
module Cms
- class BasicPage < ActiveRecord::Base
- set_table_name :cms_basic_pages
-
- validates :title, :content, :presence => true
+ class BasicPage < ApplicationRecord
+ has_paper_trail
+
+ self.table_name_prefix = :cms
+
+ validates :title, :content, presence: true
end
end
diff --git a/app/models/cms/unscoped_page.rb b/app/models/cms/unscoped_page.rb
index 0aec4de..5fed6f7 100644
--- a/app/models/cms/unscoped_page.rb
+++ b/app/models/cms/unscoped_page.rb
@@ -1,3 +1,7 @@
-class UnscopedPage < ActiveRecord::Base
-
-end
\ No newline at end of file
+# frozen_string_literal: true
+
+module Cms
+ class UnscopedPage < ApplicationRecord
+ has_paper_trail
+ end
+end
diff --git a/app/models/comment.rb b/app/models/comment.rb
index d25c20b..96e977b 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -1,3 +1,6 @@
-class Comment < ActiveRecord::Base
- belongs_to :commentable, :polymorphic => true
+# frozen_string_literal: true
+
+class Comment < ApplicationRecord
+ has_paper_trail
+ belongs_to :commentable, polymorphic: true
end
diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/app/models/division.rb b/app/models/division.rb
index d9490f5..dc5b492 100644
--- a/app/models/division.rb
+++ b/app/models/division.rb
@@ -1,8 +1,12 @@
-class Division < ActiveRecord::Base
- set_primary_key :custom_id
- validates_numericality_of(:custom_league_id, :only_integer => true)
- validates_presence_of(:name)
+# frozen_string_literal: true
- belongs_to :league, :foreign_key => 'custom_league_id'
- has_many :teams
+class Division < ApplicationRecord
+ has_paper_trail
+
+ self.primary_key = :custom_id
+ validates :custom_league_id, numericality: { only_integer: true }
+ validates :name, presence: true
+
+ belongs_to :league, foreign_key: 'custom_league_id', inverse_of: :divisions
+ has_many :teams, dependent: :destroy
end
diff --git a/app/models/draft.rb b/app/models/draft.rb
index 5c5219d..5db63c6 100644
--- a/app/models/draft.rb
+++ b/app/models/draft.rb
@@ -1,10 +1,14 @@
-class Draft < ActiveRecord::Base
- validates_numericality_of(:player_id, :only_integer => true)
- validates_numericality_of(:team_id, :only_integer => true)
- validates_presence_of(:date)
- validates_numericality_of(:round, :only_integer => true)
- validates_numericality_of(:pick, :only_integer => true)
- validates_numericality_of(:overall, :only_integer => true)
+# frozen_string_literal: true
+
+class Draft < ApplicationRecord
+ has_paper_trail
+
+ validates :player_id, numericality: { only_integer: true }
+ validates :team_id, numericality: { only_integer: true }
+ validates :date, presence: true
+ validates :round, numericality: { only_integer: true }
+ validates :pick, numericality: { only_integer: true }
+ validates :overall, numericality: { only_integer: true }
belongs_to(:team)
belongs_to(:player)
diff --git a/app/models/fan.rb b/app/models/fan.rb
index 927da80..01ff7c3 100644
--- a/app/models/fan.rb
+++ b/app/models/fan.rb
@@ -1,5 +1,9 @@
-class Fan < ActiveRecord::Base
- validates_presence_of(:name)
- belongs_to :fanable, :polymorphic => true
+# frozen_string_literal: true
+
+class Fan < ApplicationRecord
+ has_paper_trail
+
+ validates :name, presence: true
+ belongs_to :fanable, polymorphic: true
has_and_belongs_to_many :teams
end
diff --git a/app/models/field_test.rb b/app/models/field_test.rb
index f39b17a..d00254d 100644
--- a/app/models/field_test.rb
+++ b/app/models/field_test.rb
@@ -1,18 +1,20 @@
-class FieldTest < ActiveRecord::Base
- attr_accessible :comment_attributes, :nested_field_tests_attributes, :dragonfly_asset, :remove_dragonfly_asset, :retained_dragonfly_asset, :carrierwave_asset, :carrierwave_asset_cache, :remove_carrierwave_asset, :paperclip_asset, :delete_paperclip_asset, :comment_id, :string_field, :text_field, :integer_field, :float_field, :decimal_field, :datetime_field, :timestamp_field, :time_field, :date_field, :boolean_field, :created_at, :updated_at, :format
- attr_accessible :comment_attributes, :nested_field_tests_attributes, :dragonfly_asset, :remove_dragonfly_asset, :retained_dragonfly_asset, :carrierwave_asset, :carrierwave_asset_cache, :remove_carrierwave_asset, :paperclip_asset, :delete_paperclip_asset, :comment_id, :string_field, :text_field, :integer_field, :float_field, :decimal_field, :datetime_field, :timestamp_field, :time_field, :date_field, :boolean_field, :created_at, :updated_at, :format, :restricted_field, :as => :custom_role
- attr_accessible :comment_attributes, :nested_field_tests_attributes, :dragonfly_asset, :remove_dragonfly_asset, :retained_dragonfly_asset, :carrierwave_asset, :carrierwave_asset_cache, :remove_carrierwave_asset, :paperclip_asset, :delete_paperclip_asset, :comment_id, :string_field, :text_field, :integer_field, :float_field, :decimal_field, :datetime_field, :timestamp_field, :time_field, :date_field, :boolean_field, :created_at, :updated_at, :format, :protected_field, :as => :extra_safe_role
-
- has_many :nested_field_tests, :dependent => :destroy, :inverse_of => :field_test
- accepts_nested_attributes_for :nested_field_tests, :allow_destroy => true
-
- has_one :comment, :as => :commentable
- accepts_nested_attributes_for :comment, :allow_destroy => true
-
- has_attached_file :paperclip_asset, :styles => { :thumb => "100x100>" }
+# frozen_string_literal: true
+
+class FieldTest < ApplicationRecord
+ has_paper_trail
+
+ has_many :nested_field_tests, dependent: :destroy, inverse_of: :field_test
+ accepts_nested_attributes_for :nested_field_tests, allow_destroy: true
+
+ has_one :comment, as: :commentable, dependent: :destroy
+ accepts_nested_attributes_for :comment, allow_destroy: true
+
+ has_attached_file :paperclip_asset, styles: { thumb: '100x100>' }
+ validates_attachment_content_type :paperclip_asset, content_type: %r{\Aimage/.*\z}
attr_accessor :delete_paperclip_asset
- before_validation { self.paperclip_asset = nil if self.delete_paperclip_asset == '1' }
- image_accessor :dragonfly_asset
+ before_validation { self.paperclip_asset = nil if delete_paperclip_asset == '1' }
+
+ dragonfly_accessor :dragonfly_asset
mount_uploader :carrierwave_asset, CarrierwaveUploader
end
diff --git a/app/models/league.rb b/app/models/league.rb
index ee5dc0c..9dcb3ba 100644
--- a/app/models/league.rb
+++ b/app/models/league.rb
@@ -1,10 +1,14 @@
-class League < ActiveRecord::Base
- validates_presence_of(:name)
+# frozen_string_literal: true
- has_many :divisions, :foreign_key => 'custom_league_id'
- has_many :teams, :through => :divisions, :readonly => true
+class League < ApplicationRecord
+ has_paper_trail
+
+ validates :name, presence: true
+
+ has_many :divisions, foreign_key: 'custom_league_id', inverse_of: :league, dependent: :destroy
+ has_many :teams, -> { readonly }, through: :divisions
def custom_name
- "League '#{self.name}'"
+ "League '#{name}'"
end
end
diff --git a/app/models/nested_field_test.rb b/app/models/nested_field_test.rb
index 0009b9e..5ed42eb 100644
--- a/app/models/nested_field_test.rb
+++ b/app/models/nested_field_test.rb
@@ -1,3 +1,7 @@
-class NestedFieldTest < ActiveRecord::Base
- belongs_to :field_test, :inverse_of => :nested_field_tests
+# frozen_string_literal: true
+
+class NestedFieldTest < ApplicationRecord
+ has_paper_trail
+
+ belongs_to :field_test, inverse_of: :nested_field_tests
end
diff --git a/app/models/player.rb b/app/models/player.rb
index de8cc6a..5fba67f 100644
--- a/app/models/player.rb
+++ b/app/models/player.rb
@@ -1,23 +1,25 @@
-class Player < ActiveRecord::Base
- validates_presence_of(:name)
- validates_numericality_of(:number, :only_integer => true)
- validates_uniqueness_of(:number, :scope => :team_id, :message => "There is already a player with that number on this team")
+# frozen_string_literal: true
- validates_each :name do |record, attr, value|
- record.errors.add(:base, "Player is cheating") if value.to_s =~ /on steroids/
+class Player < ApplicationRecord
+ has_paper_trail
+
+ validates :name, presence: true
+ validates :number, numericality: { only_integer: true }
+ validates :number, uniqueness: { scope: :team_id, message: 'There is already a player with that number on this team' }
+
+ validates_each :name do |record, _attr, value|
+ record.errors.add(:base, 'Player is cheating') if /on steroids/.match?(value.to_s)
end
- belongs_to :team, :inverse_of => :players
- has_one :draft, :dependent => :destroy
- has_many :comments, :as => :commentable
+ belongs_to :team, inverse_of: :players, dependent: :destroy
+ has_one :draft, dependent: :destroy
+ has_many :comments, as: :commentable, dependent: :destroy
- attr_protected :suspended
-
def draft_id
- self.draft.try :id
+ draft.try :id
end
-
+
def draft_id=(id)
- self.draft = Draft.find_by_id(id)
+ self.draft = Draft.find_by(id: id)
end
end
diff --git a/app/models/rel_test.rb b/app/models/rel_test.rb
index 2a4f2ab..83d1c6e 100644
--- a/app/models/rel_test.rb
+++ b/app/models/rel_test.rb
@@ -1,5 +1,9 @@
-class RelTest < ActiveRecord::Base
- validates_numericality_of(:player_id, :only_integer => true)
+# frozen_string_literal: true
+
+class RelTest < ApplicationRecord
+ has_paper_trail
+
+ validates :player_id, numericality: { only_integer: true }
belongs_to :league
belongs_to :division
belongs_to :player
diff --git a/app/models/team.rb b/app/models/team.rb
index 4b7a650..b3690f9 100644
--- a/app/models/team.rb
+++ b/app/models/team.rb
@@ -1,22 +1,23 @@
-# coding: utf-8
+# frozen_string_literal: true
+class Team < ApplicationRecord
+ has_paper_trail
-class Team < ActiveRecord::Base
- validates_numericality_of :division_id, :only_integer => true
- validates_presence_of :manager
- validates_numericality_of :founded, :only_integer => true
- validates_numericality_of :wins, :only_integer => true
- validates_numericality_of :losses, :only_integer => true
- validates_numericality_of :win_percentage
- validates_numericality_of :revenue, :allow_nil => true
+ validates :division_id, numericality: { only_integer: true }
+ validates :manager, presence: true
+ validates :founded, numericality: { only_integer: true }
+ validates :wins, numericality: { only_integer: true }
+ validates :losses, numericality: { only_integer: true }
+ validates :win_percentage, numericality: true
+ validates :revenue, numericality: { allow_nil: true }
belongs_to :division
- has_many :players, :inverse_of => :team
+ has_many :players, inverse_of: :team, dependent: :destroy
has_and_belongs_to_many :fans
- has_many :comments, :as => :commentable
+ has_many :comments, as: :commentable, dependent: :destroy
def player_names_truncated
- players.map{|p| p.name}.join(", ")[0..32]
+ players.map(&:name).join(', ')[0..32]
end
def color_enum
diff --git a/app/models/user.rb b/app/models/user.rb
index 8bdf563..f038e46 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,21 +1,18 @@
-class User < ActiveRecord::Base
+# frozen_string_literal: true
+
+class User < ApplicationRecord
# Include default devise modules. Others available are:
- # :token_authenticatable, :confirmable, :lockable and :timeoutable
- devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
+ # :confirmable, :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable, :registerable, :trackable,
+ :recoverable, :rememberable, :validatable
serialize :roles, Array
- # Setup accessible (or protected) attributes for your model
- #attr_accessible :email, :password, :password_confirmation, :remember_me, :roles, :avatar
-
-
# Add Paperclip support for avatars
- has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
-
- def attr_accessible_role
- :custom_role
- end
+ has_attached_file :avatar, styles: { medium: '300x300>', thumb: '100x100>' }
+ validates_attachment_content_type :avatar, content_type: %r{\Aimage/.*\z}
attr_accessor :delete_avatar
- before_validation { self.avatar = nil if self.delete_avatar == '1' }
+
+ before_validation { self.avatar = nil if delete_avatar == '1' }
end
diff --git a/app/uploaders/carrierwave_uploader.rb b/app/uploaders/carrierwave_uploader.rb
index 71ad3bf..3aadf91 100644
--- a/app/uploaders/carrierwave_uploader.rb
+++ b/app/uploaders/carrierwave_uploader.rb
@@ -1,7 +1,7 @@
-# encoding: utf-8
+# frozen_string_literal: true
+
require 'mini_magick'
class CarrierwaveUploader < CarrierWave::Uploader::Base
-
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
@@ -16,9 +16,9 @@ class CarrierwaveUploader < CarrierWave::Uploader::Base
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
-
+
version :thumb do
- process :resize_to_fill => [100,100]
+ process resize_to_fill: [100, 100]
end
# Provide a default URL as a default if there hasn't been a file uploaded:
@@ -49,5 +49,4 @@ def store_dir
# def filename
# "something.jpg" if original_filename
# end
-
end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index e5483a0..eb11b64 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,13 +1,15 @@
-
- DummyApp
- <%= stylesheet_link_tag :all %>
- <%= csrf_meta_tag %>
-
-
+
+ DummyApp
+ <%= csrf_meta_tags %>
+ <%= csp_meta_tag %>
-<%= yield %>
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
+ <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
+
-
-
\ No newline at end of file
+
+ <%= yield %>
+
+