Skip to content

Instantly share code, notes, and snippets.

@wolfravenous
Created September 20, 2016 14:29
Show Gist options
  • Save wolfravenous/eef4a4455ff4749acbd3d53070f342ca to your computer and use it in GitHub Desktop.
Save wolfravenous/eef4a4455ff4749acbd3d53070f342ca to your computer and use it in GitHub Desktop.
Dynamic Selection boxes with jQuery fails on intial page load but works on page refresh
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module ReportMaster
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
end
end
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
Started GET "/reports/new" for ::1 at 2016-09-20 10:28:24 -0400
ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by ReportsController#new as HTML
Subject Load (0.2ms) SELECT "subjects".* FROM "subjects"
CACHE (0.1ms) SELECT "subjects".* FROM "subjects"
Intro Load (0.2ms) SELECT "intros".* FROM "intros" WHERE "intros"."subject_id" = ? [["subject_id", 1]]
Intro Load (0.1ms) SELECT "intros".* FROM "intros" WHERE "intros"."subject_id" = ? [["subject_id", 2]]
CACHE (0.0ms) SELECT "subjects".* FROM "subjects"
Unit Load (0.2ms) SELECT "units".* FROM "units" WHERE "units"."subject_id" = ? [["subject_id", 1]]
Unit Load (0.1ms) SELECT "units".* FROM "units" WHERE "units"."subject_id" = ? [["subject_id", 2]]
Rendered reports/_form.html.erb (367.5ms)
Rendered reports/new.html.erb within layouts/application (375.4ms)
Completed 200 OK in 910ms (Views: 893.1ms | ActiveRecord: 2.4ms)
Started GET "/assets/application.self-5a416cbd1a086089642474ee31641c7772fa146064c9674e0ce14e20cb920ac1.css?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/carousel.self-e47323f363ceb3dc0bdbce05e36e709ed428e339833a41140a85cb0af24b8127.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/jquery_ujs.self-784a997f6726036b1993eb2217c9cb558e1cbb801c6da88105588c56f13b466a.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/transition.self-6ad2488465135ab731a045a8ebbe3ea2fc501aed286042496eda1664fdd07ba9.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/collapse.self-2eb697f62b587bb786ff940d82dd4be88cdeeaf13ca128e3da3850c5fcaec301.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/alert.self-742145c5bb847aafdadc6e339be795628f8bc25f177e851f03a8c42278eb0312.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/button.self-126ac9bf0e7f2d8568f8da3a00fd5f0fac6eae0946331003370161fbf8d7975e.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/dropdown.self-561cca1cbaf67474e01e9536f106bad541594860a6df997004591c1c1957a147.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/modal.self-3e78617ade5663314b7ee0ea10375a5b34d59ffbade44939e3f2a4e4ef2019b3.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/tab.self-5bf7078b682f8b131332eefa46b45fa5eff2eca745fc0d03e2991450888f7c28.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/affix.self-6d6f1a7fc5c8aabf3547fa1b794fab6268f54bc55ad815e55873c71f52513517.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/scrollspy.self-969f3c5f48cdf1e439c7fa1154c13b948715f5c689f87837c0b64521d3b46ef6.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/tooltip.self-05afb177e08f98997ccfc84fa08a215e4b27d48d5fe4d049080675e9dffd8199.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap/popover.self-0aa93860b59fe7393f1dd490f54b3cb994f9d6155adffce034d4e14ae361b041.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/bootstrap-sprockets.self-fbfa5ad7d9aa0afe439ec4ff3883acc4cb92b62cb67c40d674320c9aa1d4642d.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/intros.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/reports.self-da66a9788f78b55ec2ef03d9520ec05562572bb727d18a41a72ee424cc186c11.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/subjects.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/units.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/assets/application.self-3b8dabdc891efe46b9a144b400ad69e37d7e5876bdc39dee783419a69d7ca819.js?body=1" for ::1 at 2016-09-20 10:28:26 -0400
Started GET "/reports/new" for ::1 at 2016-09-20 10:29:29 -0400
Processing by ReportsController#new as HTML
Subject Load (0.2ms) SELECT "subjects".* FROM "subjects"
CACHE (0.0ms) SELECT "subjects".* FROM "subjects"
Intro Load (0.1ms) SELECT "intros".* FROM "intros" WHERE "intros"."subject_id" = ? [["subject_id", 1]]
Intro Load (0.1ms) SELECT "intros".* FROM "intros" WHERE "intros"."subject_id" = ? [["subject_id", 2]]
CACHE (0.0ms) SELECT "subjects".* FROM "subjects"
Unit Load (0.2ms) SELECT "units".* FROM "units" WHERE "units"."subject_id" = ? [["subject_id", 1]]
Unit Load (0.1ms) SELECT "units".* FROM "units" WHERE "units"."subject_id" = ? [["subject_id", 2]]
Rendered reports/_form.html.erb (257.2ms)
Rendered reports/new.html.erb within layouts/application (259.4ms)
Completed 200 OK in 329ms (Views: 327.6ms | ActiveRecord: 0.8ms)
Started GET "/assets/application.self-5a416cbd1a086089642474ee31641c7772fa146064c9674e0ce14e20cb920ac1.css?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/transition.self-6ad2488465135ab731a045a8ebbe3ea2fc501aed286042496eda1664fdd07ba9.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/button.self-126ac9bf0e7f2d8568f8da3a00fd5f0fac6eae0946331003370161fbf8d7975e.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/jquery_ujs.self-784a997f6726036b1993eb2217c9cb558e1cbb801c6da88105588c56f13b466a.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/alert.self-742145c5bb847aafdadc6e339be795628f8bc25f177e851f03a8c42278eb0312.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/collapse.self-2eb697f62b587bb786ff940d82dd4be88cdeeaf13ca128e3da3850c5fcaec301.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/dropdown.self-561cca1cbaf67474e01e9536f106bad541594860a6df997004591c1c1957a147.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/modal.self-3e78617ade5663314b7ee0ea10375a5b34d59ffbade44939e3f2a4e4ef2019b3.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/carousel.self-e47323f363ceb3dc0bdbce05e36e709ed428e339833a41140a85cb0af24b8127.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/tab.self-5bf7078b682f8b131332eefa46b45fa5eff2eca745fc0d03e2991450888f7c28.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/scrollspy.self-969f3c5f48cdf1e439c7fa1154c13b948715f5c689f87837c0b64521d3b46ef6.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/tooltip.self-05afb177e08f98997ccfc84fa08a215e4b27d48d5fe4d049080675e9dffd8199.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/affix.self-6d6f1a7fc5c8aabf3547fa1b794fab6268f54bc55ad815e55873c71f52513517.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap/popover.self-0aa93860b59fe7393f1dd490f54b3cb994f9d6155adffce034d4e14ae361b041.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/intros.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/reports.self-da66a9788f78b55ec2ef03d9520ec05562572bb727d18a41a72ee424cc186c11.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/bootstrap-sprockets.self-fbfa5ad7d9aa0afe439ec4ff3883acc4cb92b62cb67c40d674320c9aa1d4642d.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/subjects.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/units.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
Started GET "/assets/application.self-3b8dabdc891efe46b9a144b400ad69e37d7e5876bdc39dee783419a69d7ca819.js?body=1" for ::1 at 2016-09-20 10:29:29 -0400
@wolfravenous
Copy link
Author

Simple solution, specify the GET method when using the link_to helper to activiate the jQuery.

  • <%= link_to "New Report", new_report_path, class: "new", **method: :get** %>
  • Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment