Highcharts in the Rails Assest Pipeline not Loading - ruby-on-rails

I'm working in development and am migrating from Rails 3.x to Rails 4.2.5 with Ruby 2.1. In the previous version of rails, Highcharts was working perfectly. Now I am trying to use the asset pipeline for the first time.
Within my applcation.html.erb file, I have included the line:
<%= javascript_include_tag "application" %>
Within assets/javascripts, I've verified the file "application.js" exists. Within that file I have included the lines:
//= require jquery.min
//= require rails
//= require highcharts
//= require_tree .
I have verified the files just listed above also exist in the asset/javascript. I thought that was all I needed, but I always get a blank screen when I try to display the chart. The log file says the view with the chart was rendered, but nothing is displayed. It worked perfectly in the previous version of rails, so I am ruling out the creation, handling and data values of the chart as being the source of the problem.
So what else am I missing to get Highcharts to run again? If more info is needed to help answer the question, please just let me know. Any help is greatly appreciated.

Problem solved. There was an extra comma buried within my Highcharts function call. I was able to find this by using #taglia comments about using a browser console, which in the future I will know to use as part of my debugging tool box.
Thanks to everyone for your help and insights.

Related

Installing Highstocks for Rails app

Do I have to do anything else other than add this to my gemfile?
gem 'highstock-rails'
Because if I go to the github account for it and add the require lines to my application.js the system still cannot find highstocks to use it in a script.
These are the lines I added:
//= require highstock
//= require highstock/highcharts-more
Make sure that you are not adding older version, and remove the require_tree . from your application.js file. Like uzaif restart your server as well for good measure even though that wasn't particularly the issue I was having, it's a good idea anyway.

Highmaps with US States in Rails

I am trying to add a widget in my rails application, in which i am going to display the US states maps as given Demo here in highcharts
The app is using highcharts-rails gem of version 4.0.4, to display some other charts in the application. To use the maps, i am trying to include the js files from gem in application.js file as follows.
//= require highcharts
//= require highcharts/modules/data
//= require highcharts/modules/map
and also the JS file for loading states information in application.html.erb
<script src="http://code.highcharts.com/mapdata/countries/us/us-all.js"></script>
I am able to get the state codes Highcharts.maps['countries/us/us-all'] and also constructed the data from application as required. But the map is not displaying any thing and not seeing any errors in the console also.
But when i remove the including lines from application.js file and add the Java Script files explicitly, the map is loading perfectly without any issues. The below are the two js files that i am adding in my layout.
<script src="http://code.highcharts.com/maps/highmaps.js"></script>
<script src="http://code.highcharts.com/mapdata/countries/us/us-all.js"></script>
Any help, why it is not loading the maps when i include the files through gem ?
Thanks in Advance.
Finally able to make it work with the gem itself, but i have to explicitly include the
//= require highcharts/modules/map
with the file that is available in http://www.highcharts.com/download for highmaps plugin, available in Highmaps-1.0.4/js/modules/map.src.js
Check the issue in github

Michael Hartl rails tutorial chapter 8 sign out not working in heroku

I'm following a tutorial by Michael Hartl. I'm implementing chapter 8, which is the sign in and sign out process. I have the app deployed to Heroku.
The tutorial has account dropdown box in header that is supposed to roll down and show the link sign out when clicked. When I deploy the app locally, the dropwdown box drops and shows the link when I click it. However, after I deploy the app to Heroku, the dropdown box doesn't drop when I click it, and the URL is appended with # at the end.
There are many files (controllers, models, etc.), so I don't know which one I should post here. The codes are almost verbatim of what is in the book.
I accidentally tumbled across a post with same problem last night, and the comment given (that solved the problem) was: The bootstrap javascript library added into application.js file need to be placed directly underneath the jquery library.
So instead of:
//=require jquery
//=require jquery_ujs
//=require bootstrap
It should be:
//=require jquery
//=require bootstrap
//=require jquery_ujs

Can't get pjax to work on Rails

I'm trying to get pjax to work on a Rails app but none of the links are being annotated with pjax. I think pjax isn't really being loaded. I'm using pjax_rails and am basically following the railscast instructions but using //= require jquery.pjax instead of just pjax. I'm also using it with bootstrap which may cause an issue but I'm not sure. My other thought is that is that the pjax javascript isn't being loaded and I need to run something like $('a').pjax('[data-pjax-container]')
To be clear the main problem is that pjax isn't being loaded client side and thus when I make requests the X-PJAX header is not being set.
Finally got it working. First problem was that the unbeknownst to me the assests pipeline was turned off so the pjax javascript file wasn't being included. Instead I went with the pjax rack gem and dumped it into the public directory. Then I created a new javascript file with $('a').pjax('[data-pjax-container]') and it works! Although I'm not sure why I need to manually call that javascript when all the documentation seems to point to the fact that it should be already there.

Rails + tinymce-rails weird error

I'm using tinymce-rails for a form .... until last night everything worked fine ... this morning when I came in and tried to run the form I get this error
undefined local variable or method 'tinymce'
the weird part is if I save the controller with :w in vim without making any changes to the file ... the error disappears and everything works ... any ideas ?
I had similar issue (rails 3.1), may be because i was using the advance theme.
then added this in application.js
//= require tinymce
//= require tinymce-jquery
and the theme folder from tinymce to assets folder
Worked for me... not sure if it helps.
I fixed it by adding helper(TinyMCE::Rails::Helper) in the controller but I still have no idea what happened
gem update tinymce-rails
bundle update
And you should get your gem updated

Resources