在Refinery CMS上添加重定向到routes.rb时的NoMethodError

时间:2015-01-13 09:53:16

标签: 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 :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

打开&#39; localhost:3000 / about.html&#39;

使用gems:refinerycms 3.0.0,rails 4.1.9

解决这个问题的任何想法?

2 个答案:

答案 0 :(得分:0)

根据您发布的内容,您遗漏了一件事,那就是控制器代码。请在about_controller.rb中尝试以下内容。

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

答案 1 :(得分:0)

@ asgeo1最后我找到了另一个解决方案。我的解决方案是通过high_voltage创建静态页面。 我想在这种情况下无法跟上Refinery :: Pages的重定向和动态路由。

  • 停止在根上安装RefineryCMS并安装在&#39; / cms&#39;
  • 创建/app/views/pages/about.html.erb,以便发布为&#39; / about&#39;。参考:high_voltage:Usage

在routes.rb之后:

  mount Refinery::Core::Engine, at: '/cms'
  get 'about.html', to: redirect('/about')

如果您还需要通过Refinery :: Pages管理页面,请创建&#39; / about&#39;关于RefineryCMS的页面,

关注app / views / pages / about.html.erb:

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