Create a Ruby Blog program in 10 minutes using NetBeans 6.0

Source: Internet
Author: User
Tags mysql database ruby on rails netbeans

Tutorial Requirements

This tutorial requires the following technologies and resources:

A database server

NetBeans IDE 6.0 that supports Ruby

To create a sample database

Note: This tutorial uses the MySQL database server. For information about using a MySQL database server in a Ruby application, see Installing and configuring Ruby support. This document also includes tips on how to use the Java DB database server.

Before you create a Ruby on Rails project, you first need to create a rubyweblog_development database. The steps are as follows:

Opens a command window.

Start the MySQL database server if it has not started.

Enter the following command to create the Rubyweblog_development database, and then click Enter. mysqladmin -u root -p create rubyweblog_developmentNote: If the root user does not set a password, the-p argument is omitted.

Create Ruby on Rails project

First, create a Ruby on Rails project. By default, the Ruby on Rails application is created in a directory structure that conforms to the project contract.

In the NetBeans IDE, select File > New Project.

Select Ruby in the Categories column and select Ruby on Rails application in the Projects column. Click the Next button.

Note: When you first create a Ruby project in the IDE, the IDE checks to see if other Ruby software is also installed in the system (in addition to the JRuby software that accompanies the IDE). If it does, the IDE pops up a dialog box asking you which software you choose to use. If you want to use the JRuby interpreter that accompanies the IDE, select JRuby, and instead, select the installed Ruby. For more information, see the Configuring the IDE to use Your Own Ruby installation section in installing and configuring the Ruby Tutorial.

Enter Rubyweblog in the Project Name field. Accept all other default settings.

Click the Finish button, which creates a new project.

The IDE creates a project directory with the same name as your project name. You will see:

The Projects window contains the basic categories of the application. The controllers, Models, and Views nodes require special attention. In this tutorial, we will follow the basic process of creating a model, adding a controller, and building a window.

The Output window lists the file list for the application. You can open the file in the editing area by clicking the link in the Output window.

Configuring the database environment

The next step is to edit the Database.yml file, which is already configured to use the MySQL adapter and the development database. You do not need to make any configuration unless the root user password is set.

Open Configuration > Database.yml

Edit the Database.yml file to add a password in the development configuration.

Save and close the Database.yml file.

Special Note: If localhost is not included in the main file of the operating system, use 127.0.0.1 instead. Also note that in some systems, you should use lowercase letters for database settings.

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.