最详细的Ruby on Rails安装步骤
本文介绍了Ruby on Rails的详细安装步骤。文中使用的Ruby on Rails版本是1.8.6-26。安装Ruby之后安装Rails,然后就可以创建Web应用,并在本地测试了。
1、安装ruby
不用说 是下载安装包:http://rubyforge.org/frs/?group_id=167,注意版本---害人不浅,后面会说到,我下的是1.8.6-26
装完后,可以用ruby -v 测试是否安装成功,如图,要是出现了版本 就说明安装成功了
2、ruby安装完成后,安装rails
在命令行下运行 gem install rails,会有四五个提示 一路Y,安装完后,依旧可以用rails -v, 来检测rails 是否安装成功
3、创建Web应用
还是命令行下输入 rails testweb,比如当前的路径是 C:\Documents and Settings\Administrator>rails testweb,便会在C:\Documents and Settings\Administrator下创建一个testweb文件夹。
PS:这里是可以加路径的 比如 rails C://test,具体可以看官方API:http://api.rubyonrails.org/
4、在当前目录(testweb)下,运行 ruby script\server 启动服务,关于webrick服务器更多的信息可以访问 http://www.webrick.org/
5、浏览器中输入http://localhost:3000/,如果看到以下页面,说明OK
6、写一个HelloWorld的Web程序,ruby script\generate controller HelloWorld命令
然后找到hello_world_controller.rb
输入以下代码,保存
class HelloWorldController < ApplicationController def index render:text=>"hello world" end end
我曾经用 render_text "Hello RoR World" 试了半天也不管用,搜了半天才发现是版本的问题,经验啊
在浏览器中打开http://localhost:3000/hello_world,就会看见结果
PS:初学的一点点记录,还希望rails高手能指点一二.
1、或许有的朋友跟我一样 看不到hello world,查看日志,出现如下错误
Status: 500 Internal Server Error
no such file to load -- sqlite3
这是由于没有装sqlite3数据库,http://files.cnblogs.com/geek007/sqlite3.rar 这里下载,
然后解压到ruby的bin目录:D:\ruby\bin,命令行执行:gem install "D:\ruby\bin\sqlite3-ruby-1.2.3-mswin32.gem"
相关文档:
SOAP 服务端:
#!/usr/local/bin/ruby
require 'soap/rpc/standaloneServer'
module MySOAP
class Timer
def now
Time.new.strftime("%Y-%m-%d %H:%M:%S")
end
end
class Add
def add(i, j)
return i.to_i + j.to_i
&nb ......
用ruby新建一个excel文件,并且设置一些值。
require 'win32ole'
excel = WIN32OLE.new("excel.application")
excel.Visible = true
excel.WorkBooks.Open("d:\\test.xls")
excel.WorkSheets("sheet1").Activate
excel.Cells(2,3).value = "张三"
exce ......
require 'win32ole'
fns = Dir.glob("*.xls")
application = WIN32OLE.new("excel.application")
application.visible = TRUE
f = File.new('errorCauseEN.xml','w')
f.puts('<?xml version="1.0" encoding="utf-8"?>')
f.puts('<!-- edited with XMLSPY v5 U (http://www.xmlspy.com) by et8 (et8) ......