我坚持这个简单的命名路线问题。我有:
#Controller:
def show
@thing = Thing.find(params[:id])
end
#Routes.rb:
match '/:name' => 'things#show'
我得到的回复是Couldn't find Thing without an ID
。如果我将控制器更改为:
@thing = Thing.find(params[:name])
然后我得到Couldn't find Thing with ID=thing
。我错过了什么?
答案 0 :(得分:5)
@thing = Thing.find_by_name(params[:name])