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 http://rubyonrails.org/download 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 Create New Project dialog box, do the following:
on the main menu. In
- In the left-hand pane, select project type Rails Application
- Specify the project location
- Select Ruby SDK and Rails version
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
In the Add New Controller dialog box, specify the name and optional location of the controller, and add the necessary actions:
So doing, RubyMine runs generate script and creates the stub controller and the corresponding views.Open the controller in the editor, and use the gutter icons to navigate to a view associated with an action. For example, click the gutter icon to the left of the
sayaction to open the corresponding view file:
In the view file, add some meaningful contents.
Observe results in a browser of your choice. To do that, hover your mouse pointer over the view code, and then select the desired browser from the pop-up menu of the supported browsers:
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.
In the Create new project dialog box, you have to select the check box Preconfigure for selected database, and choose the desired database.
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.