pcrawfor

Paul Crawford

"My clever take on the world."

RailsConf 2008 is over :(

Wow, another railsconf has come and gone and I’m back home in Victoria.

I’ll be posting some detailed info on some of the most interesting stuff I saw while I was there but I wanted to do a quick summary post of my overall impressions.

First things first, the keynotes where great I think that for me they were worth the effort of coming down for the conference alone.

Joel Spolsky

I had been really looking forward to this keynote, being a big fan of JoelOnSoftware and was very curious what Joel would have to say to the rails community. Joel hasn’t been a big advocate of rails although he has a couple of times admitted that he considers rails itself to be a great “hack” (in the good sense of the word). Joel’s talk was entertaining and funny although it did have a bit of a strange message to it in the end. His main points were to focus on making people happy, having great aesthetics and being aware of the culture code in regards to creating software. Overall he gave some useful and often hilarious examples for each :)

His last slide left me and a couple of the other VicRuby guys wondering if he had made a subtle reference to the over-hype that has seemed to have exploded around rails over the last couple of years.

Kent Beck

Kent Beck’s keynote started off a bit slow for me but ended really well, he went over some stories from his time working on and creating Extreme Programming, Test driven development and Design Patterns and where each of them started and evolved. The best part of his talk to my mind was his thoughts for the rails community and the questions and answers after the talk which they let run for quite a long time. He had some great insights to consider.


DHH

The best keynote for me personally was DHH’s because it had really nothing to do with ruby or rails and for the first time I saw him speak at a railsconf where he wasn’t just updating on features or plans but rather dug into a deeper topic.

David addressed the need for all of us as developers and professionals to both work on our own personal development and also to not worry so much about what technology we are using. Even more importantly he emphasized the importance of not coding and having other interests, other passions and expanding our horizons.

I 100% agree with him, and it left me feeling energized in a new way. The most telling thing for me was that he intentionally said not to worry about whether rails is or will be the best thing to use, but to focus on developing great general skills.

Ok I’m done for now, but more to come on some interesting topics that came out the conference.


Rake tasks are fun!

Ok so of course the second I posted my rake task I found an excellent blog article talking about rake tasks that has a better implementation of my own task :) Err the blog has an excellent article on rake and his own creation sake (used to access rake tasks at a system level so that they need not be copied into each rails project independently) here.

(for anyone wanting the quick answer here is the much more elegant impl. of the db version task which is now in rails trunk and has been since about June of last summer) desc "Returns the current schema version" task :version => :environment do puts "Current version: " + ActiveRecord::Migrator.current_version.to_s end


Not to be out done I have a new rake task for you that I am finding useful, along with the annotate_models plugin this one allows a quick view of a table structure without firing up your mysql client.


desc – Describe the table listing column name and type


desc "Describe database table structure" task :describe => :environment do unless ENV.include?('table') && !ENV['table'].blank? raise "usage: rake db:desc table=table_name" end table = ENV['table'] ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) result = ActiveRecord::Base.connection.execute("describe #{table}") puts "table #{table}" result.each do |row| puts "#{row[0]} - #{row[1]}" end end


Usage: rake db:desc table=table_name


One other useful tidbit contained in this task is the parameter passed into the task, I picked this up from a Jay Field’s article here.

The key is that the parameters to the rake task are passed in the ENV hash and have to be accessed accordingly. I’ve also taken Jay’s approach of verifying the parameter and raising an exception if it is not provided to give the user usage info.


Useful rake tasks

Some useful rake tasks…

I wrote a couple handy rake tasks the other day and thought I’d post them for anyone else who might be interested.

DB Version – this one is handy when you are trying to get into sync with some new migrations, especially if any of the migrations have errors (I know…that should never happen :) )

desc "Get the current schema version" task :version => :environment do ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) result = ActiveRecord::Base.connection.execute("select * from schema_info") version = result.fetch_hash['version'] puts "Current Database Schema Version: #{version}" end

Just add that code to your databases.rake and then you can rake db:version away.