简体   繁体   中英

What's the difference between “root to:” and “root ” in rails?

Example:

root 'post#index'

root :to => 'post#index'

I am trying to understand the difference or if there's any difference between the functionality of each one. Does it accomplish the same task?

It's just a shortcut

https://guides.rubyonrails.org/routing.html#using-root

root to: 'pages#main'
root 'pages#main' # shortcut for the above

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM