开发者

How do I replace the default url/path REST helpers in Ruby on Rails?

开发者 https://www.devze.com 2023-03-27 01:07 出处:网络
resources :cimgs, :path => :pics, :as => :pics match \'/enviar\'开发者_StackOverflow中文版=> \'cimgs#new\',as: \'new_pic\'
resources :cimgs, :path => :pics, :as => :pics

match '/enviar'开发者_StackOverflow中文版     => 'cimgs#new',         as: 'new_pic'

When I call new_pic_path I keep getting /pics/new instead of /enviar

How should I do?


you might change order cause routes are matched from the top or add :except option to the resources part

resources :cimgs, :path => :pics, :as => :pics, :except => :new


write the below code above like:

match '/enviar'     => 'cimgs#new',         as: 'new_pic'
resources :cimgs, :path => :pics, :as => :pics


First you can write match '/enviar' => 'cimgs#new', as: 'new_pic' above resources :cimgs, :path => :pics, :as => :pics; second - read this: Rails routing

0

精彩评论

暂无评论...
验证码 换一张
取 消