diff --git a/Gemfile b/Gemfile index 47a87a2..f7560e7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,8 @@ source "https://rubygems.org" -gem "rails", "7.1.2" -gem "railties", "7.1.2" -gem "activesupport", "7.1.2" +gem "rails" +gem "railties" +gem "activesupport" gem "pg" gem "sassc-rails" gem "coffee-rails" diff --git a/Gemfile.lock b/Gemfile.lock index 7fd7afa..67240fe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,35 +16,35 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.1.2) - actionpack (= 7.1.2) - activesupport (= 7.1.2) + actioncable (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.2) - actionpack (= 7.1.2) - activejob (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + actionmailbox (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.2) - actionpack (= 7.1.2) - actionview (= 7.1.2) - activejob (= 7.1.2) - activesupport (= 7.1.2) + actionmailer (7.1.3.2) + actionpack (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.2) - actionview (= 7.1.2) - activesupport (= 7.1.2) + actionpack (7.1.3.2) + actionview (= 7.1.3.2) + activesupport (= 7.1.3.2) nokogiri (>= 1.8.5) racc rack (>= 2.2.4) @@ -52,35 +52,35 @@ GEM rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.2) - actionpack (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + actiontext (7.1.3.2) + actionpack (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.2) - activesupport (= 7.1.2) + actionview (7.1.3.2) + activesupport (= 7.1.3.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.2) - activesupport (= 7.1.2) + activejob (7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.3.6) - activemodel (7.1.2) - activesupport (= 7.1.2) - activerecord (7.1.2) - activemodel (= 7.1.2) - activesupport (= 7.1.2) + activemodel (7.1.3.2) + activesupport (= 7.1.3.2) + activerecord (7.1.3.2) + activemodel (= 7.1.3.2) + activesupport (= 7.1.3.2) timeout (>= 0.4.0) - activestorage (7.1.2) - actionpack (= 7.1.2) - activejob (= 7.1.2) - activerecord (= 7.1.2) - activesupport (= 7.1.2) + activestorage (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activesupport (= 7.1.3.2) marcel (~> 1.0) - activesupport (7.1.2) + activesupport (7.1.3.2) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -266,20 +266,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.2) - actioncable (= 7.1.2) - actionmailbox (= 7.1.2) - actionmailer (= 7.1.2) - actionpack (= 7.1.2) - actiontext (= 7.1.2) - actionview (= 7.1.2) - activejob (= 7.1.2) - activemodel (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + rails (7.1.3.2) + actioncable (= 7.1.3.2) + actionmailbox (= 7.1.3.2) + actionmailer (= 7.1.3.2) + actionpack (= 7.1.3.2) + actiontext (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activemodel (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) bundler (>= 1.15.0) - railties (= 7.1.2) + railties (= 7.1.3.2) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -293,9 +293,9 @@ GEM nokogiri (~> 1.14) rails-ujs (0.1.0) railties (>= 3.1) - railties (7.1.2) - actionpack (= 7.1.2) - activesupport (= 7.1.2) + railties (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -429,7 +429,7 @@ PLATFORMS x86_64-linux DEPENDENCIES - activesupport (= 7.1.2) + activesupport best_in_place! brakeman bundler-audit @@ -453,10 +453,10 @@ DEPENDENCIES pg pry-rails puma - rails (= 7.1.2) + rails rails-controller-testing rails-ujs - railties (= 7.1.2) + railties render_async rspec-rails sassc-rails diff --git a/config/routes.rb b/config/routes.rb index 090cb32..dbe3b57 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,21 +1,22 @@ # Helper for easy routing and dasherizing. Default verb is :get. def route(action, verb = :get, *other_verbs) - match action.dasherize, to: action, via: [verb] + other_verbs + match action.dasherize => "#{@controller}##{action}", via: [verb] + other_verbs end Rails.application.routes.draw do root to: "home#index" # Navigation controller - get "about", to: "home#about" - get "king-hall", to: "home#king_hall" - get "home", to: redirect("") + get "about" => "home#about" + get "king-hall" => "home#king_hall" + get "home" => redirect("") # Weather controller + @controller = :weather resources :weather, only: :index do collection do route "awon" - match "data", to: "weather#weather", via: [:get, :post] + match "data" => "weather#weather", via: [:get, :post] route "precip", :get, :post route "et", :get, :post route "insol", :get, :post @@ -30,12 +31,11 @@ def route(action, verb = :get, *other_verbs) route "doycal_grid" end end - get "weather", to: "weather#index" # default action - get "weather/(*path)", to: redirect("weather") if Rails.env.production? - get "sun-water/(*path)", to: redirect("weather", status: 301) if Rails.env.production? - get "sun_water/(*path)", to: redirect("weather", status: 301) if Rails.env.production? + get "weather" => "weather#index" # default action + get "weather/(*path)" => redirect("weather") if Rails.env.production? # Sites controller + @controller = :sites resources :sites, only: :none do collection do route "site_data_weather" @@ -45,14 +45,15 @@ def route(action, verb = :get, *other_verbs) put :update end end - get "sites/:lat,:long", to: "sites#show", constraints: { + get "sites/:lat,:long" => "sites#show", constraints: { lat: /[-+]?\d+\.?\d*/, long: /[-+]?\d+\.?\d*/ } - get "sites", to: "sites#index" - get "sites/(*path)", to: redirect("sites") + get "sites" => "sites#index" + get "sites/(*path)" => redirect("sites") # AWON controller + @controller = :awon resources :awon, only: :index do collection do route "awon_check_boxes" @@ -64,6 +65,7 @@ def route(action, verb = :get, *other_verbs) get "awon/(*path)", to: redirect("/awon") if Rails.env.production? # Thermal models controller + @controller = :thermal_models resources :thermal_models, path: "thermal-models", only: :index do collection do route "alfalfa_weevil" @@ -85,11 +87,11 @@ def route(action, verb = :get, *other_verbs) route "download_csv", :post end end - get "thermal-models", to: "thermal_models#index" # default action - get "thermal-models/(*path)", to: redirect("/thermal-models") if Rails.env.production? - get "thermal_models/(*path)", to: redirect("/thermal-models", status: 301) if Rails.env.production? + get "thermal-models" => "thermal_models#index" # default action + get "thermal-models/(*path)" => redirect("/thermal-models") if Rails.env.production? # Subscribers controller + @controller = :subscribers resources :subscribers, only: %i[index new create update destroy] do collection do route "admin" @@ -129,8 +131,8 @@ def route(action, verb = :get, *other_verbs) mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development? - get "/ag_weather", to: redirect("/api/") - get "*unmatched", to: redirect("/") if Rails.env.production? - post "*unmatched", to: "application#bad_request" if Rails.env.production? - post "/", to: "application#bad_request" if Rails.env.production? + get "/ag_weather" => redirect("/api/") + get "*unmatched" => redirect("/") if Rails.env.production? + post "*unmatched" => "application#bad_request" if Rails.env.production? + post "/" => "application#bad_request" if Rails.env.production? end