I'm using Rails 6.1 with #hotwired/stimulus and importmap.
I'm getting this error in dev env.
ActionController::RoutingError (No route matches [GET] "/assets/stimulus-loading.js")
importmap.rb:
pin "application"
pin "#hotwired/stimulus", to: "stimulus.js"
pin "#hotwired/stimulus-loading", to: "stimulus-loading.js"
pin_all_from "app/javascript/controllers", under: "controllers"
pin "#hotwired/turbo-rails", to: "turbo.js"
The temporary solution is to set the stimulus-loading precompiled file:
pin "application"
pin "#hotwired/stimulus", to: "stimulus.js"
pin "#hotwired/stimulus-loading", to: "/assets/stimulus-loading-1fc59770fb1654500044afd3f5f6d7d00800e5be36746d55b94a2963a7a228aa.js"
pin_all_from "app/javascript/controllers", under: "controllers"
pin "#hotwired/turbo-rails", to: "turbo.js"
The only 'pin' which is failing is stimulus-loading.js. why?
I already followed https://github.com/hotwired/stimulus-rails
Any help, idea or comment is very welcome. Thanks for your time!
Gems:
'ruby' '2.6.8'
'rails', '~> 6.1'
'importmap-rails'
'stimulus-rails'
'turbo-rails'
Related
I'm trying to use out-of-the-box spree routes, but I'm running up against an error that prevents me from migrating my database or precompiling my assets for Heroku:
rake aborted! ArgumentError: Invalid route name, already in use:
'account_link' You may have defined two routes with the same name
using the :as option, or you may be overriding a route already
defined by a resource with the same naming. For the latter, you can
restrict the routes created with resources as explained here:
https://guides.rubyonrails.org/routing.html#restricting-the-routes-created
My routes can be seen below, but I'm not doing any custom spree routes:
Rails.application.routes.draw do
# This line mounts Spree's routes at the root of your application.
# This means, any requests to URLs such as /products, will go to
# Spree::ProductsController.
# If you would like to change where this engine is mounted, simply change the
# :at option to something different.
#
# We ask that you don't use the :as option here, as Spree relies on it being
# the default of "spree".
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
# COSMETICS
get 'home/index'
root 'home#index'
get 'home/info'
get 'home/export'
get 'home/kits'
get 'kits/XR250_XR400'
get 'kits/XR600'
get 'kits/XR650L'
get 'kits/polaris_key_covers'
get 'kits/replacement'
get 'kits/rear_fenders_1'
get 'kits/rear_fenders_2'
get 'kits/graphics'
get 'other/xr400mx'
# PHOTOS
resources :photos
put "photos/:id/approve" => "photos#approve", as: "approve_photo"
put "photos/:id/unapprove" => "photos#unapprove", as: "unapprove_photo"
# CONTACT US
resources :contacts
put "contacts/:id/archive" => "contacts#archive", as: "archive_contact"
put "contacts/:id/unarchive" => "contacts#unarchive", as: "unarchive_contact"
get 'admin/blogs'
post 'uploader/image', to: 'uploader#image'
get 'admin/resources'
get 'admin/subcategories'
get 'admin/subscribers'
resources :blogs
resources :lead_magnets
resources :subscribers
resources :subcategories
mount Spree::Core::Engine, at: '/store', as: 'spree'
end
When I try to push to Heroku it shows the error is somewhere inside railties?
remote: Running: rake assets:precompile remote:
DEPRECATION WARNING: Single arity template handlers are deprecated.
Template handlers must remote: now accept two parameters, the
view object and the source for the view object. remote: Change:
remote: >> Coffee::Rails::TemplateHandler.call(template)
remote: To: remote: >>
Coffee::Rails::TemplateHandler.call(template, source) remote:
(called from at /tmp/build_3e42be0e/Rakefile:6) remote:
rake aborted! remote: ArgumentError: Invalid route name,
already in use: 'account_link' remote: You may have defined
two routes with the same name using the :as option, or you may be
overriding a route already defined by a resource with the same naming.
For the latter, you can restrict the routes created with resources
as explained here: remote:
https://guides.rubyonrails.org/routing.html#restricting-the-routes-created
remote:
/tmp/build_3e42be0e/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.2/lib/action_dispatch/routing/route_set.rb:578:in
`add_route'
I am seriously out of my depth here. Please help!
I'm running these spree-related gems:
gem 'spree', '~> 4.0'
gem 'spree_auth_devise', '~> 4.0.0'
gem 'spree_gateway', '~> 3.6'
I have an application my_app, and an engine my_engine.
my_app routes:
Rails.application.routes.draw do
mount MyEngine::Engine => "/api"
end
my_engine routes:
MyEngine::Engine.routes.draw do
post "files/sync" => "files#sync"
end
From my_app, I run rails routes, and see the following:
Prefix Verb URI Pattern Controller#Action
my_engine_engine /api MyEngine::Engine
Routes for MyEngine::Engine:
As you can see, Routes for MyEngine::Engine: displays 0 results. I've tried every answer in the books about this issue, but nothing works.
Why are my engine routes not being listed by the app?
(Note that my_engine is a local gem — do I have to do something special to reload it possibly?)
One solution turned out to be changing:
gem 'my_engine', path: '/Users/me/Desktop/my_engine_gem'
to:
gem 'my_engine', path: '/Users/me/Desktop/my_engine_gem', require: 'my_engine'
This worked, even though placing require 'my_engine' in an initializer did not work. Not sure what the distinction is.
How to hide from production.log all routing errors to users uploaded files like this
ActionController::RoutingError (No route matches [GET] "/uploads/*
An easy way will be to use the Silencer gem: https://github.com/stve/silencer
Something like this should work:
config.middleware.swap Rails::Rack::Logger, Silencer::Logger, :silence => [%r{^/uploads/}]
ruby -v = 2.1.6p336
rails -v = 4.2.1
MySQL --version = 14.14
New to programming and Rails. Going through tutorials.
did rails generate controller welcome index.
Rails Server - localhost:3000 shows Welcome aboard page.
Change config/routes.rb file... un-comment out root 'welcome#index' (got rid of the #. (line 8)
Rails Server - localhost:3000 shows error.
----------copied from localhost:3000------------------------------------------
ExecJS::ProgramError in Welcome#index
Showing c:/row/dev/readit/app/views/layouts/application.html.erb where line #6 raised:
TypeError: Object doesn't support this property or method
Rails.root: c:/row/dev/readit
Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___173287605_49138164'
commented the root 'welcome#index' out again, and I have the Welcome Aboard page back.
If I execute localhost:3000/index
I get a routing error. No route matches [GET] "/index"
I have:
controllers/welcome_controller.rb
views/welcome/index.html.erb
this is the start of the config/routes.rb file -----------------
Rails.application.routes.draw do
get 'welcome/index'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'welcome#index'
How do I get the config/routes.rb file to display the views/welcome/index.html.erb file?
Does this have anything to do with the MySQL socket I'm suppose to put in the config/database.yml ? Because I don't what to put there.
It looks like there is an error at line 6 on "application.html.erb". If you want to create a hyperlink from that page to the "root" page, you should use the following view helper:
<%= link_to "Home", root_path %>
When the page is rendered and you check the HTML code using the Chrome's inspector, you will see that above code is converted to:
Home
In your app/views/layouts/application.html.erb, try changing the line:
<%= javascript_include_tag 'application', data-turbolinks-track => true %>
To this (removing the data-turbolinks-track => true):
<%= javascript_include_tag 'application' %>
That might fix it. You shouldn't remove the entire line as it's likely you'll need JS available in your layout at some point in the project :)
Hope it helps!
I fixed it by renaming my [It may not sound correct but it worked for me , give it a try]
app/views/layouts/application.html.erb
TO
app/views/layouts/default.html.erb
I hope it works for you as well
I have a rails app with a cappuccino front end that I am trying to deploy onto Heroku.
The app works fine when I run it on localhost using WEBrick, but when I push onto Heroku I get the error message ActionController::RoutingError (No route matches "/"):
Here is the contents of the routing file:
CappcourceWs::Application.routes.draw do
resources :transaction_logs
resources :users
end
Is there a route that I have failed to define?
Doesn't look like a heroku-specific problem. My first guess is you need to add a root route, such as:
CappcourceWs::Application.routes.draw do
root :to => 'users#login'
resources :transaction_logs
resources :users
end
...or whatever the appropriate action/view is in your case.