加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 在rails 5.1及更高版本中使用什么而不是`rende

发布时间:2020-12-16 23:35:23 所属栏目:百科 来源:网络整理
导读:Rails 5.1 removes a whole load of previously deprecated methods.其中有老朋友渲染:文字. 当您需要渲染一些文本但不想要视图模板的开销时,它非常有用.例子: render text: "ok"render text: t('business_rules.project_access_denied'),status: 401 用什
Rails 5.1 removes a whole load of previously deprecated methods.其中有老朋友渲染:文字.

当您需要渲染一些文本但不想要视图模板的开销时,它非常有用.例子:

render text: "ok"
render text: t('business_rules.project_access_denied'),status: 401

用什么代替?

解决方法

不推荐使用的方法是使用render:plain

Rails Guide on Layouts and Rendering:

2.2.6 Rendering Text

You can send plain text – with no markup at all – back to the browser by using the :plain option to render:

06000

奖金

而不是渲染任何东西:真实(也被删除),现在应该使用head:ok.做同样的事情:发送http 200响应代码,只发送标题,没有内容.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读