From b0331e2259702eee779bcaa93acd7fedb184ae6f Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Wed, 18 Oct 2017 11:54:52 -0400 Subject: [PATCH] working on navigation --- app/controllers/districts_controller.rb | 2 +- app/models/school.rb | 2 ++ app/views/districts/show.html.haml | 8 ++++++++ app/views/welcome/index.html.haml | 7 +------ lib/tasks/data.rake | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/controllers/districts_controller.rb b/app/controllers/districts_controller.rb index e9e0fedb..5d3a05b5 100644 --- a/app/controllers/districts_controller.rb +++ b/app/controllers/districts_controller.rb @@ -10,7 +10,7 @@ class DistrictsController < ApplicationController # GET /districts/1 # GET /districts/1.json def show - @schools = @district.schools + @schools = @district.schools.alphabetic end # GET /districts/new diff --git a/app/models/school.rb b/app/models/school.rb index 96621615..89405ca5 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -7,6 +7,8 @@ class School < ApplicationRecord validates :name, presence: true + scope :alphabetic, -> { order(name: :asc) } + include FriendlyId friendly_id :name, :use => [:slugged] diff --git a/app/views/districts/show.html.haml b/app/views/districts/show.html.haml index adfbc2b9..e213627c 100644 --- a/app/views/districts/show.html.haml +++ b/app/views/districts/show.html.haml @@ -10,9 +10,17 @@ %h4 Schools in = @district.name + + %br - @district.schools.each do |school| %p= link_to school.name, school + %br + %br + %br + %br + = link_to "View All Districts", root_path + - else .text-center.my-3.py-3 %h3.my-3.py-3 diff --git a/app/views/welcome/index.html.haml b/app/views/welcome/index.html.haml index 83dbe9b3..0bc633d3 100644 --- a/app/views/welcome/index.html.haml +++ b/app/views/welcome/index.html.haml @@ -8,16 +8,11 @@ - if true || user_signed_in? .row.mt-3 - .col-6 + .col-12 %h4 Districts - @districts.each do |district| %p= link_to district.name, district - .col-6 - %h4 Schools - -# current_user.schools.each do |school| - - School.all.each do |school| - %p= link_to school.name, school - else diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 5517f847..03a121d2 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -145,7 +145,7 @@ namespace :data do bad_answers = {} year = '2017' - timeToRun = 100 * 60 * 60 + timeToRun = 10 * 60 startIndex = 0 stopIndex = 100000 startTime = Time.new