如
@H_404_7@解决方法
200 => Found 403 => Not authorized 404 => Not found
我猜Rails 3已经有这个功能,因为你可以传递哈希来呈现:status => :not_found,我只是找不到方法做到这一点.如果没有人知道可以做到这一点的宝石?
irb(main):001:0> Rack::Utils::HTTP_STATUS_CODES[200] => "OK" irb(main):002:0> Rack::Utils::HTTP_STATUS_CODES[403] => "Forbidden" irb(main):003:0> Rack::Utils::HTTP_STATUS_CODES[404] => "Not Found"
要么
irb(main):004:0> Rack::Utils.status_code(:ok) => 200 irb(main):005:0> Rack::Utils.status_code(:forbidden) => 403 irb(main):006:0> Rack::Utils.status_code(:not_found) => 404