web开发敏捷之道2nd-rails进行web开发-笔记(全)


  <price type="decimal">29.95</price>
  <title>Pragmatic Project Automation</title>
  <orders>
    <order>
      <address>dp</address>
      <email>ilm</email>
      <id type="integer">1</id>
      <name>china</name>
      <pay-type>cc</pay-type>
    </order>
    <order>
      <address>china</address>
      <email>[email]ilmf@eyou.com[/email]</email>
      <id type="integer">2</id>
      <name>lee</name>
      <pay-type>cc</pay-type>
    </order>
    <order>
      <address>lfjs</address>
      <email>[email]fjd@china.com[/email]</email>
      <id type="integer">3</id>
      <name>chinaren</name>
      <pay-type>cc</pay-type>
    </order>
    <order>
      <address>dkf</address>
      <email>[email]zllichO@eyou.com[/email]</email>
      <id type="integer">4</id>
      <name>zllicho</name>
      <pay-type>check</pay-type>
    </order>
  </orders>
</product>
可以看到,默认情况下,to_xml方法会导出对象的所有信息。也可以要求它屏蔽某些属性,但这容易让代码变得凌乱。如果希望生成的XML符合特定的schema或者DTD,最后还是使用rxml模板。
扫尾工作
编程已经结束了,不过在将应用程序部署到生产环境之前,做一些整理工作。
为应用程序提供一份完整的文档。在Rails中可以运行Ruby提供的RDoc工具,为应用程序的所有源文件生成漂亮的开发者文档,不过在生成这些文档之前,可能需要创建一个介绍性的页面。这样未来开发者才会知道应用程序到底干了什么。为此编辑doc/README_FOR_APP文件,在里面写上有用的东西。稍后RDoc会对这个文件进行处理,所以可以随便在里面使用什么格式。
= The Depot Online Store

This application implements an online store, with a catalog, cart, and orders.

It is divided into three main sections:

* The buyer's side of the application manages the catalog, cart, and
  checkout. It is implemented in StoreController and the associated
  views.

* Only administrators can access stuff in the AdminController. 
  This is implemented by the LoginController, and is enforced by the     
  ApplicationController#authorize method.

* There's also a simple web service accessible via the InfoController.

This code was produced as an example for the book {Agile Web
Development with
Rails}[[url]http://pragmaticprogrammer.com/titles/rails2[/url]]. It should not be
run as a real online store.

=== Author

Dave Thomas, The Pragmatic Programmers, LLC

=== Warranty

This code is provided for educational purposes only, and comes with
absolutely no warranty. It should not be used in live applications.

== Copyright

This code is Copyright (c) 2006 The Pragmatic Programmers, LLC.

It is released under the same license as Ruby.
然后,用rake命令就可以生成HTML格式的文档。(/doc/app)
depot>rake doc:app
最后,想看看自己编写了多少代码,有一个rake任务可以完成
depot>rake stats
MVC
Model负责维持应用程序的状态。不仅是数据的容器,还是数据的监护者。
View生成用户界面,通常会根据模型中的数据来生成。
Controller负责协调整个应用程序的运转。控制器接收来自外界的事件,与Model进行交互,并将合适的view展现给用户。




本文转自 fsjoy1983 51CTO博客,原文链接:http://blog.51cto.com/fsjoy/75615,如需转载请自行联系原作者
上一篇:【转载】Team Development with Visual Studio .NET and Visual SourceSafe


下一篇:Vue cli路由