Angel \”Java\” Lopez on Blog

February 7, 2012

Ruby on Rails, Demo Application (1) Creating the Application

Filed under: Ruby, Ruby on Rails, Web Development — ajlopez @ 11:25 am

I wrote a post series about my experience at the past Ruby Fun Day at Buenos Aires, in Spanish:

Mi Día en el Ruby Fun Day with @bendycode

Now, I want to write my learning steps following the chapter 2 of Michael Hartl book Ruby on Rails 3 Tutorial: Learn from Example.

I installed Ruby on my Windows box, using http://rubyinstaller.org/ (more options at http://www.ruby-lang.org/en/downloads/). In Windows, you should install DevKit (a minimalist GNU for windows (mingw)). See Ruby Installer page for link download. The instructions to install it are at http://github.com/oneclick/rubyinstaller/wiki/Development-Kit. (some details in Spanish).

Then, I executed the command (at any command prompt)

gem install rails

that installs Ruby on Rails, a web framework for Ruby. Go to a working directory (in my case c:\Git), and execute

rails

Output:

Then I executed

rails new RailsDemoApp

with output:

Change to the new directory:

cd RailsDemoApp

Now, you have a folder tree like:

Ruby manages gems (package to install and use). Rails itself is a gem. And Rails application have a GemFile that list the gems our new application will use. Just in case we have a new gem to install, execute:

bundle install

Bundle is the new package installer used in Ruby on Rails 3. It reads the GemFile and installs (in Ruby gem directory, in our machine, it’s not per application) the needed gems. Then, you can execute:

bundle show

I configured the current directory (Git\RailsDemoApp) to be a Git repo:

git init
git add .
git commit –m “Initial Commit”

I added a new repository in my GitHub Account using https://github.com/repositories/new:

The new repo: https://github.com/ajlopez/RailsDemoApp

I added and pushed to the remote repo:

git remote add origin git@github.com:ajlopez/RailsDemoApp.git
git push origin master

You can launch the initial server with

rails server

or its shortcut

rails s

See the result at http://localhost:3000

Next steps: adding a simple model (users, micropost), database, views, controllers, scaffolding, and Heroku deploy. Scaffolding (quick CRUD code generation) will be the approach to use in this series, but in a following post series I want to show (and learn ;-) the making of a Rails application, step by step, as in Hartl book.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 56 other followers

%d bloggers like this: