Run Ruby on Rails in the wndow Environment

Source: Internet
Author: User
Tags ruby on rails

Mongrel is a ruby HTTP library used to deliver Ruby web applications. In fact, do not use Apache mongrel alone can run the ROR program, the online tutorial using Apache is used to do web proxy, so that the website will not have a http://www.unbe.cn: 8081/such port declaration. I just did the test. Multiple port numbers won't affect me, so I only configured mongrel.

The configuration steps are as follows:
1. Download and install Ruby
2. Install gem (Ruby installed in Windows installation package comes with Gem)
2.1 Download gem from rubyforge
2.2 decompress the gem file and run Setup: Ruby setup. RB On the command line.
3. Install rails
3.1 enter gem install rails-include-dependencies in the command line
Note: Make sure your computer has a network connection. This installation process will last for a period of time, depending on the network speed.
4. Install mongrel
4.1 enter the following command line: Gem install mongrel-y
In the middle of 4.2, you will be prompted about the version to be installed. I have installed the latest Win32 version. I have not tried other versions.
5. Install mongrel Service
5.1 run the following command line: Gem install mongrel_service-y.
In the middle of 5.2, you will be prompted about the version to be installed. I have installed the latest Win32 version. I have not tried other versions.
6. Create a rails Program
6.1 enter "Rails D:" railsdemo "in the command line to automatically create the required file in the target directory.
6.2 run mongrel_rails service: Install-N railsdemo-c d: "railsdemo-P 8082-e Production
The-e parameter can also be development, the-p parameter is the service port number, and the-n parameter is the service name.
6.3 now there will be one more railsdemo service in the Windows Service list, start it
6.4 go to the browser to test the site http: // localhost: 8082/. If the homepage is not complete, click "about your application's environment" to check whether the page is properly displayed.

 

 

5. Delete and stop services

Mongrel_rails service: Stop-n ent

To log out of the service:

Mongrel_rails service: Remove-N ent

To Install Multiple mongrel instances, you can:

Mongrel_rails service: Install-N ent0-c d: "Ruby" mywork "Ent-P 3000-e Production

Mongrel_rails service: Install-N ent1-c d: "Ruby" mywork "Ent-P 3001-e Production

 

 

 

Here I will talk about my experience. If you install Ruby into a directory containing spaces like me (for example, C: "Program Files" Ruby ), you may encounter some problems when trying to install rubygems or using it to install some things, as the installation process seems to be successful, and the corresponding commands (such as gem, rails, rake) still unavailable. If you try to call it, the error "incorrect file name, directory name, or volume label Syntax" will be reported ". This is because the source file content of these commands is incorrect and the solution is simple. Find the source files of these commands in the ruby/bin directory (such as gem. bat, rails. bat, rake. BAT), replace "@" ruby.exe "" % ~ Change dpn0 "% *" to "@" ruby.exe "" % ~ Dpn0 "%.

(Remove "Middle)

 

 

Zookeeper -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

In Windows XPInstall Ruby on Rails onSqlite3-rubyProblem Solving

1. If sqlite3is already installed, you can jump to step 3, and then download the sqlite3.exe and sqlite3.dl files to the bin directory under the ruby installation directory. For example, my directory is D: "Ruby" bin"

2. Run the following command:

Gem install sqlite3-ruby

Install the sqlite3 Ruby driver.

3. Now you can develop ror. For example, to implement mybook, first execute

Rails mybook-D MySQL

The reason for adding "-D MySQL" is to change the database to MySQL (sqlite3 by default), and then modify the database. yml in/mybook/config/. For example, my modifications are as follows:

Development:

Adapter: MySQL

Encoding: utf8

Database: mybook_development

Username: Root

Password: Root

HOST: localhost

 

Test:

Adapter: MySQL

Encoding: utf8

Database: mybook_test

Username: Root

Password: Root

HOST: localhost

 

Production:

Adapter: MySQL

Encoding: utf8

Database: mybook_production

Username: Root

Password: Root

HOST: localhost

4. Create a database and execute

Rake DB: Create: All

 

 

 

Zookeeper -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

5Three steps in one minute to make your first railsProject

 

First download the one-click installation package InstantRails-2.0-win
Address: http://files.rubyforge.mmmultiworks.com/instantrails/InstantRails-2.0-win.zip
Ruby rails MySQL has an editor. You can go to the ruby "scitedirectory to find scite.exe. The highlighted syntax is very useful!

D: "InstantRails-2.0-win" Ruby "myproject my learning directory
1. Generate a project
Add environment variables in the command line
Rails chapter-1
Generate project chapter-1,
CD chapter-1 is in the project directory:
Ruby script/Server
Start the ruby built-in server webrick Server
The browser points to http: // localhost: 3000/. The welcome screen is displayed.

2. Create a controller to display your words
Ruby script/generate controller greeting Index
The browser locates http: // localhost: 3000/greeting/index and finds that Ruby prompts you where the index is located. Greeting indicates the Controller index. The default action is index. You can enter http: // localhost: 3000/greeting/without writing it.
Use controller to display your words
Define the action in greeting_controller.rb of APP "Controllers
Def Index
Render: text => "End
Refresh the browser and you will have your words.
3. Bind the Controller to the view and modify the index method in the controller.
Def Index
@ Welcome_message = "Welcome to your first rails"
End

Input in APP "views" greeting index.html. ERB
<H1> <% = @ welcome_message %> Then go
Http: // localhost: 3000/greeting/Index

 

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.