How to Create a Rails 4+ Application
In this first lesson, we are going to run the Rails application generator and test to verify that everything works fine. To create the application, open your command prompt and go to the directory in which you want to create the application. Next, type this command to create your application.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
  • Complete the Exercise
Video locked
This video is viewable to users with a Bottega Bootcamp license

In this first lesson, we are going to run the Rails application generator and test to verify that everything works fine. To create the application, open your command prompt and go to the directory in which you want to create the application. Next, type this command to create your application.

rails new photoflash --database=postgresql

In this command, photoflash is the name of the application and the database that we are going to be using is postgresql. If we don't set the database, the application would still work fine, but it won't use postgresql as the database. Instead, it will use the default sqlite database. In Rails, it's common for production applications to use PostgreSQL, so if we use this command, the application will use postgresql in the local machine too. When you use the same database in both the local and production machines, it just makes life easy because the last thing you want is your application to throw database errors that you don't run into locally.

large

This command will create all the files for us. This may take a little bit of time, depending on the speed of your machine. If you look through the files, you'll see that it created our models, views and controller files. Also, it setup some automated tests for us to use.

medium

To check if everything is fine, let's get into our application folder, and to do that, type the command:

cd photoflash

Inside this directory, we have to now create our database, and the command for this is:

rake db:create

Lastly, run the rails server with the command:

rails s

To check if this worked, let's open a browser window and navigate to locahost:3000

large

And everything looks great!