Friday, December 2, 2011

Sample Application

Just completed chapter 3 of Hartl's Raills Tutorial.  Only real change is adding haml to the mix. While haml does not seem to be officially part of Rails 3.1 I thought this would be a good time to add.

Chapter 3 is just about mostly static pages and adding rspec and autotest.

Code pushed to github.

Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.3'

gem 'sqlite3'

gem 'haml', '~>3.1.4'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end

group :development do
gem 'rspec-rails', '2.7.0'
end

group :test do
gem 'rspec-rails', '2.7.0'
gem 'webrat', '0.7.3'
gem 'spork', '0.9.0.rc9'
end

gem 'jquery-rails'

Tuesday, November 29, 2011

New RubyMIne EAP release

I just updated to RM-112.49 release today, November 29, 2011. It seems to be an improvement over the previous release, about 1% less CPU usage and 20 fewer threads.

Why use the EAP release? Well, it has more support for Rails 3.1.

Why use RubyMine over other editors / IDEs? This is a much harder question to answer. Let me tell you I have used just about all of the reasonable alternatives. None are perfect.  Some work faster and are more native applications.  But I like the rvm and git integration.  It also has most of the best features of other alternatives plus a lot of its own.  It is a little slower but with a really fast machine it is hardly noticeable.

Saturday, November 26, 2011

Update on Redo

Well, there have been some upgrades while I took time off to work on iOS programming and my Ruby teaching material.

RVM

$ rvm --version
rvm 1.9.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]

Ruby

$ ruby --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]

Rails

$ rails --version
Rails 3.1.3

RubyMine

I decided to try RubyMine 4.0 EAP instead of version 3.x.

Use the normal techniques from Hartl's tutorial to setup ruby and rails.  You just had use the appropriate version numbers when setting up Ruby and Rails.

Once everything is installed, just start up RubyMine and use Preferences to setup git and the default Ruby / Rails environment to use.

I setup a new directory for these projects and then created first_app from the tutorial using RubyMine. I did compare to hand generated version and they were the same so I am feeling comfortable with this version of RubyMine.

Thursday, November 10, 2011

iOS 5 Programming

Well, I got Hillegass and Conway's book, iOS Programming 2nd Edition for my birthday in late September.  I was having fun learning how to write applications for the iPhone and iPad. That is, I was having fun until my iPhone 4S showed up and I installed an upgrade to Xcode.

Oops.

The book was published July 2, 2011 and now, just three months later, the coding was broke.  Not totally, but enough that the authors suggested people roll back to Xcode 4.1.  Must be painful to have spent time writing a book and then have the coding environment change just three months later.

I tried lots of different ways of continuing but it was just too painful.  I thought about switching back to Xcode 4.1 and just using my old iPhone 3G (yeah, the 4S was a huge improvement) as a testbed.  But I read more info about iOS 5 and the changes and thought why put myself through learning iOS 4 then learning changes for 5.

I decided to forge ahead and learn iOS 5 from online tutorials but also use the book as a learning guide and update all the applications in it to iOS 5. So that is what I am going to do and will be blogging from time to time as I go.

Friday, November 4, 2011

Xcode 4.2 and company name

Well, I got another surprise with Xcode yesterday.  I had upgraded Xcode 4.2 to build 4D199 a few weeks ago.  I was still working on a project.  Everything seemed to be working fine, but I knew I would have some issues when I started a new iOS project because the new version included support for iOS 5.

But I got an extra surprise when the company name changed.  I had used the old standby way of setting the default company name with the command line:

defaults write com.apple.XcodePBXCustomTemplateMacroDefinitions'{ "ORGANIZATIONNAME" = "YourCompanyName" ; }'

but suddenly I was getting a different company name.

After digging around I found it was getting the name from the Address Book. What I had to do was change My Card to one that had my company name on it.  I had not updated the card for about two years so it seemed to me to be a new change in Xcode.

 

Monday, October 3, 2011

Xcode and git

