Setting Up Ruby on Rails Projects with Git and Github

3

Git is the favourite source code management tool of the Ruby on Rails community these days. Though GNU/Linux or Mac platforms are generally preferred to Windows by Ruby on Rails as well as git communities, I will show you how you can work with these technologies on Windows platform. I will also show how to host a git public/share repository of a Rails application on the Github free web service. Note that the following information applies to any project, not just Rails.

  1. Refer to my earlier post to see how to install Ruby on Rails on the Windows platform. You can skip some of the later parts if you wish.

    Setting Up Rails Development Environment on Windows Vista/XP

  2. Git still has some issues on the Windows platform but for normal usage the msysgit package shouldn’t let you down. Download and install it from its Google Code page.

    Download msysgit for Windows

    Read the information in last few dialog boxes carefully during the installation and select the settings you prefer. The following screenshots show the settings I have picked when installing msysgit on my system.

    Install a separate git shell in which to run the git commands:

    Git's independent command shell

    I can go to any git initialized directory, right-click a file and say “Git Bash Here” which will save me a lot of ‘cd’ commands:

    Start Git shell from any Windows directory

    Git’s built-in SSH support is more than enough for development purposes:

    Git's built-in SSH support

    Now you can just go to any Rails directory and run ‘git init’ there to track the files under git.

    Start Git Bash shell from the Start Menu.

    Go to your Rails directory and run the following commands.

    Example session:

    # cd hello
    # ls
    # git init
    # git add .

    For more git commands that you can use, refer to Git Tutorial. To learn more about how Git handles line ending conversions(especially important to Windows users), refer to gitattributes man page.

  3. If you are working alone on a particular application or you are just interested in maintaining the history of the source code changes locally, then you might prefer just working with in the project directory. If I want to share the changes with friends/colleagues or the world at large, we need a public git repository. Github and Assembla are but only two examples that have good free packages to get started with.

    Create a new account on Github.

    • Go to github.com
    • Click the link “Pricing and Signup” at the top of the page.
    • Pick a package(say “Open source” which is free) and click “Signup” button.
    • Fill in the information and click “I agree, sign me up!” button if you agree to all the policies.

    You need to enter your public SSH key when creating a Github account. If you don’t already have SSH keys generated, you can generate one using git tools. Github website has nice explanation on how to go about setting up SSH key on Windows for Github, so just follow the procedure.

    Once you have created the account and are logged in, click the “Create new one” link on the dashboard page, fill in the details and click the “Create Repository” button to create an empty repository on Github.

    Now you can push the contents of your Rails directory to the empty git repository that we created on Github in the previous step by running the following command in Git Bash shell:

    # cd hello
    # git remote add origin g...@github.com:tabrez/hello.git
    # git push origin master

    Adjust the second command according to your account/project details. Now you can say ‘git push’ from your git tracked directory anytime you want to publish your changes to Github, so that others can pull these changes to their computers and merge them with their local git repository.

    Read more about git push.
    Read more about Github.

I will try to write about more tools that help in being more productive with development with Rails in future articles.

Installing Sun Java SE 6, Maven 2 and Tomcat 5.5 on Fedora GNU/Linux

3

For using most of the enterprise technologies based on Java, you generally need at least the following components installed and configured on your system:

  1. Sun Java SE (or EE) SDK
  2. A command line build tool like Ant or Maven
  3. A Java application server/container like Tomcat, Jetty, Glassfish, JBoss etc.

Based on which Java based technology/framework you want to use, you may need to install further dependencies. Even though you may not need all the three components mentioned above to be able to work with all Java technologies, I found myself installing them way too many times when compared to any other Java component that I wanted a place to document the installation process of these three components specifically, if only to refer to this post from other Java tutorials in future.

Installing OpenJDK/Sun Java SE 6, Apache Maven 2 and Tomcat 5 on Fedora GNU/Linux

