【发布时间】:2018-05-16 23:38:18
【问题描述】:
当我使用这个方法时:
patch '/posts/:id' do
post = Post.find(params[:id])
post.update(name: params[:name], content: params[:content])
redirect to '/posts/#{post.id}'
end
我收到错误ERROR URI::InvalidURIError: bad URI(is not URI?): http://localhost:9393/posts/#{post.id}
但是当我硬编码 id 或像这样连接字符串时:
redirect to '/posts/' + post.id.to_s
它工作正常。我错过了什么明显的东西吗?
【问题讨论】: