redirect_to的帮助举了一个例子:
redirect_to post_url(@post), :status=> :found, :notice => "Pay attention to the road"
其中的post_url(@post)是什么意思呢?网上没搜到具体的例子,能否举一个实际例子?
redirect_to的帮助举了一个例子:
其中的post_url(@post)是什么意思呢?网上没搜到具体的例子,能否举一个实际例子?
http://guides.rubyonrails.org/routing.html#paths-and-urls
_path _url这样的方法都是链接生成辅助方法
比如你在路由定义了 resources :photos
那么会有这些_path _url方法
[quote]photos_path returns /photos
new_photo_path returns /photos/new
edit_photo_path(:id) returns /photos/:id/edit (for instance, edit_photo_path(10) returns /photos/10/edit)
photo_path(:id) returns /photos/:id (for instance, photo_path(10) returns /photos/10)[/quote]
post_url(@post)也是一个方法,最终返回http://host/posts/1 (这里的1是@post的id)
认真看看官方的手册,英文有压力的话,就看