Installing Java SE 6
You can’t install Sun’s JDK directly from the Fedora repositories, you have the following two choices:

  1. Use OpenJDK that comes installed by default in Fedora 9(if not, you can install it with a simple ‘yum install java-1.6.0-openjdk’ command; or first search for the exact package name using ‘yum search jdk’). If you want to go with Fedora’s OpenJDK then you don’t have to do anything else, except perhaps set JAVA_HOME environment variable to OpenJDK installation path in your profile file.
  2. Install Sun’s latest JDK by manually downloading the binaries from Sun’s website. If you are very specific about using Sun’s official JDK only, then you first have to un-install OpenJDK that is installed by default in Fedora 9. Then you need to download Sun’s JDK and run the installer. (Download the Java EE SDK if you want to install the enterprise edition.) Assuming you have downloaded Sun JDK binary and saved it in your home directory under a name like jdk-6u7-linux-i586.bin, run the following commands to complete the installation:
    # yum remove java-1.6.0-openjdk java-1.6.0-openjdk-plugin
    # yum install compat-libstdc++-33 compat-libstdc++-296
    # cd ~ & chmod +x jdk-6u7-linux-i586.bin
    # ./jdk-6u7-linux-i586.bin
    # javac -version
    javac 1.6.0_07

    As a final step, add the following line to your profile file(e.g. .bash_profile) to set the JAVA_HOME environment variable to the path where you have installed Sun JDK:

    export JAVA_HOME /opt/jre/jdk

    Make JAVA_HOME point to OpenJDK installation path if you are using OpenJDK.

Installing Apache Maven2
Apache Maven 2 can be installed using yum command:

# yum install maven2
# mvn ––version
Maven version 2.0.4
# yum remove maven2

Installing Maven 2 on Fedora 9 using the yum package manager gave me the old 2.0.4 version, so I removed it and decided to install Maven manually. To manually download and extract Maven 2 archive on Fedora 9, follow these instructions:

  1. Download the latest stable version of Apache Maven 2 archive from its download page.
  2. Extract it to your home directory and rename the directory to ‘maven2′
    # tar xjvf apache-maven-2.0.9-bin.tar.bz2
    # mv apache-maven-2.0.9-bin maven2
  3. Add the following line to your profile file(e.g. .bash_profile or /etc/profile) to set maven2 executables in system path:

    export PATH=$PATH:$HOME/maven2/bin

  4. Confirm if Maven 2 is installed and configured correctly:
    # source .bash_profile
    # mvn ––version
    Maven version 2.0.9
    Java version 1.5.0

Installing Tomcat 5 and Jetty
You can finally install tomcat and jetty servers using yum command:

# yum install tomcat5 jetty

The installation procedure on other GNU/Linux distributions should be on similar lines using their respective package managers and I will try to post the procedure for Ubuntu, Gentoo, openSuse and Mandriva distributions in the near future.

Testing the installation

To test the above installation, see my next post(to be published), “Hello, World” Java Web Application using Java SE 6 + Tomcat 5.5 + Maven 2.”

Installing amazon-ecs/hpricot RubyGem on Windows Operating System

1

Installing rubygems that come with native extensions is not same on gnu/linux and Windows platforms as I have discovered recently. Apparently, it is important that the native extensions needed by the rubygem be built with the same compiler tool chain as your main ruby installation. The rubygem I needed to install was amazon-ecs and it depends on another rubygem called hpricot which comes with native extensions. Though hpricot installed fine on gnu/linux OS, I recieved the following errors on Windows:

C:\Users\tabrez> gem install hpricot
Bulk updating Gem source index for: http://gems.rubyforge.org/
Building native extensions. This could take a while…
ERROR: Error installing hpricot:
ERROR: Failed to build gem native extension.

c:/ruby/bin/ruby.exe extconf.rb install hpricot
checking for stdio.h… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Gem files will remain installed in c:/ruby/lib/ruby/gems/1.8/gems/hpricot-0.6.161 for inspection.
Results logged to c:/ruby/lib/ruby/gems/1.8/gems/hpricot-0.6.161/ext/fast_xs/gem_make.out
C:\Users\tabrez>

Help on the IRC channel and some searching on the Internet provided me with the following solution: use whytheluckystiff’s repository as the source to install hpricot rubygem. Once hpricot rubygem was installed, amazon-ecs rubygem installed with no problems.

C:\Users\tabrez> gem install hpricot ––source http://code.whytheluckystiff.net
Successfully installed hpricot-0.6-x86-mswin32
1 gem installed
Installing ri documentation for hpricot-0.6-x86-mswin32…
Installing RDoc documentation for hpricot-0.6-x86-mswin32…

C:\Users\tabrez> gem install amazon-ecs
Successfully installed amazon-ecs-0.5.3
1 gem installed
Installing ri documentation for amazon-ecs-0.5.3…
Installing RDoc documentation for amazon-ecs-0.5.3…
C:\Users\tabrez>

The same source works for sandbox rubygem too.

References:

“Hello, World” Web Application in Ruby on Rails using Aptana Studio

2

