首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

Rails3课程系列之四:Rails3入门(4)

2012-12-21 
Rails3教程系列之四:Rails3入门(4)文章出处:http://edgeguides.rubyonrails.org/getting_started.html?1.

Rails3教程系列之四:Rails3入门(4)

文章出处:http://edgeguides.rubyonrails.org/getting_started.html

?

1. 显示一条Post

当你在index页面点击一条文章的链接时,它将指向一条类似 http://localhost:3000/posts/1 的地址。Rails是把它作为show动作资源来解释的,然后传递 1 作为 :id 的参数。下面是 show 动作:

?

def destroy  @post = Post.find(params[:id])  @post.destroy  respond_with @postend

?destroy方法将从数据库中移除相应的记录,然后浏览器将跳转到 index 页面。

?

?

热点排行