rails ember-cli No route matches [GET] > "/javascripts/emberFrontend/vendor.js" - ruby-on-rails

I am new to Ember and I'm trying to understand how the asset building works.
I have an existing Rails project that is in the middle of conversion to Ember, with ember-cli.
ember 1.13
ruby 2.1.6
rails 4.1.6
I keep getting these errors when trying to access ember pages, and I'm trying to isolate when, and what causes them:
Started GET "/javascripts/emberFrontend/vendor.js" for 127.0.0.1 at
2015-12-28 17:10:16 +0200
ActionController::RoutingError (No route matches [GET]
"/javascripts/emberFrontend/vendor.js"):
...
Started GET "/javascripts/emberFrontend/ember-frontend.js" for
127.0.0.1 at 2015-12-28 17:10:16 +0200
ActionController::RoutingError (No route matches [GET]
"/javascripts/emberFrontend/ember-frontend.js"):
for example, I take a page that is rendering fine and logs:
Started GET
"/assets/emberFrontend/vendor-b0892280be71c70102741f9d7feb0532.js" for
127.0.0.1 at 2015-12-28 17:53:15 +0200
Started GET
"/assets/emberFrontend/ember-frontend-affc24729a1c2e1a0a6a56334d2bb16a.js"
for 127.0.0.1 at 2015-12-28 17:53:15 +0200
And I make a change in the template code from:
<li class="reportsTab"><a href={{urls.reports}}>Reporting</a></li>
to:
<li>{{#link-to "merchant.reports"}}Reporting{{/link-to}}</li>
In order for one of the page tabs to direct to the ember code instead of the old one, similar to other changes made on that page. This change causes the errors above, and the browser page is blank.
What is puzzling me is that if I revert the change while the rails server is running, and then restart it - it doesn't stick, but if I stop the server, than make the change and rerun it, it does.
Clearly I am missing something in understanding how the ember server is building the assets, but I can't figure it out from any guides.
Also (and possbily related), my */emberFrontend/tmp directory doesn't clean.

Turned out my machine is to slow.
I changed the timeout in /config/initializers/ember.rb to 60
c.app :emberFrontend, path: Rails.root.join('emberFrontend').to_s, build_timeout: 60

Related

Rails 7 ActionController::RoutingError stimulus controller with outdated digest

Edit: A simpler example than my original question, my CSS is experiencing the same caching issue. Using the dartsass-rails gem, with the bin/rails dartsass:watch in development. Default configuration. Changes to my SASS files throw an error because Rails goes looking for an outdated digest.
ActionController::RoutingError (No route matches [GET] "/assets/application-01d05ee418a658bda88e5c4b0f5b5b1e7610df787a559e2151838d567ecfe62d.css"):
(Original post follows)
I have a stimulus controller app/javascript/editor/section.js. I am using a default Rails 7 configuration, using import maps along with Stimulus. I am running Puma locally in the development environment, with no changes to default configuration.
Whenever I make changes to my stimulus controller, the web server does not pick up the changes, and continues looking for the outdated controller digest, throwing 404 errors.
Javascript console errors like this:
GET http://localhost:3000/assets/editor/section-ca5da14b07bf02053399e5391d999b5870acc0d8783bb5d7844ce5a22f2278da.js
net::ERR_ABORTED 404 (Not Found)
Failed to register controller: editor (controllers/editor_controller) Error: 404 Not Found
http://localhost:3000/assets/editor/section-ca5da14b07bf02053399e5391d999b5870acc0d8783bb5d7844ce5a22f2278da.js
imported from http://localhost:3000/assets/controllers/editor_controller-0…31577c25719d88e9ca691b7736994a3335959f5513834f370414835d3.js
Puma console also complains:
ActionController::RoutingError (No route matches [GET] "/assets/editor/section-ca5da14b07bf02053399e5391d999b5870acc0d8783bb5d7844ce5a22f2278da.js"):
The reason for the error is known: the file has changed and been rebuilt, so the digest has changed. I just don't understand why the updated file isn't being picked up right away.
I have observed the behavior in Firefox and Chrome, with the Disable HTTP Cache (when toolbox is open) option enabled for both. Restarting the Puma web server will also correct the issue.

Rails Server-- clearing unwanted logs in rails server

when ever I am using my app in local machine I have to on the server
$rails server
each time I do something in my app in the browser all the assets, jquery logs appear in the terminal like
Started GET "/assets/jquery.ui.core.css?body=1" for 127.0.0.1 at 2013-10-11 12:38:44 +0530
....
.....
and so on like this .
If i dont want to see them in my logs each time what should I do?
Am new to Linux
Possible this How to disable logging of asset pipeline (sprockets) messages in Rails 3.1? is the answer your question.
Briefly, you can use this gem: https://github.com/evrone/quiet_assets

Rails Server is not finishing inside terminal

I am new to Rails and working my way through RonR3 Tutorial. Everything has worked perfectly except by page 59
$ rails generate scaffold Micropost content: String user_id:integer.
When I try to run rails s or rails server my terminal application never seems to end. When I ctrl-c to shut down the server after 10+ hours the site can not be found on localHost. Any help would be much appreciated.
Everything seems to stall out around:
Started GET "/assets/users.js?body=1" for 127.0.0.1 at 2012-09-20 13:33:54 -0400
Served asset /users.js - 304 Not Modified (0ms)
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-09-20 13:33:54 -0400
Served asset /jquery_ujs.js - 304 Not Modified (0ms)
After this the terminal just sits there doing nothing...
With programs run from the terminal, they will run there unless they stop or have a daemon option. When you press ctrl-c, the rails webbrick server stops, so of course localhost won't show anything.
When the server is sitting there, it's waiting for a user to visit the site. It won't render views, for example, unless there's a request to render views.
If you want to run the webserver while still using the same terminal window, you need to run rails s as a daemon (background process). Instead, run the command as rails s -d which will "detach" the server process.
On a side-note, why not open multiple terminal windows, if your operating system has a GUI/Window Manager. I normally keep three terminal windows open to run the server, make git commits, check rake routes, etc.
Related Question: Running Webrick server in background?

Setting up rails - 304 Not Modified

I am newbie trying to learn some code. I am following the tutorial on http://guides.rubyonrails.org/getting_started.html
I am up to the point where I've gotten the welcome aboard message at localhost:3000, the last command I typed into my OSX terminal was "rails server"
The server spit out some info and at the end I got this...
Started GET "/assets/rails.png" for 127.0.0.1 at Fri Jan 27 12:44:36
-0500 2012 Served asset /rails.png - 304 Not Modified (2ms)
Started GET "/assets/rails.png" for 127.0.0.1 at Fri Jan 27 12:48:29
-0500 2012 Served asset /rails.png - 304 Not Modified (0ms)
Now the terminal prompt is not coming up...not sure how to fix or what I should do? Thanks to anyone who can help!
When you type in rails server (or rails s for short) the server starts running in that terminal window. This is a good thing. It means that there was no critical error at start up and rails will proceed by showing you a log of what's happening in your app - what resources it's serving, how long does it take, what views is it rendering, what database queries is it running, etc.
To proceed you can either kill the server by pressing control-C or simply open up a new terminal tab by pressing command-T and work from there and you can always switch to the first tab to look at the log if needed. With rails you usually don't need to restart the server so you can usually just keep it running in a tab in your terminal (an exception to that is when editing stuff in config or your Gemfile).
The server runs until you end it by typing Control+C. What it does is turns your computer in to a web server, and allows you to look at your website by going to http://localhost:3000 (by default this is the webport). There is nothing wrong with your computer or program. The server will show you a log of what it's doing while you navigate your website.
The 304 Not Modified is just telling you that when it went to fetch something, it knows it's done it before and the file was not modified. This is usually true of static assets, like images.

How to set path to public in Rails 2.2.3 Application

I am trying to get a local instance up of an existing rails application. It is built on Rails 2.2.3. I keep getting errors that seem to me like I need to set the path to the public directory. When I run "scripts/server" and request pages, I get these errors:
ActionController::RoutingError (No route matches "/favicon.ico" with {:method=>:get}):
...
ActionController::RoutingError (No route matches "/stylesheets/cache/xxx.css" with {:method=>:get}):
ActionController::RoutingError (No route matches "/javascripts/cache/xxx.js" with {:method=>:get}):
How do I set the path to public? Could this have something to do with setting "RAILS_ROOT"?
Thanks
Check that in config/environments/{development,test,production}.rb, serve_static_assets is set to true. Otherwise, Rails will not serve the assets in /public.
Note that in production, you should likely have Apache or whatever web server you use serve those assets. Running it through Rails proper is an unnecessary slow down.

Resources