If you are going to build enterprise applications you really need to use a good SCM.  I intend to look at how to integrate iOS apps within a larger application.  I have used SCM systems for more than 25 years and my current favorite is git.  I was using Hg before on a Java EE project but git has more and better tool support, IMHO.  I also love GitHub.

By default git will be used for any new Xcode project you create.  You have to uncheck the option during project creation if you don't want it. If you leave it checked Xcode will be create the default files for the project and it will do the initial commit.  After that you control the commits.  In this example I have added some code to the example in chapter 2 of Conway and Hillgras's book, iOS Programming, The Big Nerd Ranch Guide, 2nd  One way to access the git commands is via the File menu.

Xcode scm menu

Since I just added some code I want to do a simple commit. This brings up window shown below.  You can not complete the commit until you have added a comment.

XCode git commit screen

Note you can see the diffs of any file being committed.  Not a bad interface for commits.  I'll be commenting on other features of git integration as I use them.

You can also view the SCM repositories and see change history from the same File>Source Control menu.

List of Xcode Repositories

Saturday, October 1, 2011

iOS Programming

Well, I have toyed around with Objective C over the years but never quite made the jump. Then last week I got an autographed copy of iOS Programming, the Big Nerd Ranch Guide, 2nd Editionby Joe Conway and Aaron Hillegrass for my birthday. How cool was that and just at a time I am thinking about enterprise applications that use iPads and iPhones. So now the juices are flowing again.

An added plus is Xcode 4.1 includes git integration.  So, over time I will be adding posts here on iOS programming and interfaces to Rails.

Stay tuned.

Thursday, September 15, 2011

Redo Rails 3.0 Tutorial in 3.1 using Rubymine

First Steps

This is the first of a series of blogs about my experiences redoing Michael Hartl's Rails 3.0 Tutorial in 3.1.  He published a 13th chapter that basically says try to move a file at a time from the completed 3.0 sample application until you get it working.  I am going to take a different approach.  I am going back to the beginning of the sample app and create it from scratch using Rails 3.1 and Rubymine. The only thing I will start with is all the gems needed.  Below is the Gemfile:

I did the original tutorial using several editors: Vim, Textmate, BBEdit, and Aquamacs. Each had its features and problems. None of them could be classified as a full featured IDE.  I have done enough large enterprise projects using Java that realize the value of an IDE. Even in my Smalltalk days the VisualWorks editor could be classified as an IDE, and it was a dynamically typed language also. So I decided to try Rubymine.

The first step was getting Rails 3.1 installed. There was my first surprise.  I had upgraded the Mac OS to Lion and upgraded Xcode since the last time I had tried to install a new version of Ruby or Rails.  The install failed and it turned out I needed to install the rest of Xcode so that gcc would be put in /usr/bin as well as /Developer/usr/bin/gcc.

So here is my starting environment:

  • Ruby 1.9.2p290
  • rvm 1.8.3
  • Rails 3.1.0
  • rake 0.9.2
  • All the gems in Gemfile as well.

First step is install Ruby 1.9.2p290, make sure that gem and rake is up-to-date.  Then use rvm to setup a dedicated gem set.

In Rubymine set the Ruby SDK and gems

Ruby SDK and Gems

Then create a new Rails project.

First step in creating Rails project

Note we are skipping Test::Unit files.

Second step in setting up Rails project

Then setup the Gemfile and use Tools menu to Bundle install.

Now to use Rspec.  First one needs to [Reload generators list] to load the rspec:install generator (it is there because of the Gemfile but the install did not update the generators list). Then select spec:install

Screenshot 03

And no arguments

Screenshot 04

My .gitignore file looks like this

.bundle
db/*.sqlite3
log/*.log
tmp/
.sass-cache/
webrat.log
*.swp
*~
.DS_Store
.idea/*

We now have the base to build on and we are ready to make our first git commit.  The Version Control menu includes a menu item for initial setup.  By selecting the git init you can put the entire directory under git version control. Once I used git init version control menu items changed to support git. See Rubymine's online documentation. All that was left was adding the files and doing the initial comment.

The uncommitted files:

The unversioned files

After adding files and switching to folder view:

Files added before commit in folder view

Commit window:

Initial commit window