Ruby on Rails
СамоучительШагПервый

Самоучитель | СамоучительШагВторой? (конфигурируем базу данных) →

In this sample Howto we’ll use a MySQL database.

An SQLite version of Tutorial Step One and a PostgreSQL version of Tutorial Step One are also available.

How about adding information about migrations here?

Инѿтрументы работы ѿ SQL

Графичеѿкие инѿтрументы длѿ работы ѿ базами данных

Вѿе нижеперечиѿленные дейѿтвиѿ вы можете ѿовершать ѿ помощью командной ѿтроки, но еѿть неѿколько инѿтрументов длѿ управлениѿ БД, обладающих графичеѿкими интерфейѿами. Смотрите врезку.

Замечание длѿ пользователей Windows

If you have MySQL 4.1, you will most likely want to change the server’s security properties to allow the old password methods. Edit the my.ini in C:\Program Files\MySQL\MySQL Server 4.1

If this doesn’t work, after changing the my.ini, add a new mysql user, and update database.yml to use the new user and password. (see mysql bug #847)

  1. Use old password encryption method (needed for 4.0 and older clients).
    old_passwords

*Note: It seems like the Windows installation of RoR 1.0 has the reverse problem: it doesn’t support the old-style passwords. So it might be a good idea to skip this tip. *

Создание базы данных

Create a database named “rails_production” and a user that has full access to the database.

Shut down the database server and restart it. You are now ready to proceed.

Create the Table

For the purposes of this tutorial, make the following table and data:

# 
# Database : `rails_production`
# 
# --------------------------------------------------------
#
# Note: <a href="http://wiki.rubyonrails.com/rails/pages/ActiveRecord" class="existingWikiWord">ActiveRecord</a> will correctly map the Person class to 
#       this table. If you're curious about how it's done
#       see the Inflector module (specifically the methods
#       tableize and pluralize)
#
# Table structure for table `people`
#

CREATE TABLE `people` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(50) NOT NULL default '',
  `street1` varchar(70) NOT NULL default '',
  `street2` varchar(70) NOT NULL default '',
  `city` varchar(70) NOT NULL default '',
  `state` char(2) NOT NULL default '',
  `zip` varchar(10) NOT NULL default '',
  PRIMARY KEY  (`id`),
  KEY `name` (`name`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

#
# Dumping data for table `people`
#

INSERT INTO `people` VALUES (1, 'Superman', '123 Somewhere', '', 'Smallville', 'KS', '123456');

<— Tutorial | TutorialStepTwo (Configuring the Database) —>

Note that the name of the database table should be the plural of the name of the model you will be using. In this case `people` is the plural of the model `person` (yes, rails correctly pluralises irregular nouns).

category:Tutorial

<— Tutorial | TutorialStepTwo (Configuring the Database) —>

па других ѿзыках