Ruby on rails 在炼油厂CMS上将重定向添加到routes.rb时出现NoMethodError

Ruby on rails 在炼油厂CMS上将重定向添加到routes.rb时出现NoMethodError,ruby-on-rails,refinerycms,Ruby On Rails,Refinerycms,由于从旧路径重定向到新路径,我添加到routes.rb: Refinery::Core::Engine.routes.prepend do get 'about.html', to: redirect('/about') end mount Refinery::Core::Engine, at: '/' 因此,它没有重定向到“/about”并引发NoMethodError: NoMethodError - undefined method `valid_encoding?' for :e

由于从旧路径重定向到新路径,我添加到routes.rb:

Refinery::Core::Engine.routes.prepend do
  get 'about.html', to: redirect('/about')
end

mount Refinery::Core::Engine, at: '/'
因此,它没有重定向到“/about”并引发NoMethodError:

NoMethodError - undefined method `valid_encoding?' for :en:Symbol:
  actionpack (4.1.9) lib/action_dispatch/routing/redirection.rb:23:in `block in call'
actionpack(4.1.9)lib/action_dispatch/routing/redirection.rb:23:

req.symbolized_path_parameters.each do |key, value|
  unless value.valid_encoding? # <= L23
    raise ActionController::BadRequest, "Invalid parameter: #{key} => #{value}"
  end
end
req.symboliced_path_参数。每个do键,值|

除非value.valid_编码?# 从您发布的内容来看,您缺少一件事,那就是控制器代码。在about_controller.rb中尝试以下操作

def find_page
    @page = ::Refinery::Page.find_by_link_url("/about")
end

@我终于找到了另一个解决办法。我的解决方案是创建静态页面。 我猜在这种情况下,无法通过页面同时保持重定向和动态路由

  • 停止在根目录上安装DefineryCMS,并在“/cms”上安装
  • 创建/app/views/pages/about.html.erb,将其发布为“/about”。参考:
遵循routes.rb:

  mount Refinery::Core::Engine, at: '/cms'
  get 'about.html', to: redirect('/about')
如果还需要按Refinery::Pages管理页面,请在RefineryCMS上创建“/about”页面

以下是app/views/pages/about.html.erb:

<% @page = Refinery::Pages.find_by(link_url: '/about') %>
<%= raw @page.content_for(:body) %>


您可以发布关于页面的控制器代码吗?为什么要打开/about.html而不是/about@DaisukeTerada-精炼厂和重定向404存在完全相同的问题。你找到解决办法了吗?谢谢你的回复。about页面是作为Refinery::page的记录创建的。我希望opening/about.html将重定向到/about。精炼厂::页。未找到通过链接查找url(“/about”):“关于”页面中的链接url为空。关于页面:`-在精炼厂CMS/admin/pages上创建-并将“关于”输入到:title-发布为url“”`