Through Chapter 2 of Rails Tutorial

I just completed Chapter 2 of the Rails Tutorial that I mentioned in my previous post. It has been a really enjoyable exercise. Every example has been clear and useful. I really like how time is spent on actually setting up your environment. The focus on Test Driven Development & Version Control right from the start also feels exactly right.

Another thing that I really appreciate about this book is that there are exercises where the answer isn’t right in front of you. It can be very easy to just follow the recipe and not learn as much if the exact steps are spelled out directly on the page. At the end of Chapter 2 there are a couple of exercises that I had to go back and read some material again. I want to stress that neither was difficult which is right in line with the goal of making this book for pure beginners. But you do have to use your brain a little bit which I appreciate.

The only thing I have skipped over so far is the setup of Autotest. I’ll go back and redo that section at some point, until then I’m happy hitting spec spec/ as much as needed.

Next up: Ruby on Rails Tutorial

Since completing the Beginning Ruby book a couple of weeks ago I have dabbled with Sinatra, but I’m just not getting it. Being a complete newbie I really need my handheld and the material available to learn Sinatra just wasn’t working for me. Why I went with Sinatra instead of Rails as my next step? I have no idea, but I’m going to Rails now. There is a great community here in Houston to help me out and there is no shortage of tutorials, screen casts and books on Rails. I am a little concerned about the upcoming Rail 3 release and what that will mean for someone starting out with Rails 2.x. However I may have found the material to help me out. Michael Hartl is writing a Ruby on Rails tutorial. As he states at the beginning:

Though the Ruby on Rails web framework benefits from a wealth of learning resources—including books, blogs, and screencasts—many of them assume a substantial background in Rails. Ruby on Rails Tutorial is designed to give you this background. By the time you finish this book, you will have a solid foundation in Rails programming, ready to benefit from more advanced Rails resources.

That sounds like exactly what I need! So I’m jumping in. Michael is in the process of writing the book and is making the drafts available. I’ll be providing feedback on what is confusing to me, as I represent his target audience.

Beginning Ruby – Finished!

I just wrapped up the book and felt the need for quick post.

First of all the book is fantastic. It is well written and the examples were well though out. I didn’t go through every single example, but I read every one. My estimate is that I did 85% of the examples and of that 85% I was able to get 90% of them to work. The ones I didn’t get to work I’m chalking it up to using an old version of the book on a fresh install of Ruby and Ruby on Rails.

Second point. The author, Peter Cooper, has been of more help than I would have dreamed possible. If I got stuck on something, I tweeted it or posted an entry here. Usually in seconds I had a response from Peter. I think there might be 5 of him. 

I’m going to move on to a Ruby on Rails book now. Probably this one.

If you are trying to figure out what book to buy to learn Ruby I really recommend that you pick up Peter’s book.

Problem with scaffolding?

After a couple of days of being distracted by getting Ubuntu set up I am back at it. I’m still in Chapter 13 of the book. I have the 1st edition. After I run through the scaffolding instructions this is the code I get for the  index page.

 

image

This however is not what is listed in the book and the rendered web page looks like this:

image

The table header entries are missing. When I add the code that is supposed to be there, according to the book, to the first <tr> section then it renders properly.

image 

image

I am running into similar problems with another page where scaffolding doesn’t seem to be properly creating the rhtml to display all the contents of the page. For example on the new page, the form fields to create a new entry are missing. Is it the scaffolding that is causing the problem, am I doing something incorrectly or ?

The move to Ubuntu

After running into a few problems during the first 13 chapters of Beginning Ruby that I thought were exacerbated by using Windows I have made the move to Ubuntu. First I was thinking that I would get a new desktop/laptop that would be a dedicated Linux machine but hesitated on making an monetary investment in something (programming) that I was just getting into. Thanks to a tip from @vpz I am now running Ubuntu inside VirtualBox on my laptop.

The setup was pretty straightforward. The only problem I have right now is not being able to adjust the size and resolution of the Ubuntu desktop. I have tried a couple of tips but haven’t cracked that but yet. I will though. I thought I was a good problem solver before. Programming is going to only make me better.

Beginning Ruby Chapter 13, page 399

As I run into problems I am going to post them here and ask for some help. I have the first addition of the book.

I am trying to use ‘migration’ to create my database for the tutorial in this chapter but am running into this error.

 

C:\Users\David\RubyonRails\InstantRails-2.0-win\rails_apps\mydiary>ruby script/generate migration AddEntriesTable

