An update on my Rails Tutorial work

I am now on page 168 of the Rails Tutorial book. Things have been going pretty well. The interaction with Michael Hartl has been very good both on Get Satisfaction and on Twitter. Besides making the PDF free to the public while writing it, Michael is creating lots of goodwill by interacting with his readers. In return he is receiving valuable feedback on minor typos and examples that could use some more description.

There has been more than one occasion where I thought I was stuck or something wasn’t working. Usually it is just a case of me being tired. The next day I find my error and move on. Michael starts the book off early warning about working through the examples while tired isn’t a good idea. I can confirm.

Tonight is a good example. I am at a spot where I can’t get some code to work. When I test I get this thrown back at me:

Processing UsersController#show (for 127.0.0.1 at 2010-03-03 22:48:33) [GET]
Parameters: {“id”=>”1″}
Rendering template within layouts/application
Rendering users/show

ActionView::TemplateError (undefined method `name’ for nil:NilClass) on line #1 of app/views/users/show.html.erb:
1: <%= @user.name %>, <%= @user.email %>

app/views/users/show.html.erb:1

Rendered rescues/_trace (40.0ms)
Rendered rescues/_request_and_response (0.3ms)
Rendering rescues/layout (internal_server_error

I’ve been chasing down the error for several minutes but it’s time to walk away. I’ll be back at it tomorrow.

1 week down, 103 to go

I completed my first week in braces yesterday. My son summed up the experience I had pretty well. “You thought you could just put on braces and it would be that easy, didn’t you?”, he said. Since he spent over 2 years in braces he knows. It’s not that easy.

The first lesson for me was to use the wax. The first two days I was doing alright. Then the inside of mouth was starting to get irritated. The woman that cuts my hair beat it into my head that I needed to use dental wax. The orthodontist had given me some but I had not touched it yet. The wax really does help. Even after just one week I’m already becoming less dependent on it as my mouth gets used to its new tenants.

Lesson number 2 was drinking alcohol without eating is a bad idea. I haven’t been eating much this week. It’s just not that fun. Especially the first few days. I have been limited to mostly soup, yogurt and recently pasta. Friday night we went out and I had a couple of drinks without eating. I was picking at a plate but really there was nothing in my stomach. I paid a price for that lesson.

This first week was a little painful but not completely unexpected. Though Andrew was close, I knew it wasn’t going to be a walk in the park. I am really happy that I decided to get braces. My only regret is that I didn’t do it sooner.

A day of change

Today was a very interesting day where I made two significant changes. The first one is that I now have a lot of metal in my mouth. When I made that comment on a teleconference I was asked if I got my tongue pierced. Yes I did.

Okay no, I did not. What I did do was get braces. This is something I have been considering for a few years. If I had done it when I received my first orthodontic consultation I would be finished now with a smile pretty enough to be on American Idol. I finally made up my mind about 4 weeks ago and began the process of impressions and X-rays. I have known for a couple of weeks that today would be the day and have been very ready to get started. It really wasn’t that bad. I was in the chair for about an hour. There was one problem with getting one of the brackets setup with the wire due to the over-crowding that prompted me in the first place. The day had been setup where I had warned people that I may not be available this afternoon. Once the orthodontist was finished I was on a teleconference 45 minutes later and made it through the workday with no problem. After finishing up my work I headed out for a 5 mile run. One of my best in weeks. The only difficult part this evening has been eating. I can’t really chew much right now which I was warned about. It will take 3-4 days to get used to having braces on and in the meantime I’ll be eating soup and yogurt I suppose.

The estimate is that I will have these on for 24 months. It will fly by. 

The other change will be written about in a future blog post. Nothing too dramatic. Here is a hint. Think fruit and an appropriate name for a cab driver.

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.

←Older