简体   繁体   中英

Generate absolute URL from an array of route components

link_to 'My account', [:edit, :admin, :account, :details]

The code above does successfully resolve to the following relative path:

/admin/account/details/edit

Is it possible, using the same array, to render the absolute url? Ie

mydomain.com/admin/account/details/edit

You can simply use url_for:

link_to 'My account', url_for([:edit, :admin, :account, :details])

Check out this document

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