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?
Related
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
Getting error while creating webservices on Ruby on Rails.
I have followed what ever the steps mentioned in this.
After starting the Server with rails server command, when I am hitting http://localhost:3000/hello_message/wsdl, it's giving me the error:
ActionController::RoutingError (No route matches [GET] /hello
message/wsdl)
routes.rb:
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
That tutorial is from 2008, I'm not quite sure but maybe this could help you to fix it
Add resources :hello_messages
or
get '/hello_messages/wsdl' => 'hello_messages#hello_messages'
This should be inside of Rails.application.routes.draw do
But I'll recommend you to look for more recent tutorials
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]
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
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