1

I'm trying to follow a tutorial on adding d3.js graph to Rails 4 application. The example application is on github and works as expected.

My problem is that when I try to replicate this application from scratch or add this graph to my existing project the js file in /app/assets/javascripts is not included in resources for some reason despite the fact that the //= require_tree . line is present in /app/assets/javascripts/applications.js files.

I can see this as the only problem since if I paste the code from problematic file into the console, it works.

I found similar questions and followed advice given but couldn't fix my problem.

I've already tried rake assets:precompile suggested here

Can anybody help?

2
  • Do you have a coffee file in /app/assets/javascripts with the same name? Commented Jun 27, 2016 at 11:34
  • Yes I do, nothing in it apart from few commented out lines Commented Jun 27, 2016 at 11:47

1 Answer 1

2

I had the same problem. I had file.coffee and I created file.js which was not added. When I renamed file.coffee to file.js everything was fine. However, you could just use www.js2.coffee to convert your js code to coffee and then use the file.coffee file instead.

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

2 Comments

First of all THANKS SO MUCH, I was scratching my head not this for a while. It is weird though, the original project from the tutorial has the coffee file and it works. I guess my issue may return at some point if I decide to use coffee script after all.
OK, I guess this is just something I had to learn the hard way. Not sure why both js and coffee files were in the example project (or why it actually works) but according to asset pipeline docs it it should be one or the other, or file.js.coffee if I wan to parse it with coffee first an then javascript. At least that's how I understand this.

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.