Ruby on Rails development from scratch (Windows) (32)-Rails configuration file

Source: Internet
Author: User
Tags config ruby on rails

The Run-time configuration of rails is controlled by the files in the Config directory.

1. Runtime Environment (Runtime environment)

When developers write code, the requirements are many and varied. In development you may need a lot of logins to load the changed code. When testing, you need to separate the systems from each other. Before publishing, you may need to optimize performance and keep users away from bugs.

To support all this, rials has the concept of runtime configuration. Each environment has its own set of configurations that can run the same application in different environments.

Switching to a running environment allows us to switch from development to testing and to publishing without modifying the code. How do I specify a running environment? It depends on how you run your program, if you use the Script/server and use the-e parameter:

Depot > Ruby script/server–e Development |test| Production

If you use Apche or LIGHTTPD, you should set the RAILS_ENV environment variable, which we'll introduce later.

If you have special needs, you can create your own environment (environment), you need to add your own configuration section to the database configuration, and add a profile to the Config/environment folder.

2. Configure Database Links

File config/database.yml is used to configure the database link, and you will find that it includes three configuration sections, each of which starts with the environment name followed by a colon. The following line must be indented, with the key and corresponding value in the content, separated by a colon. At a minimum, each configuration section must specify a database adapter (DB adapter) and the database used, such as mysql,postgres, and so on. The database adapter has its own specific configuration, and the complete list will be listed later. The following is the database.yml file for our current depot program:

Development:
adapter:mysql
database:depot_development
Username: password
:
host:localhost
# warning:the database defined as ' test ' would be erased and
# re-generated from your development database when Y ou run ' rake '. # don't set this db to the same as development or production.test:
adapter:mysql
Database:depot _test
Username:
Password:
host:localhost
production:
adapter:mysql
Database: Depot_production
username:root
password:prod
host:wibble

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.