我设置了high_voltage来在我的应用中创建静态页面。不过我现在又添加了一个新的投资控制器。我正在尝试创建一个从application.html.erb到控制器的链接,它给了我以下错误。我相信它正试图在High_Voltage内部进行路由(对此仍然有点新鲜)
ActionController::UrlGenerationError in HighVoltage::Pages#show
No route matches {:action=>"index", :controller=>"high_voltage/investments", :id=>"about"}
application.html.erb看起来像这样:
<li> <%= link_to 'About', page_path('about') %> </li>
<li> <%= link_to 'Real Estate', controller: 'investments' %></li>
routes.rb看起来像这样:
Rails.application.routes.draw do
devise_for :users
devise_for :views
mount Ckeditor::Engine => '/ckeditor'
get 'pages/index' => 'high_voltage/pages#show', id: 'index'
root :to => 'high_voltage/pages#show', id: 'index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :posts
resources :properties
resources :articles
resources :investments
end
我在这里尝试了所有其他选项但没有取得多大成功:/
答案 0 :(得分:1)
在application.html.erb中尝试使用Real Estate链接。感谢
<li> <%= link_to 'Real Estate', investments_path %></li>