路径助手奇怪的输出

时间:2013-06-08 11:42:28

标签: ruby-on-rails

Rake路线相关输出:

 colorschemes GET    /colorschemes(.:format)                 colorschemes#index
                       POST   /colorschemes(.:format)                 colorschemes#create
       new_colorscheme GET    /colorschemes/new(.:format)             colorschemes#new
      edit_colorscheme GET    /colorschemes/:id/edit(.:format)        colorschemes#edit
           colorscheme GET    /colorschemes/:id(.:format)             colorschemes#show
                       PUT    /colorschemes/:id(.:format)             colorschemes#update
                       DELETE /colorschemes/:id(.:format)             colorschemes#destroy
          choose_color GET    /choose_color(.:format)                 colorschemes#choose_color

当我使用路径助手时:

<%= link_to 'delete', colorschemes_path(@colorscheme), :method=>:delete, :remote=>true %>

输出为:Started DELETE "/colorschemes.4"

而不是“/colorschemes/4

为什么?

1 个答案:

答案 0 :(得分:0)

你需要做colorscheme_path(@colorscheme) - 单数,而不是复数!