Sinatra端点在localhost上完美运行,但在生产中找不到?

时间:2017-06-10 03:07:28

标签: ruby heroku sinatra

我有一个奇怪的问题我无法排除故障,我得到了一个404的回应主体

<h1>Not Found</h1>

从我的sinatra API部署到heroku时,我有一百条路线,除了这一条之外,它们都能正常工作。这个正在开发......

namespace '/departments' do

  namespace '/department' do

    get '/single' do
      begin
        dept = API::Department.find(params['department_id'])
        status 200
        body json BODY: {
          department: dept.dept_details
        }
      rescue => error
        puts error
        status 403
        body json DETAIL: error
      end
    end

  end

end

1 个答案:

答案 0 :(得分:0)

解决:

显然在localhost中,您可以将名称空间嵌套在彼此之内,但在生产中它不起作用。

namespace '/departments' do

    get '/department' do
      begin
        dept = API::Department.find(params['department_id'])
        status 200
        body json BODY: {
          department: dept.dept_details
        }
      rescue => error
        puts error
        status 403
        body json DETAIL: error
      end
    end

end