diff --git a/README.md b/README.md index e2522c9..7077123 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,9 @@ Note: If you get a security warning in Chrome, Click "Advanced" and then "Procee Contributing new spots is easy! Make sure you're signed into your [Github account](https://github.com/join) and edit the [seeds file](https://github.com/swrobel/meta-surf-forecast/edit/master/db/seeds.rb): -1. Create a new region if necessary. For example, the LA region is created like so: +1. Create a new Region if necessary. For example, Los Angeles is created like so: ```ruby - LA = Region.find_or_create_by(name: 'Los Angeles') + LA = Subregion.find_or_create_by(name: 'Los Angeles') ``` 1. Get the Spitcast spot id, slug (unique text id) & lat/lon data using [their spot list API](http://api.spitcast.com/api/spot/nearby?longitude=-122.005261&latitude=37.02188) (you'll need to replace the lat/lon in the URL with yours, which you can get from the [Google Geocoder](https://google-developers.appspot.com/maps/documentation/utils/geocoder/)). The slug is `spot_id_char` in their API. 1. Go to the MagicSeaweed page for the spot you want to add. Their spot id is the number at the end of the url, and the slug is the text after the slash and before `-Surf-Report`, ex: for `http://magicseaweed.com/Pipeline-Backdoor-Surf-Report/616/` the slug is `Pipeline-Backdoor` and the id is `616`. @@ -49,7 +49,7 @@ Use the following as a template. Delete the lines for `surfline_id`, `msw_id`, e msw_slug: 'County-Line-Yerba-Buena-Beach', spitcast_id: 207, spitcast_slug: 'county-line-malibu-ca', - region: LA, + subregion: LA, }, ``` diff --git a/app/controllers/regions_controller.rb b/app/controllers/subregions_controller.rb similarity index 94% rename from app/controllers/regions_controller.rb rename to app/controllers/subregions_controller.rb index b17a170..21b9c73 100644 --- a/app/controllers/regions_controller.rb +++ b/app/controllers/subregions_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -class RegionsController < ApplicationController - before_action :set_region +class SubregionsController < ApplicationController + before_action :set_subregion def show @forecasts = Spot.connection.select_all <<-SQL @@ -57,7 +57,7 @@ def show JOIN spots s ON sub.spot_id = s.id WHERE sub.timestamp > now() at time zone 'utc' AND sub.timestamp <= (SELECT max(timestamp) FROM spitcasts) - AND s.region_id = #{@region.id} + AND s.subregion_id = #{@subregion.id} GROUP BY id ,name ,lat @@ -98,7 +98,7 @@ def show private - def set_region - @region = Region.find(params[:id]) + def set_subregion + @subregion = Subregion.find(params[:id]) end end diff --git a/app/models/spot.rb b/app/models/spot.rb index e9d1bc2..a311847 100644 --- a/app/models/spot.rb +++ b/app/models/spot.rb @@ -8,7 +8,7 @@ class Spot < ApplicationRecord has_many :surfline_lolas has_many :msws has_many :spitcasts - belongs_to :region + belongs_to :subregion default_scope -> { order(:name) } scope :optimized, -> { includes(:msws, :surfline_nearshores, :surfline_lolas, :spitcasts) } diff --git a/app/models/region.rb b/app/models/subregion.rb similarity index 76% rename from app/models/region.rb rename to app/models/subregion.rb index f8cfa85..baeb9bf 100644 --- a/app/models/region.rb +++ b/app/models/subregion.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Region < ApplicationRecord +class Subregion < ApplicationRecord extend FriendlyId friendly_id :name, use: %i[slugged finders] diff --git a/app/views/regions/show.html.slim b/app/views/subregions/show.html.slim similarity index 88% rename from app/views/regions/show.html.slim rename to app/views/subregions/show.html.slim index a635814..e0381dc 100644 --- a/app/views/regions/show.html.slim +++ b/app/views/subregions/show.html.slim @@ -2,8 +2,8 @@ nav.navbar.navbar-light.sticky-top .row.font-weight-light span.margin-left Region: select.margin-left onchange='window.location = this.value' - - Region.all.each do |region| - option value=region_path(region) selected=('selected' if region == @region) =region.name + - Subregion.all.each do |subregion| + option value=subregion_path(subregion) selected=('selected' if subregion == @subregion) =subregion.name div - @forecasts.each do |data, forecast| h2.font-weight-light.margin-left.spot-header diff --git a/config/environments/development.rb b/config/environments/development.rb index 3c7a22e..91337a0 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -38,7 +38,7 @@ # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. - config.assets.debug = ENV['RAILS_SERVE_STATIC_FILES'].blank? + config.assets.debug = true # Asset digests allow you to set far-future HTTP expiration dates on all assets, # yet still be able to expire them through the digest params. @@ -61,7 +61,6 @@ # Suppress static asset requests from server logs config.assets.quiet = true - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? config.middleware.insert_before ActionDispatch::ShowExceptions, Rack::Toolbar, snippet: '