开发者

Where's root_path or root_url?

开发者 https://www.devze.com 2023-04-06 17:21 出处:网络
In rails, there are a lot of helpers to direct our actions, like collections_path new_member_path edit_member_path and so on.

In rails, there are a lot of helpers to direct our actions, like collections_path new_member_path edit_member_path and so on.

But where is the root? Is there a helper开发者_如何学编程 always points to my homepage?


These helpers exist, but you have to set your root url before, in config/routes.rb:

root :to => "controller#action"

You can use root_url and root_path afterwards.

Be warned that there's a catch when doing redirections with the _path helpers, you should use the _url ones when redirecting (see @LanguagesNamedAfterCoffee's comment for the details).

0

精彩评论

暂无评论...
验证码 换一张
取 消