zoukankan      html  css  js  c++  java
  • Rails框架技术讲座:如何定义自己的Rails应用软件入门位置

     (一)系统环境:

    1. Ruby 语言 1.8.4版本, 点击这里Ruby1.8.4
    2. Rails 框架 1.1.6版本,安装方法:
      gem install rails -v=1.1.6
    3. Windows XP 或者 Windows 2000操作系统 或者 Linux操作系统
    4. 需要一个浏览器,如FireFox1.5.0.1
    5. 开发编辑工具 Notepad2 ,安装方法请单击这里,复制一个notepad2.exe,并且更名为vi.exe。
    6. 在Windows XP上安装Linux核心命令,点击这里

     (二)前提条件:

    1. 在本机Winodw操作系统上,我们的工作目录为d:\works_rails。
    2. 你的电脑必须在线。

     (三)目的:

    1. 在Rails框架中,文件public/index.html和config/router.rb存在着一定的联系,理解这种关系是本讲座想说明的。
    2. 本讲座的完整代码请您在Google Code Hosting上查看:
      http://cnruby.googlecode.com/svn/trunk/rails-projects/router_index
      或者下载
      svn co http://cnruby.googlecode.com/svn/trunk/rails-projects/router_index

     (四)解决方案:

    1. 打开Windows的行命令控制台(开始 -> 运行... -> 输入cmd -> 确认),创建一个名称为 router_index 项目,其命令如下:
      rails router_index
      cd router_index
      图01

      图02
    2. 创建一个控制器Admin,和相应的页面,目的是把它作为我们的网站入口页面:
      ruby script/generate controller admin index
      图03
    3. 修改管理控制类路径的文件routes.rb,在Rails框架中这是一个重要的配置文件:
      vi  config/routes.rb
      图04
    4. 打开浏览器,在浏览器的地址栏中输入下面网址,请注意看图:
      ruby script\server
      图05
    5. 打开浏览器,在浏览器的地址栏中输入下面网址,看到的并不是我们想要的内容:
      http://localhost:3000/
      图06
    6. 打开另一个控制台,删除在目录public中的文件index.html:
      rm public/index.html
      图07
    7. 进入浏览器,点击F5按钮,这是我们想要看的图:
      F5
      图08

     (五)视听教学:



     (六)必须注意的问题:



     (七)参考资料:



     (八)命令清单:

    [open dos shell]
    rails router_index
    cd router_index
    ruby script/generate controller admin index
    vi  config/routes.rb
    ruby script\server
    [open browser]
    http://localhost:3000/
    [open new dos shell]
    cd d:\works_rails\router_index
    d:
    rm public/index.html
    [once again enter browser]
    F5

  • 相关阅读:
    求数组元素出现的次数
    数组的一些内置方法
    二维数组
    创建对象
    取出数组最大值与最小值
    4-jQuery
    3-jQuery
    2-jQuery
    1-jQuery
    Spark共享变量(广播变量、累加器)
  • 原文地址:https://www.cnblogs.com/chinatefl/p/565115.html
Copyright © 2011-2022 走看看