Tutorial Requirements
The following techniques and resources are required to learn this tutorial:
Database server
NetBeans IDE 6.0 with Ruby support
To create a sample database
This tutorial builds the relationship between the Rails model based on another tutorial. If you have completed that tutorial, you can start with the project that was generated when you completed the tutorial and go directly to the next section. Otherwise, you can download the Rubyweblogmodel.zip file first, and then follow the steps below to create the sample database.
Note: This tutorial uses the MySQL database server. You can refer to the install and configure Ruby Support article for information on how to use the MySQL database server in a Ruby application. The document also describes how to use the JAVADB database server as an alternative.
Open a command line window.
If your MySQL database server has not been started, start it first.
Type the following command to create the development database and press the "Enter" key.mysqladmin -u root -p create rubyweblog_development
Note: If the root user does not require a password, omit the-p argument.
Open the Rubyweblog project in the IDE.
Note: If you are opening or creating a Ruby project for the first time, the IDE checks to see if you have a Ruby installation other than the bound JRuby software. If so, the IDE displays a dialog box asking you which software you choose to use. If you want to use a bound JRuby interpreter, choose JRuby, or if you prefer to use your own Ruby installation, choose your own installation. For more information, refer to the configuration IDE in the installation and configuration Ruby Tutorial, using your own Ruby installation section.
If your database requires a password, please edit the database.yml file and provide the password in the Development configuration section. Save the file.
To quickly access the Database.yml file, press Alt+shift+o (press Ctrl+shift+o on the MAC system), type Database.yml in the File name text box, and then press Enter.
Right-click the Rubyweblog node and choose Migrate Database > to current version.
The operation updates the database to include the posts table and the comments table. When the migration completes, it is displayed in the Output window.
Run the application and publish a new article.
Click "Permalink" and add a comment to the article.
You can see that when you add a comment, the entire page is reloaded.