How can I use Cesium with Ruby on Rails?

Ruby 2.2.1
Ruby on Rails 4.2.1
Cesium 1.15 (install by bower-rails)

I want to use Cesium with Ruby on Rails.
But I couldn't run cesium.

This is my config/application.rb
    config.assets.paths << config.root.join('vendor', 'assets', 'bower_components')


<!DOCTYPE html>
    <title>Hello World!</title>
      #cesiumContainer {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        width: 100%;
        margin: 0;
        overflow: hidden;
        padding: 0;
        font-family: sans-serif;

      html {
        height: 100%;

      body {
        padding: 0;
        margin: 0;
        overflow: hidden;
        height: 100%;

  <div id="cesiumContainer"></div>
    var viewer = new Cesium.Viewer('cesiumContainer');

//= require cesiumjs/cesium/cesium
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

after that I ran rails server.
I saw this error logs.

Error constructing CesiumWidget.
Visit to verify that your web browser and hardware support WebGL. Consider trying a different web browser or updating your video drivers. Detailed error information is below:

DeveloperError: Unable to determine Cesium base URL automatically, try defining a global variable called CESIUM_BASE_URL. Error at new t (http://localhost:3000/assets/Cesium/Cesium.self-e5be9662de17d5d8579c81c127c8f403d7b3943fd6f3ed5a374164899895e06e.js?body=1:418:6674) at o (http://localhost:3000/assets/Cesium/Cesium.self-e5be9662de17d5d8579c81c127c8f403d7b3943fd6f3ed5a374164899895e06e.js?body=1:419:5894) at s (http://localhost:3000/assets/Cesium/Cesium.self-e5be9662de17d5d8579c81c127c8f403d7b3943fd6f3ed5a374164899895e06e.js?body=1:419:6142) at d (http://localhost:3000/assets/Cesium/Cesium.self-e5be9662de17d5d8579c81c127c8f403d7b3943fd6f3ed5a374164899895e06e.js?body=1:419:6293) at new J (http://localhost:3000/assets/Cesium/Cesium.self-e5be9662de17d5d8579c81c127c8f403d7b3943fd6f3ed5a374164899895e06e.js?body=1:457:17887) at new P (http://localhost:3000/assets/Cesium/Cesium.self-e5be9662de17d5d8579c81c127c8f403d7b3943fd6f3ed5a374164899895e06e.js?body=1:466:26381) at new J (http://localhost:3000/assets/Cesium/Cesium.self-e5be9662de17d5d8579c81c127c8f403d7b3943fd6f3ed5a374164899895e06e.js?body=1:468:28064) at http://localhost:3000/:35:18

Please tell me how to solve...

were you able to make it work?

i’m in a similar problem

No I can’t make it work yet…

2015年12月29日火曜日 8時21分52秒 UTC+9 Mauricio Giraldo:

Cesium Viewer needs access to the “assets” folder, containing the star map, moon texture, and other odds and ends. The error you posted is saying that Cesium can’t figure out where that stuff is hosted.

Try what the error message suggests you to try: Set a JavaScript global window.CESIUM_BASE_URL = ‘/Cesium’; (or wherever Cesium’s Build folder is being served from). This way, Viewer can find the assets it needs to run.


ok this now kind of works. added the CESIUM_BASE_URL variable and the map shows up (and no error) but now it cannot find the assets. one example error:

No route matches [GET] “/assets/lib/Workers/cesiumWorkerBootstrapper.js”

this is the current location of the application (URL will change eventually):

notice line 18 in the HTML. PIC is the name of my app, which contains all the Cesium code.

ok added a trailing slash to CESIUM_BASE_URL and now i get no network errors

but i still get weird asset behavior

ok got the assets to work again. was embedding the widget.css file wrongly

now to figure out how tho get the rest of the app working…


Sorry, I couldn’t load Cesium yet…
I put Cesium at app/assets/javascripts/Cesium/Cesium.js

And I wrote
//= require cesium/cesium
//= require jquery

//= require jquery_ujs

//= require turbolinks

//= require_tree .

at app/assets/javascripts/application.js

And then, ERB is

<%= yield %>

And I saw this error

Uncaught ReferenceError: Cesium is not defined

That means you forgot to actually include the Cesium.js script tag in your HTML document.

i forgot to mention that i ended up putting the Cesium js files in /public/assets because it was becoming a nightmare to have things properly mapped/compiled/understood by Rails

maybe there is a better way to do this but it is working so far for me