0

Dropdown menus work on localhost or Heroku, but not both depending on order in application.js

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require angular
//= require 'leaflet.js'
//= require leaflet
//= require_tree .

With the above dropdown menus work on Heroku https://secure-shore-68966.herokuapp.com/summary. To work on localhost bootstrap needs to be second, that is, above jquery_ujs.

This an old problem, e.g., Javascript features work on localhost but not when deployed to Heroku. I found the order solution in one of the comments. (The post is four years old, so the items differ a bit.)

production.rb file has config.assets.compile = true which I assume takes care of precompiling, but in any case I've tried rake assets:precompile before pushing to Heroku and that didn't help.

What might I have wrong? Or is there a workaround so I don't have to change application.js everytime I upload? I'm a newbie so my knowledge of asset management is weak to say the least.

Community
  • 1
  • 1
Greg
  • 2,359
  • 5
  • 22
  • 35
  • how did u install bootstrap and angular? from gem or npm ? – 7urkm3n Mar 30 '16 at 20:41
  • Most likely a gem. I have been working through several tutorials and get bounced around a bit. Is there a way to tell? I don't use npm much. My Gemfile has source 'https://rails-assets.org' do gem 'rails-assets-bootstrap' gem 'rails-assets-angular' gem 'rails-assets-leaflet' end Also have in Bowerfile: asset 'angular', '~> 1.5' resolution 'angular', '1.5' asset 'angular-route' Not currently using angular. I experimented with it, but decided to abandon its use for now. Thanks for any help. – Greg Mar 30 '16 at 20:54
  • Are you using the 12factor gem for setting up assets on your deployed heroku app? Install that gem, then in your command line do: "bundle exec rake assets:precompile RAILS_ENV=production" Then do a git commit and push to heroku! – bkunzi01 Mar 30 '16 at 21:24
  • `group :production do gem 'rails_12factor', '0.0.2' gem 'puma', '2.15.3' end` has been in Gemfile all along. Is `bundle exec rake assets:precompile` different than `bundle exec rake assets:precompile RAILS_ENV=production`? – Greg Mar 30 '16 at 21:30
  • To be honest I am not sure and that makes me sad > – bkunzi01 Mar 30 '16 at 21:47
  • @7urkm3n `npm list` returns `(empty)`. `gem list` turns up `bootstrap-sass (3.3.6, 3.3.5, 3.2.0.0) bootstrap-will_paginate (0.0.10)` and `angular-rails-templates (1.0.0, 0.2.0)` and of course many other gems. Not sure if this answers the question. – Greg Mar 30 '16 at 22:32
  • @Greg, is dropdown from Bootstrap navbar ? – 7urkm3n Mar 31 '16 at 03:47
  • @7urkm3n. Yes, following http://getbootstrap.com/components/#dropdowns and it's in a navbar. Code here: https://bitbucket.org/MtnBiker/crores5/src/494608f2fc5478caf961ccceeb4d45da43ba91f9/app/views/layouts/_header.html.erb?at=master&fileviewer=file-view-default. I'd paste it but hard to read in comments – Greg Mar 31 '16 at 19:27
  • @Greg Ill look at that later, to help you at all. – 7urkm3n Mar 31 '16 at 19:37
  • @7urkm3n I have to add that something else is going on. I now can't get dropdowns to work on localhost. And I think I can't stop them from working on Heroku (but I'm not going to try very hard to break it). In other words I put `bootstrap` second in `application.js` reboot server and dropdowns don't work on localhost. It may be tied to recent OSX upgrade (10.11.3 to 10.11.4 mainly bug fixes). FWIW dropdowns don't work in Safari or Chrome. Maybe the problem is with gems, but I didn't change anything—I've checked git for any recent changes I may have inadvertently made. Thanks for any help – Greg Mar 31 '16 at 20:49

0 Answers0