I cannot find the meaning of the keyword "mount" in Rails routing system.
I have set up Mercury to use within my Rails application. It added this line to my routes.rb
config file:
Appname::Application.routes.draw do
mount Mercury::Engine => '/'
What does the mount
keyword mean?
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.
rake routes will list all of your defined routes, which is useful for tracking down routing problems in your app, or giving you a good overview of the URLs in an app you're trying to get familiar with.
The routing module provides URL rewriting in native Ruby. It's a way to redirect incoming requests to controllers and actions. It replaces the mod_rewrite rules. Best of all, Rails' Routing works with any web server. Routes are defined in app/config/routes.
Mount within the Rails routes does the equivalent of a Unix mount
.
It actually tells the app that another application (usually a Rack application) exists on that location.
It is used mostly for Rails Engines.
Mounting an engine means that the functionality from that engine is available inside your application.
See http://guides.rubyonrails.org/engines.html#mounting-the-engine
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