【问题标题】:Issue with path helper for named routes命名路由的路径助手问题
【发布时间】:2013-09-22 03:10:18
【问题描述】:

我正在使用以下控制器实现一个用于在 Rails 应用中提供静态页面的系统:

class PagesController < ApplicationController
  def about
    render 'pages/about'
  end
end

我的路线设置如下:

get 'about', to: 'pages#about', as: :about

我可以访问 www.example.com/about,它会正确呈现 about 内容,但如果我尝试在视图中的任何位置使用带有 link_to 的 about_path 帮助器,我会在 about_path 上收到未定义的方法错误。搜索我的路线会返回“关于 GET /about(.:format) pages#about”

有人知道为什么这个助手没有注册吗?

【问题讨论】:

    标签: ruby-on-rails routes


    【解决方案1】:

    这是与 Spree 集成导致的问题。下面的链接提供了两种可行的解决方案。

    Adding Routes to Rails' Spree E-Commerce

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-03
      • 1970-01-01
      • 1970-01-01
      • 2015-09-19
      相关资源
      最近更新 更多