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

ruby-on-rails – 什么是Rails Presenters文件夹?

发布时间:2020-12-17 01:36:15 所属栏目:百科 来源:网络整理
导读:什么是Rails Presenters文件夹?这个文件夹里有什么?为什么需要此文件夹? 解决方法 演示者是一种通常被称为模型视图演示者(MVP)的设计模式 这是模型视图控制器模式的派生,用于创建用户界面. 对于使代码更干燥的问题分离是有用的. 以下是维基百科的描述方式
什么是Rails Presenters文件夹?这个文件夹里有什么?为什么需要此文件夹?

解决方法

演示者是一种通常被称为模型视图演示者(MVP)的设计模式

这是模型视图控制器模式的派生,用于创建用户界面.

对于使代码更干燥的问题分离是有用的.

以下是维基百科的描述方式

model – interface defining the data to be displayed or otherwise acted upon in the user interface.

presenter – acts upon the model and the view. It retrieves data from repositories (the model),and formats it for display in the view.

view – a passive interface that displays data (the model) and routes user commands (events) to the presenter to act upon that data.

https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter

Ruby on Rails中的演示者

演示者是位于模型和视图之间的简单类,并提供了一种很好的,以DRY面向对象的方式来处理复杂的显示逻辑.

在Rails中,约定是它们位于app / presenters文件夹中

这是一篇有用的文章,解释了模式及其在Ruby on Rails中的使用.

https://kpumuk.info/ruby-on-rails/simplifying-your-ruby-on-rails-code/

(编辑:李大同)

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

    推荐文章
      热点阅读