I am assuming that you have everything properly setup on your computer for developing applications with the Ruby on Rails framework using Aptana Studio IDE. If not, see my previous posts:

In this post I will take you through a screenshot guided tour of the Aptana Studio (RadRails) IDE and show you how to develop a blank web application using Ruby on Rails framework and add a simple scaffold to it(“Hello, World” equivalent for Rails framework). So let’s get started.

When you run the Aptana Studio application, you will see the splash screen as shown below:
Aptana Studio IDE splash screen.

To create a new Ruby on Rails project, go to File -> New -> Project… and select Rails Project from the “Rails” folder(expand it if necessary). Enter a name for the project(say “Demo1″) and click Finish.
Create a new Ruby on Rails web application project in Aptana Studio IDE

The main window should look like the following screenshot(click to see larger version).
Create a new Ruby on Rails web application project in Aptana Studio IDE

Below you can see the screenshots of various sections of the main window shown above:
Create a new Ruby on Rails web application project in Aptana Studio IDE

The Project pane on the left:
Create a new Ruby on Rails web application project in Aptana Studio IDE

The Console window at the bottom:
Create a new Ruby on Rails web application project in Aptana Studio IDE

The Scripts window at the right(you can access the same from the “Scripts” menu too):
Create a new Ruby on Rails web application project in Aptana Studio IDE

The Cheat Sheets window at the extreme right:
Ruby on Rails cheatsheet in Aptana Studio IDE

If you click the “Click to Begin” link in the cheatsheet window(shown above), you will see the following “Dynamuc Help” window with links to various Rails help topics:
Ruby on Rails help topics in Aptana Studio IDE

Aptana Studio supports the following views that you can enable, for example to view API documentation, try out some regular expressions etc.:
Different views supported for Ruby on Rails web application project in Aptana Studio IDE

At the bottom, you can click on RubyGems tab to see a list of Ruby gems:
List of RubyGems available in Aptana Studio IDE

You might be prompted to install some Ruby gems by Aptana Studio(you can install or ignore them):
Install RubyGems right from the Aptana Studio IDE

RailsPlugins tab will show you the Rails plugins that you can install with a few simple mouse clicks:
Aptana Studio shows the Rails plugins that you can install with a few  mouse clicks

RakeTasks tab allows you to perform various rake tasks by selecting the one you want from the drop-down box:
Perform various rake tasks just by selecting the one you want from the drop-down box in Aptana Studio IDE

Generators tab similarly allows you to generate a scaffold, model, controller, view etc. by selecting the appropriate option from the drop-down box:
Generate a scaffold, model, controller, view etc. by selecting the appropriate option from the drop-down box in Aptana Studio IDE

Creating a Blank Rails Web Application using Aptana Studio

Let us put the Generators tab to use. Select “Scaffold” from the “Generator” dropdown box, enter the parameters as shown in the screenshot below and press the “Go” button.
Generate a Rails scaffold and model in Aptana Studio IDE

You should see the following output in the Console tab.
Scaffold generation output in Aptana Studio console window

You should be able to see the following migration file generated in the project directory:
Migration file generation output in Aptana Studio in console window

And here is a screenshot showing the contents of the generated migration file:
Generated Rails migration file by the scaffold generator in Aptana Studio IDE

If you now run the rake tasks “db:create:all” and “db:migrate” you should be able to see the output of commands executed in the console window:
Output of Rake database migration tasks in Aptana Studio console window

Now run the application. You should see the following output in the internal web browser of Aptana Studio:
Ruby on Rails web application running in the internal web browser of Aptana Studio IDE

Click on the “New Book” link and you will see the new book form like this:
Ruby on Rails web application running in the internal web browser of Aptana Studio IDE

You can go back to your Rails project, make edits, generate more scaffolds, models, controllers and views and test your changes in the internal browser of Aptana Studio. And so on and so forth.

Aptana Studio IDE with RadRails plugins provides one of the richest web application development environments for Ruby on Rails framework. NetBeans 6.1, emacs/vim, IntelliJ IDEA are pretty good too and all of these are multi-platform, so why bother with Mac-only solution like Textmate? ;)

Setting Up Rails Development Environment using Aptana Studio

5

You first need to complete the first five steps of my earlier post “Setting Up Rails Development Environment on Windows Vista/XP” which explain how to install Ruby, RubyGems, Ruby on Rails, Mongrel web server and MySQL database server on Microsoft Winodws Vista/XP. You can skip the last two steps(sixth and seventh) of that post which describe how to setup NetBeans 6.1 IDE for development with the Rails framework; continue with this post instead which explains how to setup the Eclipse-based IDE Aptana Studio for developing web applications using the Ruby on Rails framework.

