I want to discard some requests and to nothing. Generate no errors. Rails 4.1.
A route like this:
ActionController::RoutingError (No route matches [GET] "/edist-images/article/bw_2014-mid-year-outlook_180x120.jpg"):
We have to define the routes for those actions which are defined as methods in the BookController class. Open routes. rb file in library/config/ directory and edit it with the following content. The routes.
The Rails router is responsible for redirecting incoming requests to controller actions. The routing module provides URL rewriting in native Ruby. It recognizes URLs and dispatches them as defined in config/routes.
TIP: If you ever want to list all the routes of your application you can use rails routes on your terminal and if you want to list routes of a specific resource, you can use rails routes | grep hotel . This will list all the routes of Hotel.
You can force Rails to respond to specific routes with a HTTP status code. For example, to respond with a 200 OK for your missing image:
get '/edist-images/article/bw_2014-mid-year-outlook_180x120.jpg', to: proc { [200, {}, ['']] }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With