Rails 4 Couldn't find file 'angular-rails-templates' - ruby-on-rails

I'm following this tutorial: https://thinkster.io/angulartutorial/angular-rails/ and everything went well till the part where I had to arrange my angular code with folders in the rails assets pipeline javascripts and use the gem 'angular-rails-template' (https://github.com/pitr/angular-rails-templates) to reach them.
I've installed the gem through the Gemfile and I'm getting a "couldn't find file 'angular-rails-templates'" error even though I've required the file in the application.js:
//= require angular
//= require angular-rails-templates
//= require angular-ui-router
//= require_tree .
Any suggestions?

Apperantly I was sure that I restarted the server, which I didn't. If anyone encouter this problem try the old fashioned solution to fix it.

Related

Sprockets::FileNotFound in Application#angular

I'm working through the thinkster Angular-Rails tutorial (https://thinkster.io/angular-rails), and encounter the following error trying to install Devise:
Sprockets::FileNotFound in Application#angular
couldn't find file 'angular-devise'(in /app/assets/javascripts/application.js:2)
I have installed Devise gem, restarted the server, installed angular-devise and injected Devise module into my app. Guidance on how to troubleshoot appreciated!
Instead of angular-devise use AngularDevise/lib/devise but it must be placed after
angular-rails-templates
please see the following order
//= require angular
//= require angular-rails-templates
//= require AngularDevise/lib/devise
Ravi's approach worked for me.
The step from the thinkster tutorial reads like this:
require angular-devise in application.js after angular
Seems like the wording of that step could be improved.
Note that the AngularDevise folder contains a bower.json file that points to lib/devise.js. So this will also work:
//= require AngularDevise
Doing it this way is more consistent with how other packages are referenced in the application.js file. And it insulates application.js from future changes to the directory structure/naming inside the AngularDevise directory.

Sprockets cant find asset from rails-assets.org

I try to install react-router and material-ui on my rails 4 app but I get Sprockets::FileNotFound error for react-router and material-ui. I follow instructions from rails-assets.org.
My Gemfile:
source 'https://rails-assets.org' do
gem 'rails-assets-classnames'
gem 'rails-assets-lodash'
gem 'rails-assets-react-router'
gem 'rails-assets-material-ui'
end
application.js
//= require jquery
//= require lodash
//= require jquery_ujs
//= require react
//= require classnames
//= require react_ujs
//= require react-router
//= require turbolinks
//= require_tree .
And after bundle I got this notification on some gems This component doesn't define main assets in bower.json.. Thank you for your time and I hope we work this out.
UPD 1:
I found kind of a solution on stackoverflow but I would like to stick to rails-assets.org way if possible.
ruby '2.2.0'
rails '4.2.3'
Might be easy to forget, but have you restarted your (running) rails server?
Started to use rails-assets yesterday as well and it showed me the exact same problem (Sprockets::FileNotFound).
I restarted the running server in the console and the problem was solved.
Rails 4.2.5
/ Ruby 2.3.

Dropdowns work locally in production but don't work on real server

I got this application.js
And when I run my app locally with env production dropdowns work fine. But after deploy to a real server they stopped working.
//= require ckeditor/init
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require jquery.turbolinks
//= require turbolinks
//= require_tree .
How can I fix this?
up1
Uncaught TypeError: Cannot read property 'langEntries' of nullapplication-c6f1be54480428c9ab047aa15b1a5d07.js:4
window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.plugins.setLangapplication-c6f1be54480428c9ab047aa15b1a5d07.js:21 (anonymous function)
up2
I dev env I have a lot of errors
UP3
When I move ckeditor directory to public there're no errors.
I was having a similar issue and tried many of the answers found here untill it worked. I suggest deleting the public and tmp folders (or their content) and deploying like that, then precompile the assets in your server. That and fiddling with the order of the requires worked for me. Hope it helps.
I tried a lot of things but ended up removing turbolinks completely.

Installing rails-backbone, missing assets?

I just installed the rails-backbone gem and then rails g backbone:install.
I see a list of javascript references to backbone on application.js but it does not copy them to the project and I'm not sure if this is normal.
//= require backbone
//= require backbone_rails_sync
//= require backbone_datalink
//= require backbone/myapp
If this is normal, where is it possible to find backbone_rails_sync and backbone_datalink. I'm afraid that by simple searching will maybe not find the same version tested for this gem?
These files are inside the gem and served through Rails Asset Pipeline.
You could find them in the gem souce.

Rails and codekit - how to disable rails coffescript compilation

I'm using rails 3.2, but I'm compiling my coffee files with CodeKit.
I still want my coffee files to live inside 'assets', but each time I restart rails, it finds them in there and tries to compile them itself.
My files live in /assets/cafe/myscript.coffee, and codekit compiles them into /assets/javascripts/myscript.js
The coffee-rails gem is already commented out in my gemfile (when rails tries to (re) compile it it gives "throw Error("LoadError: no such file to load -- coffee_script)" - though I really dont want it to even try compiling.
Setting "config.assets.compile = false" in application.rb results in "application.js isn't precompiled"
you should probably just configure your sprockets manifest to not require the whole tree.
edit app/assets/javascripts/application.js
typically it looks like this:
//= require jquery
//= require jquery_ujs
//= require_tree .
change that to
//= require jquery
//= require jquery_ujs
//= require myscript
An (inferior) workaround is to put my coffeescripts inside "App" rather than "assets" (so one more branch up the tree.)
This sucks because it's not where they should go, but at least it does put it outside rails' stalker-tendencies to find coffeescript files anywhere in assets and try to compile them.

Resources