Rails Routes issue on heroku - ruby-on-rails

My app working fine on localhost but when I push app on heroku, its show error on heroku. Heroku log below
ActionController::RoutingError (No route matches [POST] "/forgot_password"):
and below is rake routes result
My app working fine on localhost but when I push app on heroku, its show error on heroku log below
ActionController::RoutingError (No route matches [POST] "/forgot_password"):

Your routes suggest the path as "/api/v1/forgot_password". And you are getting the path error as "/forgot_password".
Check the form where you are routing to this path.

I think you forgot add routes.rb file with your commit. you need to push that file on heroku

Related

ActionController::RoutingError (No route matches [GET] "/serviceworker.js"):

Installed Rails 6.0.3. Ran rails new [app], started the server, loaded the homepage and the server logs are showing this routing error. Any ideas? Here's my routes file which I haven't touched.
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
Going into Chrome's Dev Tools > Application > Clear Storage fixed my issue.
If you want to use the service-worker in the rails, please refer to as follows
https://github.com/rossta/serviceworker-rails

Rails Tutorial sample_app fails in Heroku with log: ActionController::RoutingError (No route matches [GET] "/about"):

I am following the online version of Rails Tutorial. The Sample_app in chapter 3 works fine locally, but when pushed to Heroku, the home page is found but not the other pages. Running heroku logs after trying to see the About page gives me (along with much else) the error above:
2015-08-09T02:56:43.916991+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/about"):
My routes.rb file is
Rails.application.routes.draw do
root 'static_pages#home'
get 'static_pages/help'
get 'static_pages/about'
end
I have followed the directions carefully. I tried deleting and recreating the Heroku file. I did web searches and tried some things to no avail. My gemfile is straight from the online version of the book, which is using current versions.
Solved: #thedanotto had me run heroku run rake routes which showed that the help and about pages were directed to {root}/static_pages/about rather than {root}/about. I am still puzzled why the tutorial gives the about routes, which appear not to work as expected, and welcome any further comment, but I am marking this as solved.
Whenever I can't find a route, I run the terminal command
rake routes
Since you're on heroku you'll want to run
heroku run rake routes
Which will return something similar to the following.
Prefix Verb URI Pattern Controller#Action
static_pages_about GET /static_pages/about(.:format) static_pages#about
So that shows that you can go to www.[heroku_app_name].herokuapp.com/static_pages/about And it will bring you to the page you want. You can also add a link to the page in a view by putting the following line of code within a view.
<%= link_to("About", static_pages_about_path) %>
That's all good stuff to know. But let's talk about using the controller action: static_pages#about with the path /about
Switch the following in routes.rb from
get 'static_pages/about'
to
get "static_pages/about", path:"/about"
or alternatively
get "/about", to: "rabbits#about"
You can read more about Routes here
If it works fine locally, I assume you've set up the controllers, views etc properly.
Have you made sure to commit all those necessary changes then push?
e.g.
git add .
git commit -am "Added route"
git push heroku master
Are you accessing the about page using the following URL ?
http://YourHerokuAppName.herokuapp.com/static_pages/about
[ Replace "YourHerokuAppName" with your Heroku App Name]

Rails Route missing in Production

I have an a Rails 3.2 App that show an error for Route not found in production
but not in development. I ran rake Route on my local machine and on the server and the text below show they are identical. I checked the route config file and it was identical and the views were the same. THe exact message I get in production is:
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
The two outputs from rakes routes is:
Rake Route Development:
harvest GET /harvest(.:format) visits#harvest
Rake Route from Production
harvest GET /harvest(.:format) visits#harvest
I am stumped is there anything else to look at. THe local machine is a Macbook the server is Centos

Routing Issues Trying to Upload a File in Rails

I'm trying to learn how to upload a data file to an application by following the instructions http://bit.ly/JgJyV and http://bit.ly/LXZ44L.
After following the instructions and typing in the code I open my browser and go to the link below.
localhost URL on port 3000: .../upload/index
Routing Error
No route matches [GET] "/upload/index"
Try running rake routes for more information on available routes.
I update config/routes.rb with:
resources: upload
Revisit localhost URL on port 3000: .../upload/index
Unknown action
The action 'show' could not be found for UploadController
Try localhost URL on port 3000: .../upload
Works! I select a file and click the Upload button:
Routing Error
No route matches [POST] "/assets"
rake routes returns:
Steves-iMac:config steve$ rake routes
upload_index GET /upload(.:format) upload#index
POST /upload(.:format) upload#create
new_upload GET /upload/new(.:format) upload#new
edit_upload GET /upload/:id/edit(.:format) upload#edit
upload GET /upload/:id(.:format) upload#show
PUT /upload/:id(.:format) upload#update
DELETE /upload/:id(.:format) upload#destroy
Any ideas?
There are widely used ruby gems to do what you want to do: Paperclip and Carrierwave.
So, why reinvent the wheel?

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