在我的应用程序标题中,我试图让我的导航栏品牌成为我的应用程序根页面的链接。我正在使用嵌入式红宝石
<a class="navbar-brand" <%= link_to "Document", "root_path" %></a>
</div>
这是我一直得到的错误;
No route matches [GET] "/root_path"
root_path GET / pages#home
about_path GET /about(.:format) pages#about
prices_path GET /prices(.:format) pages#prices
faq_path GET /faq(.:format) pages#faq
terms_path GET /terms(.:format) pages#terms
view_path GET /view(.:format) pages#view
policy_path GET /policy(.:format) pages#policy
我的路线页面;
Document::Application.routes.draw do
root "pages#home"
get "about" => "pages#about"
get "prices" => "pages#prices"
get "faq" => "pages#faq", :as => :faq
get "terms" => "pages#terms"
get "view" => "pages#view"
get "policy" => "pages#policy"
答案 0 :(得分:1)
从root_path链接中取出引号。
<%= link_to "Document", root_path, "class" => 'navbar-brand' %>
此外,link_to
将创建一个标签;你在ERB中不需要它