繁体   English   中英

Rails 3路径路径构建问题

[英]rails 3 route path building issue

我有这样的路线:

scope ':property', :constraints => { :property => /inv|um|tm|pp/ } do
      resources :user_templates do
        member do
          get 'download/:idcreated', :action => 'download'
        end
      end
end

在浏览器http://127.0.0.1:3000/inv/user_templates/6/download/12?locale=uk ,它可以工作。

但是如何建立资源路径?

我试过了:

download_user_template_path(params[:property], @id, @idcreated)

但我得到了以下信息:

No route matches {:action=>"download", :controller=>"user_templates", :locale=>:uk, :property=>"inv", :id=>76, :format=>6}

它也不起作用:

download_user_template_path('property' => params[:property], 'id' => @tmp_id, 'idcreated' => @created_temp_row[:id])

rake routes

                  GET    /:property/user_templates/:id/download/:idcreated(.:format) {:property=>/inv|um|tm|pp/, :action=>"download", :controller=>"user_templates"}
   user_templates GET    /:property/user_templates(.:format){:property=>/inv|um|tm|pp/, :action=>"index", :controller=>"user_templates"}
                  POST   /:property/user_templates(.:format){:property=>/inv|um|tm|pp/, :action=>"create", :controller=>"user_templates"}
new_user_template GET    /:property/user_templates/new(.:format){:property=>/inv|um|tm|pp/, :action=>"new", :controller=>"user_templates"}
edit_user_template GET    /:property/user_templates/:id/edit(.:format){:property=>/inv|um|tm|pp/, :action=>"edit", :controller=>"user_templates"}
     user_template GET    /:property/user_templates/:id(.:format){:property=>/inv|um|tm|pp/, :action=>"show", :controller=>"user_templates"}
                   PUT    /:property/user_templates/:id(.:format){:property=>/inv|um|tm|pp/, :action=>"update", :controller=>"user_templates"}
                   DELETE /:property/user_templates/:id(.:format){:property=>/inv|um|tm|pp/, :action=>"destroy", :controller=>"user_templates"}

有什么帮助吗?

只需添加:as =>:download,并使用耙路径CONTROLLER = ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM