更好的路线练习返回给定参数的JSON

时间:2015-06-23 08:54:19

标签: ruby-on-rails

我想通过Expected request URL获取JSON结果。我怎么能这样做?

当前请求网址:

http://localhost:3000/research/demo/customer/12,13/history.json

预期请求网址

http://localhost:3000/research/demo/customer/history/12,13

当前路线:

namespace :research do
  namespace :demo do
    get 'customer/:items/history.json' => "customer#history"
  end
end

1 个答案:

答案 0 :(得分:0)

  namespace :research do
    namespace :demo do
      get 'customer/history/*items' => "customer#history"
    end
  end

根据请求格式

,每个请求都呈现为html或json或xml