« Interviewing, Part 1 | Home | Set up a Fedora development box »

Ruby on Rails, Cygwin, and Git part 1

By Jacob Cohen | May 9, 2008

This is the first of what will probably become a series on using Ruby on Rails under Cygwin, with source control managed by Git. This might raise a couple of questions, which I will attempt to answer here.

As for getting it all running, I’ve covered that in a previous post.

For now, I’ll just cover the basics of getting a Rails project started under Cygwin, using Git for source control.

First, I’ll create the directory which will hold the rails application, git repository, and everything else I’m working on. Then, I’ll initialize a git repository, and see that everything is working.

cohen@ceres ~
$ mkdir paste

cohen@ceres ~
$ cd paste

cohen@ceres ~/paste
$ git init
Initialized empty Git repository in .git/

cohen@ceres ~/paste
$ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)

As you may have guessed, I’m going to be using my Nopaste application as a project, rewritten using Ruby on Rails. Next, I’ll run rails to initialize my project and check what Git thinks has changed. (Note: I originally had an issue under Cygwin where rails couldn’t read from /dev/urandom, but I was able to get around it by removing the :urandom entry from the GENERATORS line in the random generator file. Running rails -t will print a backtrace on errors so it’s easy to find the right files to tinker with.)

cohen@ceres ~/paste
$ rails .
      exists
      create  app/controllers
      create  app/helpers
      create  app/models
  ... snip ...
      create  log/production.log
      create  log/development.log
      create  log/test.log

cohen@ceres ~/paste
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add …” to include in what will be committed)
#
#       README
#       Rakefile
#       app/
#       config/
#       doc/
#       log/
#       public/
#       script/
#       test/
nothing added to commit but untracked files present (use “git add” to track)

Git is saying it has noticed a bunch of new stuff that it currently isn’t tracking. We need to get this stuff into our Git repository. I’ll do that, then commit it all onto the master branch.

cohen@ceres ~/paste
$ git add *

cohen@ceres ~/paste
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached …” to unstage)
#
#       new file: README
#       new file: Rakefile
#       new file: app/controllers/application.rb
#       new file: app/helpers/application_helper.rb
    … snip …
#       new file: script/runner
#       new file: script/server
#       new file: test/test_helper.rb
#

cohen@ceres ~/paste
$ git commit -m “Generated an initial Rails project”
Created initial commit cf547ba: Generated an initial Rails project
 43 files changed, 8339 insertions(+), 0 deletions(-)
 create mode 100644 README
 create mode 100644 Rakefile
 create mode 100644 app/controllers/application.rb
 create mode 100644 app/helpers/application_helper.rb
    … snip …
 create mode 100755 script/runner
 create mode 100755 script/server
 create mode 100644 test/test_helper.rb

Now I can test my new rails project and see what I get.

cohen@ceres ~/paste
$ ruby script/server
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2008-05-09 00:56:59] INFO  WEBrick 1.3.1
[2008-05-09 00:56:59] INFO  ruby 1.8.6 (2007-03-13) [i386-cygwin]
[2008-05-09 00:56:59] INFO  WEBrick::HTTPServer#start: pid=3012 port=3000
127.0.0.1 - - [09/May/2008:00:57:01 GMT-8:00] "GET / HTTP/1.1" 200 7557
- -> /
127.0.0.1 - - [09/May/2008:00:57:01 GMT-8:00] "GET /javascripts/prototype.js HTTP/1.1" 200 125605
http://localhost:3000/ -> /javascripts/prototype.js
127.0.0.1 - - [09/May/2008:00:57:01 GMT-8:00] "GET /javascripts/effects.js HTTP/1.1" 200 38916
http://localhost:3000/ -> /javascripts/effects.js
127.0.0.1 - - [09/May/2008:00:57:01 GMT-8:00] "GET /images/rails.png HTTP/1.1" 200 1787
http://localhost:3000/ -> /images/rails.png

Next, I’ll start using branches to make some modifications, such as creating my database configuration.

Topics: General |

2 Responses to “Ruby on Rails, Cygwin, and Git part 1”

  1. Windows » Ruby on Rails, Cygwin, and Git part 1 Says:
    May 9th, 2008 at 2:03 am

    […] Rafblog wrote an interesting post today on Ruby on Rails, Cygwin, and Git part 1Here’s a quick excerptMy home machine runs Windows XP, but I can’t imagine starting any development without having access to find, grep, the bourne shell, and all of the other utilities I… […]

  2. Mike Boone Says:
    June 3rd, 2008 at 3:17 pm

    I’m another Rails/Cygwin guy. That /dev/urandom problem was a bug in Ruby. There’s a newer version of Ruby in Cygwin’s repo that should not have that problem.

    Now if only Ruby would run faster on Cygwin…it’s pretty slow, but still usable.

    BTW if you like Cygwin for grepping, give ‘ack’ a try: http://petdance.com/ack/

Comments

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word