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.)

4
  • 1
    try to use the gem browsify Commented Apr 26, 2016 at 11:52
  • Took a look - So browserify-rails allows you to just require the bower, npm packages in application.js without worrying about the Rails asset pipeline? (worried this is a little over my head) Commented Apr 26, 2016 at 12:40
  • 1
    yes that is that gem =) Commented Apr 26, 2016 at 12:45
  • Wooooow thats amazing! Thankyou Commented Apr 26, 2016 at 13:42

1 Answer 1

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'
Sign up to request clarification or add additional context in comments.

Comments

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.