Download and Install Aptana Studio and RadRails plugin

  1. Download Aptana Studio IDE, run the installer and install it on your computer(or simply extract it if you downloaded the zip file).

    Download Eclipse-based IDE called Aptana Studio with RadRails for Ruby on Rails

  2. Run Aptana Studio. In the main window, you should see the start page of Aptana Studio(for some reason if you don’t, go to Help -> Aptana Studio Start Page…). Here you will see options to install various plugins for Aptana Studio like PHP plugin, Ruby on Rails plugin, Adobe AIR plugin etc. Click the “Install” button in the “Ruby on Rails” section.
  3. Select Aptana RadRails checkbox and select all the available optional features available for it.
    Install RadRails plugin for Eclipse-based Aptana Studio IDE.

    Install RadRails plugin for Eclipse-based Aptana Studio IDE.

    I recommend that you leave the selected default location for installation as it is and proceed with the installation.
    Install RadRails plugin for Eclipse-based Aptana Studio IDE.

Once the RadRails plugin is installed, it is time to configure Ruby installation in Aptana Studio. If you haven’t installed Ruby and Ruby on Rails yet, see my previous post.

Configure Ruby/Rails in Aptana Studio

  1. If Ruby is installed in a location like “C:\ruby”, Aptana will automatically find the path and configure the Rails environment so you don’t have to worry about anything. If you have installed Ruby in a non-standard path where Aptana could not find it, then you need to set the path manually. To do so, go to Windows -> Preferences, expand the Ruby node in the left pane and select the Installed Interpreters item.

    Set the path to installed Ruby interpreter in Aptana Studio RadRails IDE

  2. Click the Add button and enter the details about your Ruby installation directory. Paths to all the other Ruby tools(e.g. rake, rails etc.) will be picked up automatically from this setting.

    Set the path to installed Ruby interpreter in Aptana Studio RadRails IDE

That’s all we need to do to get Ruby on Rails framework configured with Aptana Studio IDE. We can now create new project and check out if everything is working properly. I have made a separate post to show how to create a basic Ruby on Rails web project in Aptana Studio and run it with the help of a lot of screenshots to introduce you to the most important features of the Aptana RadRails IDE for Rails based development, so check that out for more details.

