0

I'm trying to setup angular-chart.js in an Angular on Rails application, per github instructions. But the documentation is not specifically for Rails so I'm running into errors.

Installation instruction: http://jtblin.github.io/angular-chart.js/

For reference,

  1. installed via bower, bower install angular-chart.js --save
  2. added as dependency, angular.module('myModule', ['chart.js']);.

Documentation then recommends then adding <script src="bower_components/angular-chart.js/dist/angular-chart.js"></script>, but this file is not found if I add this line (think because using Rails).

Since the application is Angular ontop of Rails, I assume it needs to be added to Rails application.js file. As otherwise there is an angular no module error.

But I'm not sure exactly what needs to be added to application.js. I've tried:

  • chart.js
  • angular-chart.js
  • angular-chart

(prefaced by //= require)

But everything results in a Rails error,

Sprockets::FileNotFound in Boards#index
couldn't find file 'chart.js' with type 'application/javascript'

Is there a way to find out exactly what needs to be added to application.js? Or some other way to solve this?

(Apologies if this is difficult to follow.)

tim_xyz
  • 11,573
  • 17
  • 52
  • 97

1 Answers1

1

You can use (as you mentioned in discussion) gem browserify-rails to easily pick-up bower/node.js packages. Include gem into Gemfile, bundle install, and then install npm/bower package into app.

gem 'browserify-rails'
Малъ Скрылевъ
  • 16,187
  • 5
  • 56
  • 69