Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails路由url名称帮助程序_Ruby On Rails_Routing_Refinerycms - Fatal编程技术网

Ruby on rails Rails路由url名称帮助程序

Ruby on rails Rails路由url名称帮助程序,ruby-on-rails,routing,refinerycms,Ruby On Rails,Routing,Refinerycms,需要哪些基本设置来确保路由url名称帮助器工作 例如,在我的路线中,我有以下几点: Blog::Application.routes.draw do resources :news, :as => :news_items, :controller => :news_items, :only => [:show, :index] scope :module => "refinery" do scope(:path => 'refinery', :as

需要哪些基本设置来确保路由url名称帮助器工作

例如,在我的路线中,我有以下几点:

Blog::Application.routes.draw do
  resources :news, :as => :news_items, :controller => :news_items, :only => [:show, :index]

  scope :module => "refinery" do
    scope(:path => 'refinery', :as => 'admin', :module => 'Admin') do
      resources :news, :except => :show, :as => :news_items, :controller => :news_items
    end
  end
end
但以下几点似乎不起作用:

new_refinery_news_url
我不断地犯错误

未定义的局部变量或方法“new\u news\u url”

因此,我很确定我配置应用程序的方式中缺少了一些东西,谁的主要路由是添加到gem文件中的RefineryCMS gem


有什么想法吗?

助手名称将是
新的\u管理员\u新闻\u项目\u url

查找所有路由及其辅助方法很简单。只需运行
rake routes
,您将看到:

          news_items GET    /news(.:format)                   {:action=>"index", :controller=>"news_items"}
           news_item GET    /news/:id(.:format)               {:action=>"show", :controller=>"news_items"}
    admin_news_items GET    /refinery/news(.:format)          {:action=>"index", :controller=>"refinery/Admin/news_items"}
                     POST   /refinery/news(.:format)          {:action=>"create", :controller=>"refinery/Admin/news_items"}
 new_admin_news_item GET    /refinery/news/new(.:format)      {:action=>"new", :controller=>"refinery/Admin/news_items"}
edit_admin_news_item GET    /refinery/news/:id/edit(.:format) {:action=>"edit", :controller=>"refinery/Admin/news_items"}
     admin_news_item PUT    /refinery/news/:id(.:format)      {:action=>"update", :controller=>"refinery/Admin/news_items"}
                     DELETE /refinery/news/:id(.:format)      {:action=>"destroy", :controller=>"refinery/Admin/news_items"}

必须使用
主应用程序。新的炼油厂新闻url
取而代之。

对于可安装的引擎,您始终需要指定“主应用程序”(或炼油厂路线“炼油厂”)前缀,因为引擎与应用程序隔离。

解决方案,如果您使用的是炼油厂以外的路线,是用包含命名路由方法的Rails对象作为命名路径的前缀

Rails.application.routes.url_helpers.new_admin_news_item_path

就是这样,
rake routes
的所有路由都不工作。绕过此问题的唯一方法是直接使用“/refinery/news/new”,如添加图标%>