《Agile Web Development with Rails》读书笔记(二)

原创 2007年09月19日 15:06:00

Instant Gratification

After the Rails environment has been established, I write a simple application to verify we have got Rails snugly installed on my machine.

        I.              Create a new project

Rails application is a bunch of Ruby source code, but does a lot of magic behind the curtain to minimum the explicit configuration.

I’ll use a new command-line tool rails to create my first project.

To create the first Rails application, pop open a shell window, navigate to a place in the file system where I want to create the application directory structure.

  work>rails demo

This command creates a bunch of files and subdirectories, you can cd demo to have a look at it.

Two directories will be used in this example:

app: the kernel of MVC, put application code files here.

script: contain some useful utility scripts.

In order to see the result of create application, I start the stand-alone develop web server:

  work>ruby script/server

note: this command will hang up the command shell, so open another shell window, change to the application directory to run the above command.


The service start on port 3000. I access the application using the URL

the work of “create new application” is finished when I see the “welcome aboard” page in the browser.

Now, let’s write some content for this application.

     II.              Hello Rails!

Before I write some content for the application, first I introduce some concept.

The Architecture of Rails:

Rails accept a request from browser, decodes the request to find the controller, and call the action method in that controller. The controller then invoke a particular view to display the result to the user.

Rails and Request URLs

Like other web application, Rails application appears to its users to be associate with a URL.

I’ll take a URL as an example to explain it:

Rails uses the path to determine the name of the controller to use and the name of the action to invoke in that controller.

My First Action

Ok, now let’s write some content for our application.

Followed the discussion in the previous section, the hello action means create a method in the class SayController.

The controller’s job is to set up things so that the view knows what to display.


class SayController > ApplicationController

   def hello






      <title>Hello, Rails!</title>



      <h1>Hello from Rails!</h1>



Save these two files, and refresh the browser, then you should see my friendly greeting.

Agile Web Development with Rails第十二章笔记——任务G:付款

如标题所示,这一章的主要目的就是完成付款功能,整个任务由以下几个模块迭代完成。 迭代G1:获取订单 订单是商品项目及其购买交易的细节的集合,为了存储购买交易的细节,下面我们需要创建表orders。...
  • lissdy
  • lissdy
  • 2013年06月10日 17:50
  • 1208

Agile Web Development with Rails第十一章笔记——任务F:Ajax初体验

本章内容: 使用局部模版呈现页面布局利用Ajax和RJS动态更新页面利用Script.aculo.us高亮变化隐藏和显示DOM元素测试Ajax更新 本章目标: 为购物车添加Ajax,...
  • lissdy
  • lissdy
  • 2013年06月06日 11:01
  • 1697

Agile Web Development with Rails第九章笔记——任务D:创建购物车

本章内容: 会话和会话管理添加模型间的关系创建一个按钮,可添加产品到购物车中 迭代D1:寻找购物车 将购物车放在数据库中,并在会话中存储该购物车的唯一标识符,cart.id。每当请求出现...
  • lissdy
  • lissdy
  • 2013年05月23日 10:18
  • 1933

Agile Web Development with Rails第十章笔记——任务E:更智能的购物车

本章内容: 修改数据库模式与现有数据诊断和处理错误闪存日志 迭代E1:创建更智能的购物车 问题提出:保存与显示购物车中同一产品的数量 解决方案:修改line_items表,添加描述...
  • lissdy
  • lissdy
  • 2013年06月03日 16:43
  • 1191

Mastering Web Application Development with AngularJS-Packt 2013 读书笔记(不错的好书!)

Angular Zen Batarang Batarang is a Chrome developer tool extension for inspecting the AngularJ...
  • cteng
  • cteng
  • 2017年08月03日 14:29
  • 419

Agile Web Development with Rails.pdf(英文)

  • 2010年09月15日 15:28
  • 383KB
  • 下载

Pragmatic - Agile Web Development with Rails 2nd

  • 2010年10月15日 18:55
  • 5.94MB
  • 下载

Agile Web Development with Rails中文版

  • 2007年09月14日 09:41
  • 5.01MB
  • 下载


  • 2007年07月09日 12:23
  • 6.42MB
  • 下载

Agile.Web.Development.with.Rails.4(2013.10).Sam.Ruby.文字版.pdf 一书的配套代码

  • 2016年09月28日 16:01
  • 21.69MB
  • 下载
您举报文章:《Agile Web Development with Rails》读书笔记(二)