Rails 3.1 设计插件失败

发布于 2024-12-10 13:13:59 字数 827 浏览 0 评论 0原文

ActionView::Template::Error (No route matches {:controller=>"devise/items"}):
    8: </head>
    9: <body>
    10:   <nav>
    11:   <%= link_to_unless_current "Home", :controller => "items", :action => "index" %> |
    12:   <%= link_to_unless_current "About us", :controller => "site", :action => "about" %> | 
    13:   <%= link_to_unless_current "Contact us", :controller => "site", :action => "contact" %> 
    14:   </nav>

我正在尝试制作一个简单的 Rails 在线商店。我包含了设计模型 User(严格遵循 Railcasts 教程),当我尝试访问 /users/sign_in 时,我在服务器日志中收到此错误。我不明白为什么当我输入 localhost:3000/users/sign_in 时它会呈现“devise/items”。

额外: 路线.rb:

devise_for :users
get "site/about"
get "site/contact"

resources :items
root :to => "items#index"
ActionView::Template::Error (No route matches {:controller=>"devise/items"}):
    8: </head>
    9: <body>
    10:   <nav>
    11:   <%= link_to_unless_current "Home", :controller => "items", :action => "index" %> |
    12:   <%= link_to_unless_current "About us", :controller => "site", :action => "about" %> | 
    13:   <%= link_to_unless_current "Contact us", :controller => "site", :action => "contact" %> 
    14:   </nav>

I'm trying to make a simple rails online shop. I included devise model User(strictly following Railcasts tutorial) and when I'm trying to go to /users/sign_in I get this error in the server log. I don't understand why it renders "devise/items" when I'm typing localhost:3000/users/sign_in.

Added:
routes.rb:

devise_for :users
get "site/about"
get "site/contact"

resources :items
root :to => "items#index"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫弦 2024-12-17 13:14:00

您可以在控制器名称前添加“/”来修复它。

<%= link_to_unless_current "Home", :controller => "/items", :action => "index" %> 

You can fix it adding a "/" before your controller name.

<%= link_to_unless_current "Home", :controller => "/items", :action => "index" %> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文