Week 1: Your First Rails Application · Lesson 1 ·
I'm going to show you how to create a new Ruby on Rails application
In your command line, type:
$ cd ~/Desktop # Makes sure you're on your desktop to begin with $ pwd # Just to make sure /Users/mattangriffel/Desktop $ rails new omruby ... # A new Rails app is created
A typical Ruby on Rails app is structured like this:
app/ Where most of your code will go
bin/ Where special Rails commands go. Don't worry about this.
config/ This is where configuration and customization files go.
config.ru Another configuration file.
db/ Where your database lives.
Gemfile Where other people's libraries of code gets installed from.
Gemfile.lock Generated automatically from the Gemfile.
lib/ Here's where you can store code you want to share between applications.
log/ Where log files go.
public/ Where public files and images go.
Rakefile Special tasks you can create for your Rails application.
README.md Later we'll put text here that tells people about this app.
test/ Where automated tests go.
tmp/ Stores temporary files.
vendor/ Where other people's files goes that you've downloaded.
In your command line type:
$ cd omruby # Make sure you're in the newly created folder $ rails server => Booting Puma => Rails 184.108.40.206 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options Puma starting in single mode... ... Use Ctrl-C to stop
Then visit http://localhost:3000 in your browser.
Yay! You ran your first Rails app.
You get a "This site can’t be reached" error. Did your Rails server start properly? Check your command line to see if you got a warning message.
The command `rails server` doesn't work. Are you sure you used `cd` to change directory into your new folder? You can only run the rails server from inside your Rails application folder.