Ruby on Rails:修订间差异
ShiningRay(留言 | 贡献) |
|||
第59行: | 第59行: | ||
*[http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html Onlamp.com的Ajax on Rails] |
*[http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html Onlamp.com的Ajax on Rails] |
||
*[http://www-128.ibm.com/developerworks/linux/library/l-rubyrails/ Fast-track your Web apps with Ruby on Rails] ([[David Mertz]] article at IBM [[developerWorks]]) |
*[http://www-128.ibm.com/developerworks/linux/library/l-rubyrails/ Fast-track your Web apps with Ruby on Rails] ([[David Mertz]] article at IBM [[developerWorks]]) |
||
*[http://www-128.ibm.com/developerworks/cn/java/wa-rubyonrails/ Ruby on Rails 和 J2EE:两者能否共存?]] |
|||
===热门的支持Ruby on Rails的空间服务=== |
===热门的支持Ruby on Rails的空间服务=== |
2005年8月12日 (五) 14:42的版本
Ruby on Rails, 也称 RoR 或简称 Rails, 是一个使用Ruby语言写的开源网络应用 框架,它是严格按照Model-View-Controller (MVC) 结构开发的。它努力使自身保持简单,来使实际的应用开发时的代码更少,使用最少的配置。
Rails的设计原则包括“不要重复自己”(Don't Repeat Yourself)和“约定优于配置”(Convention Over Configuration)
历史
Ruby on Rails 是从一个项目管理工具Basecamp中抽出来的,由David Heinemeier Hansson制做。它首次公开发布是在2004年6月。
Rails的 MVC 结构
Ruby on Rails的模型-视图-控制器架构由以下各部分组成:
模型Model
在面向对象、数据库驱动的MVC Web应用中,模型In object-oriented, database-driven MVC web applications, Model consists of the classes representing RDBMS tables.
在RoR中,模型类是通过Active Record模式进行处理的。一般来说,程序员要做的是继承ActiveRecord
类,同时程序会自动计算出要使用哪个RDBMS表,这个表有哪些列。表与表之间的关系通过简单的命令来指明。
视图
在 MVC 中, 视图View 是显示的逻辑,也就是数据如何从控制器类中显示出来的。在Web应用中,is the display logic, or how the data from the Controller classes is displayed. In web applications, this frequently consists of a minimal amount of code, interspersed in HTML.
Views are done as a fragment of HTML (.rhtml files) with Embedded Ruby interspersed or programmatically used in pure Ruby through Builder. The actual code is part of Rails' Action Pack, but programmers rarely need to touch it outside of Embedded Ruby.
For each method in the controller that needs to display user output, a small HTML code fragment needs to be written. The page layout is described separately from the controller action that displays layouts, and the fragments can also call other fragments.
控制器
在MVC中,控制器类用来处理应用程序的逻辑,它操作模型中的数据并通过视图把数据显示出来。在Web的MVC应用中,控制器方法是用户通过Web浏览器来启动的。
控制器 的实现是通过Rails的 Action Pack来进行处理,Action Pack有一个类,ApplicationController
。Rails 应用仅仅只要继承ApplicationController
并把必须的行为以方法的形式写出来,然后就可以通过Web访问了。
Rails 也提供了预设状态下的(out-of-the-box)脚手架,他可以快速构造大多数的必需逻辑和视图来完成一般的操作,例如 CRUD。
其它模块
In addition to this, Rails also offers some other modules, like Action Mailer for sending email and Action Web Service for SOAP and XML-RPC support.
Rails中的AJAX
一个独立的技术称为 AJAX,可以让which allows for using Javascript and XML to process queries by a 浏览器 to a Web服务器 as 后台处理 without 载入额外的网页, has been combined with this technology to produce a system referred to as "Ajax on Rails". Rails 提供一些助手工具来更方便地实现AJAX应用。
Web服务器支持
For development and testing, the lightweight WEBrick web server included with Ruby is often used as the application server. For production use, Apache or Lighttpd with FastCGI is recommended, but any web server with CGI or FastCGI support will work. On Apache, mod_ruby can help with performance considerably.
数据库支持
Since the Rails architecture strongly favors database use, an RDBMS system is recommended for data storage, but Rails also supports the SQLite library if running an RDBMS server is not possible. Multiple RDBMS systems are supported, including MySQL, PostgreSQL, SQLite, DB2, Oracle and SQL Server.
这是一篇與计算机相關的小作品。您可以通过编辑或修订扩充其内容。 |
外部链接
参考站点
- Ruby On Rails项目首页
- Onlamp.com的Ajax on Rails
- Fast-track your Web apps with Ruby on Rails (David Mertz article at IBM developerWorks)
- Ruby on Rails 和 J2EE:两者能否共存?]
热门的支持Ruby on Rails的空间服务
模板参数错误!(代码36)
|