Ruby 一步步安装

http://www.gayathri-frenzy.com/technology/ruby-on-rails

I kept thinking for a while on what do I have next in the store :-)
Here we go “Ruby on Rails

Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby Programming language.Ruby is a pure object-oriented programming language with a super-clean syntax that makes programming elegant and fun.

What is Rails?

Rails is an open source Ruby framework for developing web-based, databasedriven applications. Dozens of frameworks are out and most of them have been around much longer than Rails. Why do we then have a different framework?

Rails help us in developing a web application at least ten times faster than we can with a typical Java framework. We can–without making any sacrifices in the quality of our application!

When I got started with this topic, I just lacked a proper installation guide to help me with the installation. So I’m trying to make my reader’s life easier.

Ruby on Rails Installation:

To develop a web application using Ruby on Rails Framework, install the following software:
·
Ruby
· The Rails framework
· A Web Server
· A Database System

We can use the WEBrick Web Server which comes with Ruby.Rails works with many database systems, including MySQL, PostgreSQL, SQLite, Oracle, DB2 and SQL Server.

Rails Installation on Windows:

1. Install Ruby
Download an installation package from rubyinstaller.rubyforge.org.
Follow the download link, and run the resulting installer. We will get RubyGems along with this package.

2. With Ruby Gems loaded, we can install Rails and its dependencies through the command line.
C:/> gem install rails –include-dependencies
We would get the following error:
C:/Ruby>gem install rails –include-dependencies
INFO: `gem install -y` is now default and will be removed
INFO: use –ignore-dependencies to install only the gems you list
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
ERROR: could not find gem rails locally or in a repository
As connecting to the repository gives us a problem here, let us download the required gems locally and do
the installation step by step.

下载rails.xx.zip rails.xx.gem 放到待安装的目录中:(注意zip文件不需要解压)

然后 gem install rails --local 出出现提示。 需要什么 gem 文件。 然后 一步步的安装

a. Firstly, download Rails gem from the below link. http://rubyforge.org/frs/?group_id=307
Execute the following command to install rails.
C:/Ruby>gem install rails-2.3.2.gem
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
ERROR: Error installing rails-2.3.2.gem:rails requires rake (>= 0.8.3, runtime) This says us that we require rake-0.8.3 gem.

b. Download rake gem from the below link.
http://rubyforge.org/frs/?group_id=50
Execute the following command to install rake.
C:/Ruby>gem install rake-0.8.3.gem
Successfully installed rake-0.8.3
1 gem installed
Installing ri documentation for rake-0.8.3…
Installing RDoc documentation for rake-0.8.3…
Rake gem got successfully installed.
Execute the command to install rails again.
C:/Ruby>gem install rails-2.3.2.gem
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
ERROR: Error installing rails-2.3.2.gem:
rails requires activesupport (= 2.3.2, runtime)
This says us that we require activesupport-2.3.2 gem.

c. Download activesupport gem from the below link.
http://rubyforge.org/frs/?group_id=570&release_id=32254
Execute the following command to install activesupport.
C:/Ruby>gem install activesupport-2.3.2.gem
Successfully installed activesupport-2.3.2
1 gem installed
Installing ri documentation for activesupport-2.3.2…
Installing RDoc documentation for activesupport-2.3.2…
activesupport gem got successfully installed.
Execute the command to install rails again.
C:/Ruby>gem install rails-2.3.2.gem
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
ERROR: Error installing rails-2.3.2.gem:
rails requires activerecord (= 2.3.2, runtime)
This says us that we require activerecord-2.3.2 gem.

d. Download activerecord gem from the below link.
http://rubyforge.org/frs/?group_id=182
Execute the following command to install activerecord.
C:/Ruby>gem install activerecord-2.3.2.gem
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
Successfully installed activerecord-2.3.2
1 gem installed
Installing ri documentation for activerecord-2.3.2…
Installing RDoc documentation for activerecord-2.3.2…
activerecord gem got successfully installed.
Execute the command to install rails again.
C:/Ruby>gem install rails-2.3.2.gem
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
ERROR: Error installing rails-2.3.2.gem:
rails requires actionpack (= 2.3.2, runtime)
This says us that we require actionpack-2.3.2 gem.

e. Download actionpack gem from the below link.
http://rubyforge.org/frs/?group_id=249
Execute the following command to install actionpack.
C:/Ruby>gem install actionpack-2.3.2.gem
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
Successfully installed actionpack-2.3.2
1 gem installed
Installing ri documentation for actionpack-2.3.2…
Installing RDoc documentation for actionpack-2.3.2…
actionpack gem got successfully installed.
Execute the command to install rails again.
C:/Ruby>gem install rails-2.3.2.gem
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
ERROR: Error installing rails-2.3.2.gem:
rails requires actionmailer (= 2.3.2, runtime)
This says us that we require actionmailer-2.3.2 gem.

f. Download actionmailer gem from the below link.
http://rubyforge.org/frs/download.php/53265/actionmailer-2.3.2.gem
Execute the following command to install actionmailer.
C:/Ruby>gem install actionmailer-2.3.2.gem
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
Successfully installed actionmailer-2.3.2
1 gem installed
Installing ri documentation for actionmailer-2.3.2…
Installing RDoc documentation for actionmailer-2.3.2…
actionmailer gem got successfully installed.
Execute the command to install rails again.
C:/Ruby>gem install rails-2.3.2.gem
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
ERROR: Error installing rails-2.3.2.gem:
rails requires activeresource (= 2.3.2, runtime)
This says us that we require activeresource-2.3.2 gem.

g. Download activeresource gem from the below link.
http://rubyforge.org/frs/?group_id=3507&release_id=22583
Execute the following command to install activeresource.
C:/Ruby>gem install activeresource-2.3.2.gem
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
Successfully installed activeresource-2.3.2
1 gem installed
Installing ri documentation for activeresource-2.3.2…
Installing RDoc documentation for activeresource-2.3.2…
Execute the command to install rails again.
C:/Ruby>gem install rails-2.3.2.gem
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
Successfully installed rails-2.3.2
1 gem installed
Finally, Rails got successfully installed!!

Installation Verification

We can verify whether everything is setup properly or not.
Use the following command to create a demo project.
This will generate a demo rail project.

C:/Ruby>rails demo
create
create app/controllers
create app/helpers
…………………………………………..
…………………………………………..
create log/development.log
create log/test.log

Now next use the following command to run WEBrick web server on your machine.
C:/Ruby>cd demo
C:/Ruby/demo>ruby script/server
=> Booting WEBrick
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2009-04-30 11:02:21] INFO WEBrick 1.3.1
[2009-04-30 11:02:21] INFO ruby 1.8.6 (2008-08-11) [i386-mswin32]
[2009-04-30 11:02:21] INFO WEBrick::HTTPServer#start: pid=3624 port=3000
Now open your browser and type the following address.
http://localhost:3000
If everything is fine then you should have a message something like “Welcome aboard” or “Congratulations“.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值