Create and Run Your First Project
To get more familiar with RubyMine it is recommended that you create from scratch your first project with the very basic functionality.
In this section:
- Creating your first Rails application
- Exploring the project structure
- Running the server
- Populating your application
- Observing results
- Important note on using databases
Creating a living Web application that enables you to view results in a browser of your choice requires the following prerequisite to be fulfilled:
- Ruby SDK is downloaded and installed on your machine. Refer to this page for details.
Creating your first Rails application
The procedure below describes creating a simple project on Windows platform.
To create your first Rails application, follow these steps
- Create a new project. To do that, choose on the main menu. In the Create New Project dialog box, do the following:
RubyMine creates stub Rails application, which is reflected in the Run tool window:
You can see that RubyMine has taken care of the proper application structure:
Exploring the project structure
Running the server
If you want to see how your application works, launch the Web server. To do that, choose the Development run/debug configuration from the Run/Debug Configuration drop-down list, and then click the run button on the main toolbar:
The Console tab of the Run tool window shows the URL where the Rails application starts. Copy this address to the clipboard:
After that, to make sure the settings are correct and the Rails server works properly, preview results in the browser.
Populating your applicationNext, let's populate the Rails application.
- Create a controller. To do that, press
and in the pop-up window start typing the desired generator name. In our case, this is
sayaction to open the corresponding view file:
In the view file, add some meaningful contents.
The result displays in the selected browser:
Important note on using databases
In the real-life applications, using databases is required. In this case it is important that one of the supported database servers should be installed, the daemon should be running and accessible to your machine.
Make sure that the required databases are available. First, launch your preferred database server.
For example, in the Windows environment, you can launch the MySQL daemon from the command line,
Note that if you choose sqlite3, no additional actions are required.
When your Rails application is created, you have to run Rake task db:create:all. Thus, a database required by your Rails application, as it is described in the database.yml file, will be created.
After updating the model structure of your application, run Rake task db:migrate.