Ruby on Rails experience (1)-Installation

Source: Internet
Author: User
Tags ruby on rails

I was eager to learn something new. I heard that ROR is very efficient in development, so I chose Ruby on Rails. It was really difficult to install it, here I will write down my installation experience:

1) install Ruby

    Download installation package: http://rubyforge.org/frs? Group_id1_167,what I download is rubyinstaller-1.8.7-p302.exe

    After installation, you can use ruby-V to test whether the installation is successful. If a version is installed, the installation is successful.

2) install rubygems

Rubygems is the ruby package manager tool, which makes Ruby package installation very simple. You only need one command to download the corresponding package from the remote server. If the corresponding application contains other extensions, rubygems will also prompt you to remotely install the dependent extension. After the installation, rubygems runs the corresponding program to generate the rdoc help document (similar to javadoc ). It has become Ruby's de facto Package Manager standard.

: Http://rubyforge.org/projects/rubygems,

I downloaded the rubygems-1.3.7, decompress and execute setup. Rb in the directory. After the installation is complete, run the following command to check:

Gem-V

3. Install rails

A) Remote Installation: Gem install rails-remote

The following is a description from the Internet that I didn't use this method for installation, because my network speed is too slow.

Then the output is automatically:
Install required dependency activerecord?
Install required dependency actionpack?
Install required dependency actionmailer?
Install required dependency activeresource?
Yes depends on the file in sequence, and then displays:
Successfully installed rails-2.1.0
Successfully installed activerecord-2.1.0
Successfully installed actionpack-2.1.0
Successfully installed actionmailer-2.1.0
Successfully installed activeresource-2.1.0
Installing Ri documentation for activerecord-2.1.0...
Installing Ri documentation for actionpack-2.1.0...
Installing Ri documentation for actionmailer-2.1.0...
Installing Ri documentation for activeresource-2.1.0...
Installing rdoc documentation for activerecord-2.1.0...
Installing rdoc documentation for actionpack-2.1.0...
Installing rdoc documentation for actionmailer-2.1.0...
Installing rdoc documentation for activeresource-2.1.0...
Look at the version: rails-V
Output: rails 2.1.0
Done

B) Local manual installation:

Download required

Activesupport

"Href =" http://files.rubyforge.vm.bytemark.co.uk/activesupport/activesupport-2.2.3.gem "> http://files.rubyforge.vm.bytemark.co.uk/activesupport/activesupport-2.2.3.gem

Activerecord

"Href =" http://files.rubyforge.vm.bytemark.co.uk/activerecord/activerecord-2.2.3.gem%20 "> http://files.rubyforge.vm.bytemark.co.uk/activerecord/activerecord-2.2.3.gem

Actionpack

"Href =" http://files.rubyforge.vm.bytemark.co.uk/actionpack/actionpack-2.2.3.gem "> http://files.rubyforge.vm.bytemark.co.uk/actionpack/actionpack-2.2.3.gem

Actionmailer

Http://rubyforge.org/frs/download.php/64424/actionmailer-2.2.3.gem

Rake
"Href =" http://files.rubyforge.vm.bytemark.co.uk/rake/rake-0.8.7.gem%20 "> http://files.rubyforge.vm.bytemark.co.uk/rake/rake-0.8.7.gem

Activeresource

Http://rubyforge.org/frs/download.php/64419/activeresource-2.2.3.gem

Rails http://rubyforge.org/frs/download.php/64426/rails-2.2.3.gem

After the download is complete, place all the files in the same folder and install them in sequence: (eg: D: \ Ruby)

Then execute the command

(D: --> D: \> Cd D: \ Ruby)

Gem install activesupport

Gem install activerecord

Gem install actionpack

Gem install actionmailer

Gem install rake

Gem install rails

Check the command after successful installation

Rails-V

Verify installation successful

4. Create a web application

Enter rails helloworld in the command line. For example, if the current path is E: \ Ruby on Rails> rails helloworld, A helloworld folder is created under E: \ Ruby on Rails.

If you need to specify the path can rails C: // test, specific can see the official API: http://api.rubyonrails.org/

5. Run the ruby script \ server startup service under the current directory (helloworld), more information about webrick server can access http://www.webrick.org/

6. Enter http: // localhost: 3000/in the browser. If the following page is displayed, it indicates OK.

7. Write a helloworld web program, Ruby script \ generate controller helloworld command

Find hello_world_controller.rb

  •  
    1. ClassHelloworldcontroller <applicationcontroller
    2. DefIndex
    3. Render: text => "Hello World"
    4. End
    5. End
  • Enter the following code to save

  • If the service is not started, restart Step 5.

Open http: // localhost: 3000/hello_world in the browser and you will see the result. However, I have an error:

    You can see a solution on the Internet:

    This is because sqlite3 database is not installed, http://files.cnblogs.com/geek007/sqlite3.rar download here,

    Then decompress the package to the bin directory of Ruby: D: \ Ruby \ bin, execute the command: Gem install "D: \ Program Files \ ruby187 \ bin \ sqlite3-ruby-1.2.3-mswin32.gem"

After the installation is successful, follow the step 5 to restart the server and access

Http: // localhost: 3000/hello_world

OK, success ~ Haha, happy ~~~

 

PS: manual installation is very troublesome, you can download instantrails from the http://instantrails.rubyforge.org/, all done.

Reference resources:

Http://rubyforge.org

Http://api.rubyonrails.org/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.