Using Ajax in Ruby on Rails

Source: Internet
Author: User
Tags command line mysql mysql database ruby on rails

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.

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.