buy genuine Zovirax online purchase prednisone prescription online prednisone no prior script prednisone no rx needed order prednisone usa cod ordering Paxil over the counter order Paxil without rx needed order rx free Paxil cheapest Paxil available online purchase Paxil without purchase Paxil without prescription prednisone cheap overnight fedex discount finpecia purchase Strattera usa cod Cytotec online buy saturday delivery where to buy accutane buy Cytotec online overseas Crestor side effects wm5 software download treo software download best antivirus software download cheap microsoft word software buy software for mac software discounts for educators microsoft office buy windows xp oem software buy flash cs3 software photoshop cs 5 full fashion conference italy buy Orlistat with amex windows 7 product key purchase online cheapest xenical available online prescription xenical online Zithromax uk sales where to purchase generic valtrex online without a prescription quality generic valtrex cheap valtrex usa (no prescriptions needed for Buspar|buy Buspar with no prescription|online pharmacies Buspar|Buspar cheap|buy Buspar without rx|purchase rx Buspar without|Buspar purchase online|purchase Buspar online without rx|purchase Buspar free consultation|buy Buspar Online|buy Buspar american express|buy Buspar Online|buy cheap Buspar with dr. prescription|Buspar side effects|fedex Buspar without priscription|overnight Buspar without a rx|order cheap overnight Buspar|Buspar toronto|uk order Buspar|Buspar no doctors prescription|Buspar mexico|Buspar order|no prescription Buspar with fedex|order generic Buspar|buy Buspar without rx from us pharmacy|prezzo Buspar|Buspar 10mg|Buspar from canada|purchasing Buspar without a script|buy Buspar australia|purchase Buspar visa without prescription|online purchase Buspar|buy Buspar no perscription cod|buy Buspar drugs|buy Buspar with visa|buy Buspar without rx needed|buy Buspar without prescription|buy Buspar no prescription low cost|purchase purchase Buspar no prescription cheap buy generic Valtrex buy cheap Nolvadex cod buy Nolvadex infertility in internet visa at Wisconsin Ontario omicrosoft office 2003 megaupload buy pharmacy Strattera waterview Buy genuine accutane online buy Cytotec online no rx Cytotec online where to buy synthroid in germany buy Nolvadex without rx from us pharmacy buy Nolvadex without a prescription overnight delivery Valtrex without doctor prescription order zithromax 250mg mastercard buy mail order Orlistat buy Valtrex online now Orlistat tablets Strattera best buy free fedex delivery Buspar buy cheap Finpecia under without rx purchase online finpecia without rx finpecia fedex no prescription buy line finpecia want to buy Maxalt in malaysia generic Crestor uk Buspar u.p.s shipping cod buy Prednisone without rx from us pharmacy cheap order rx Valtrex pharmacy prednisone no prescrption buy valtrex cheap without prescription purchase Zithromax without purchase Zithromax no scams Arimidex delivered overnight order cheap overnight Arimidex want to buy Flomax in malaysia buy cheap Flomax without prescription purchase Cytotec over the counter fedex buy cheap Cytotec online free consult buy Cytotec online overnight adobe financial results microsoft office professional 2007 upgrade cheap Buspar by money order cheap valtrex uk purchase Proscar usa cod adobe lm service adobe after effects simple creativity what is Crestor buy Crestor amex Photoshop For Sale buy discount Tamsulosin line Autocad 2010 Review buy Maxalt with a mastercard where can i buy herbal Crestor where to buy Crestor buy Crestor online cod Buy Fincar online 5 mg mastercard purchase Orlistat amex online without prescription flash catalyst sql ms office 2010 enterprise windows 7 upgrade oem Windows Server 2003 Standard Edition Downloads For Windows 7 Ultimate Buy cheap Valtrex without a perscription Valtrex no prescription purchase Valtrex amex online without prescription Xenical Orlistat Flomax buy on line boilsoft viseo create new instrument logic studio 9 cheap purchase finpecia buy Strattera no prescription low cost Flomax best buy formica countertop buy online rx Crestor without buy Prednisone no prescriptions cheap indesign cs android acdsee buy Flomax australia generic Valtrex online download de driver para corel windvd buy microsoft office online cheap generic Valtrex online prednisone ordering without a dr buy Flomax online no prescription buy pharmacy Flomax waterview price of valtrex buy valtrex doctor prescription buy Cipro epharmacist buy generic Crestor purchasing prednisone without a script Cipro canada order generic Tamsulosin buy Buspar without a rx want to buy Buspar in malaysia buy Crestor now buy Valtrex without a rx purchase rx Valacyclovir without Bupropion buy Bupropion buy no perscription Amitriptyline buy discount Zithromax cheapest Zithromax available online how to order Buspar online without a rx purchase prednisone cod next day delivery where can i purchase prednisone online prednisone online cash on delivery microsoft office 2010 3 user license cheap mac desktops no prescription Orlistat cod delivery buy Crestor without doctor buy Valtrex where order Orlistat no rx Microsoft Windows Xp Purchase buy Valtrex legally buy cheap Proscar without prescription buy cheap online pharmacy Buspar generic Zithromax usa accutane 40 mg delivered overnight buy accutane 40 mg with no prescription cheap cs software buy Flomax online us pharmacy cheapest Buspar available online where can i purchase Buspar without a prescription sony oem software Valtrex from india where to purchase cheap Crestor no rx Maxalt pharmacy Prednisone prescription order Crestor ohne rezept Buspar shipped by cash on delivery purchase Proscar online with overnight delivery prezzo Valtrex buy Valtrex shipped cod Proscar no prescription overnight Proscar overnight no consult where to purchase cheap Cytotec no rx Cytotec to buy canadian prescriptions prednisone where to buy Prednisone online Prednisone buy Prednisone Proscar online no rx overnight where can i buy Valtrex online without a prescription buy valtrex legally order Valtrex without a rx overnight shipping c.o.d prednisone purchase Prednisone money purchase buy Cytotec cheapest Cytotec without rx medications buy Zithromax on line buy rx Maxalt without how to buy prednisone online without rx Buy Finpecia 1 mg online finpecia overdose excel new window windows for loop buy Maxalt in india virtual dj software web design software mac no prescription Flomax what does Flomax look like buy Prednisone usa buy Orlistat legally Rosuvastatin generic order buspar pharmacy buy finpecia fed ex dreamweaver cs4 windows mobile opera Maxalt online adobe photoshop price epson creativity suite
Go to Top