C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:602:in `send’: undefined method `cache_template_extensions=’ for ActionView::Base:Class (NoMethodError)
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:602:in `initialize_framework_settings’
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:601:in `each’
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:601:in `initialize_framework_settings’
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:598:in `each’
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:598:in `initialize_framework_settings’
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:155:in `process’
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send’
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `run’
        from C:/Users/David/RubyonRails/InstantRails-2.0-win/rails_apps/mydiary/config/environment.rb:13
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/generate.rb:1
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’        from script/generate:3

I have updated all gems via ‘gem update’. Any suggestions?

UPDATE (10 minutes later)

Very quickly both @cglee and @peterc responded with the solution which can be found here.

After commenting out the undefined method. I ran into another error.

C:\Users\David\RubyonRails\InstantRails-2.0-win\rails_apps\mydiary>rake db:migrate
(in C:/Users/David/RubyonRails/InstantRails-2.0-win/rails_apps/mydiary)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install
the mysql gem and try again: gem install mysql.
rake aborted!
126: The specified module could not be found.   – C:/Ruby/lib/ruby/gems/1.8/gems
/mysql-2.8.1-x86-mswin32/lib/1.8/mysql_api.so

(See full trace by running task with –trace)

But this time I learned my lesson. I quickly searched for the error I ran into and found this solution which worked perfectly. 

Wow it has been a long time

My last blog post was on July 29, 2009. Before that one it was May 3, 2009. I have been pretty active on Twitter though that isn’t a very good excuse. This morning I’m committing to being more active blogging. First I need to tie up some loose ends. In that May 2009 post I talked about my progress on my goals. Here is how things turned out in 2009.

Goal 1: Kick my soda habit

As I alluded to in the update this goal was about to be dropped. And it was. I’m back to being a 2 or 3 Diet Dews a days drinker. Everyone needs a vice. That one is mine.

Goal 2: Run 50% more than I did last year: 965 miles

I gave this one a good try. My total for the year was 886 miles. I had a couple of poor running months and the summer in Houston was just brutal in 2009. No good excuse though I should have completed this one.

Goal 3: Volunteer more.

In 2009 I volunteered at the Houston Food Bank Peanut Butter factory. I even organized a trip for other co-workers. I also taught some computer classes to veterans through the Houston Goodwill. There is always more I can do but I feel good about this goal.

Goal 4: Inbox Zero.

Nope.

So that wraps up the goal update. What am I up to now?

Learning Ruby on Rails in attempt to get back into the start-up world. The first step in that is to go through a book called Beginning Ruby. I started over the Christmas break and have been spending time each week working through the examples. I am really enjoying it. My journey of learning Ruby and RoR will be a hot topic on the blog for awhile. I’ll pepper in updates on my running; 2010 goal TBD. There is much going on in 2010 and there should be plenty of topics for the blog.

It’s only a matter of time…

Goals progress

Its been a busy time since I wrote my last post goals post on Feb 5th. Unfortunately I’m not doing too hot with blog posts or keeping up with my goals. Here is a status on each plus another goal just for the fun of it.

January Goals

  1. Kick my soda habit. I kicked the habit but I feel myself slipping back into it. I actually bought some soda for the house last week which is the first time I did that since making the goal. Prior to that I had reached a point where I could easily go days without a soda. I really like drinking the Diet Mountain Dew and have begun rationalizing why I should abandon this goal.
  2. Run 50% more than I did last year. I just added everything up and so far this year I have run 282.74 miles which is 30 miles behind the pace I need to keep to reach 965 miles in 2009. I can easily make this up though since we just entered May. I’m lining up a couple of half marathons in late summer/fall which will force me to pick up the mileage. I’ll make this one.

February Goals

  1. Volunteer more. Back in February I said I was going to volunteer at the Houston Food Bank. I didn’t do that but I did volunteer to help teach some computer classes to veterans through Houston Goodwill. That was a great experience and I’ll make volunteering part of the rest of the year. 
  2. Implement and stick to Inbox Zero. Complete failure. I never actually reached Inbox Zero and after managing to keep it steady at about 10-20 email in my Inbox a couple of weeks of business travel have completely destroyed my plan. I need to get this going again.

New Goal

My new goal added today is to complete the Hundred Pushups plan. According to the website this is a 6 week plan to get you to 100 consecutive pushups. I just completed the initial test and completed 33 good form pushups without resting. Back in my Army days I would have paused and knocked out several more but I think with this the idea is to not stop at all.

That’s the goals update. Be back in a few weeks with another update.

There is no beauty in Twitter

I have been thinking about this for a few days and it worries me. I picked on Twitter in my title but the same could said for Facebook, MySpace or just about any Web2.0/social media product out there. There doesn’t seem to be any craft. Maybe it is because all the “social media experts” just became that within the last couple of years. What concerns me is who will be creating beautiful architecture, writing the next great novel, dancing with grace when the world is moving towards 140 characters or less?

There is a lack of touch with social media. The keyboard feels the same to everyone. The mouse offers no depth. How will a population reduced to sending Lil Green Patches grow a garden?

As the great newspapers fight for their existence and people seem to rally behind their demise, where will the journalism come from? People link to the masters but they don’t support them.

I enjoy Twitter, Facebook and their cousins. But I’m more concerned that we will become a civilization incapable of creating anything worth a link.

←Older