namespace :blog do
resources :posts, :only => [:index, :show], :path => "/"
end
如果我写:
http://localhost:3000/blog/post1
它工作正常。但是,如果我写:
http://localhost:3000/blog/invalid_id_fkdkflskdfl
我在日志中收到 200 响应:
Processing by Blog::PostsController#show as HTML
Parameters: {"id"=>"invalid_id_fkdkflskdfl"}
MOPED: 127.0.0.1:27017 QUERY database.............................
Completed 200 OK in 60ms
在我的模型中:
class Post
include Mongoid::Document
include Mongoid::Slug
#slug
slug :title
#fields
field :title
end
这是我的动作秀:
def show
@post = Post.find(params[:id])
end
我正在使用mongoid_slug宝石
invalid_id_fkdkflskdfl
如果这个 id不存在,为什么我没有收到 404 响应?
如何获得 404 响应?