淘小店

ruby on rails 自学笔记 (1)入门篇

最近想学习一下rails,rails是一个采用ruby语言编写的mvc框架的web框架,rails的好处就不说了,在这主要记录一下自己在学习的时候遇到的问题,首先介绍一下rails的开发环境,今天在win7下面安装了一下非常简单,下载地址,下载railsinstaller,安装就可以了,里面已经包括ruby,安装完成之后,会进去rails的命令窗口,

开始会让输入基本的一些配置信息,参照书上写的创建自己的第一个站点,进入自己想要创建站点的目录,然后输入命令:rails new  应用名称(不同版本命令可能有所不同,我的版本是ruby1.8.7,rails 3.0.6),创建成功之后进入该目录会发现创建了好多文件夹和文件  ,接下来启动站点,测试一下,输入命令:ruby script\rails server,启动服务,其实就是进入刚才创建的站点目录下的script文件夹中,执行rails文件,ruby script\rails,这是一个命令,执行rails脚本,后面的server是参数,说明启动的是rails的服务,

c:\Users\xxxxtest
c:\Users\xxxxt>cd myruby
c:\Users\xxxxt\myruby>ruby script\rails
Usage: rails COMMAND [ARGS]
The most common rails commands are:
 generate    Generate new code (short-cut alias: "g")
 console     Start the Rails console (short-cut alias: "c")
 server      Start the Rails server (short-cut alias: "s")
 dbconsole   Start a console for the database specified in config/database.yml
             (short-cut alias: "db")
 new         Create a new Rails application. "rails new my_app" creates a
             new application called MyApp in "./my_app"
In addition to those, there are:
 application  Generate the Rails application code
 destroy      Undo code generated with "generate"
 benchmarker  See how fast a piece of code runs
 profiler     Get profile information from a piece of code
 plugin       Install a plugin
 runner       Run a piece of code in the application environment
All commands can be run with -h for more information.
c:\Users\dulizhao\rubytest\myruby>ruby script\rails server
=> Booting WEBrick
=> Rails 3.0.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-05-25 22:01:19] INFO  WEBrick 1.3.1
[2011-05-25 22:01:19] INFO  ruby 1.8.7 (2011-02-18) [i386-mingw32]
[2011-05-25 22:01:19] INFO  WEBrick::HTTPServer#start: pid=3540 port=3000

 可以看到启动的进程id3540,端口3000,在浏览器输入地址,出现以下内容说明创建成功了

Getting started

Here’s how to get rolling:

  1. Use rails generate to create your models and controllers

    To see all available options, run it without parameters.

  2. Set up a default route and remove or rename this file

    Routes are set up in config/routes.rb.

  3. Create your database

    Run rake db:migrate to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.



posted on 2011-05-25 22:14  adu123  阅读(490)  评论(0编辑  收藏  举报

导航

淘小店