0

I have a site with the Slidedeck jquery plugin on it. When I serve it locally it works just fine and looks great. After I push it to Heroku, though, it doesn't work at all.

I'm including all my files using sprockets, and I also use a gem that takes care of themes (themes_for_rails). I have an initializer in config:

 ThemesForRails.config do |config|
  # themes_dir is used to allow ThemesForRails to list available themes. It is not used to resolve any paths or routes.
  config.themes_dir = ":root/app/assets/themes"

  # assets_dir is the path to your theme assets.
  config.assets_dir = ":root/app/assets/themes/halo"

  # views_dir is the path to your theme views
  config.views_dir =  ":root/app/views/themes/halo"

  # themes_routes_dir is the asset pipeline route base. 
  # Because of the way the asset pipeline resolves paths, you do
  # not need to include the 'themes' folder in your route dir.
  #
  # for example, to get application.css for the default theme, 
  # your URL route should be : /assets/default/stylesheets/application.css
  config.themes_routes_dir = "assets"
end

This is in my application.js:

//= require jquery
//= require jquery_ujs
//= require_tree .
//= require_tree ../themes/halo/javascripts

Maybe my problem is that I am using relative paths in Heroku. I don't know exactly how to do absolute paths, though.

1 Answer 1

1

I haven't used the Slidedeck library before, but here are some things to look into to narrow down your bug source:

  • Javascript erroring out. Load up the console in your app on Heroku. Does basic Javascript work? If not, something could be eating your errors--I've seen this happen before but I haven't been able to find what exactly causes it.

  • Is there actually an issue with Slidedeck loading? If it's wrapped in a class (like how jQuery is wrapped in the jQuery class), can you reference that class in the console?

  • Relative paths should be fine on Heroku...but I notice in this line:

    //= require_tree ../themes/halo/javascripts

    you're requiring the equivalent of app/assets/themes/halo/javascripts. Is that right? Why not use the javascripts folder? If you have css, and images in this folder as well, you can split them into their respective app/assets/ subfolders, just to be sure. (My teammates have told me that this isn't or shouldn't be necessary, but I've found it to help me in one or two instances).

  • Were there any console errors pushing to Heroku related to asset precompile failure? They have a dedicated page for that error.

Sign up to request clarification or add additional context in comments.

6 Comments

Thank you, Eric. - Not sure exactly how to test js functionality in the rails console. I tried console.log("test"); - Once again, not sure how to access the js from the console (specifics?) - I do mean to require these specific theme folders and keep them separated, but if it doesn't work because of that, I'm willing to adapt. The css and images are split as you suggested to be sure. - No precompile failures. I followed the directions on the Heroku dev center to precompile before pushing. That works fine in other apps I'm developing.
Ah, I meant in the Javascript console in your browser. If you're not using Firebug (on Firefox) or Web Inspector (on Chrome), I highly recommend it. My preference is for Firebug.
I can reference the class for SlideDeck on my local server, but not on the Heroku site. I still haven't solved this.
So the javascript files aren't getting included properly with your include_tree relative path. As a hack, may I suggest moving app/assets/themes/halo/javascripts/ to app/assets/javascripts/halo/ just to see if it works?
I got it working. I deleted a few .js files that weren't working. Both were web font related (Cufon). Thanks, Eric. I used the console a lot as per your instructions.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.