iteye_2203 2010-05-03 18:00
浏览 184
已采纳

Ruby on Rails: /account/edit 与 /account/edit.current

刚开始看RUBY ON RAILS, 请问 http://127.0.0.1:3000/account/edit
http://127.0.0.1:3000/account/edit.current
的区别?
还有就是 /account/edit 使用 edit.html.erb 来显示内容, 并能正常显示布局, 而 /account/edit.current 使用 edit.erb, 并且不能显示布局

谢谢

  • 写回答

2条回答 默认 最新

  • WalleZhang 2010-05-07 09:18
    关注

    [code="html"]http://127.0.0.1:3000/account/edit
    http://127.0.0.1:3000/account/edit.current [/code]

    这两个的区别是后缀不一样,所以需要渲染的页面的后缀名字也不一样,第一个地址渲染的是html后缀的erb文件,也就是edit.html.erb,而后面的那个渲染的是edit.current.erb文件。

    这个是根据account_controller里面的respond_to语句来决定的

    [code="ruby"]
    respond_to do |format|
    format.html
    format.xml { render :xml => @articles }
    format.current
    end
    [/code]

    这个就是决定不同格式渲染的不同页面

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?