January 07, 2009
Installing Rails & sqlite3 on Mac OS X Leopard
I'm completely new to the Ruby on Rails framework, and I've decided to blog my way to knowledge. This is my first post, and fairly simple. But hey, maybe it will help some out. Check it out, Installing Rails & sqlite3 on Mac OS X Leopard
Hey, ever wanted to load Objects from Ruby files without having to use YAML or define a custom class named like the file? Now you can, with Contextify.
January 06, 2009
Ruby symbols
I keep seeing some programmers from different backgrounds are unable to get what ruby symbols are, and though I do know that there are many great posts regarding this topic, and actually my intent is not to increase them by one :) , but i feel i have to clear few points regarding them.
So I’m trying to answer answer 2 important question here: What are ruby symbols? and When to use them?
Answers goes here :)
Action Guide to git submodules (with Rails flavor)
The article collects current best practices of a submodules workflow and form a “howto” kind of guide,
So if you’re still asking yourself “How shall I track changes in my submodules?” or even (if you’re cool and eat your own dog food) “How shall I use the submodule in my app, have it editable/pushable and let others clone the app without any issues?” - read on, you should find your answers.
How to make a custom form builder in Rails
A quick run through creating a custom form builder in rails. This particular form builder will inline error messages into your form labels.
Little Known Ways to Ruby Mastery by Josh Susser
Josh Susser talks to Ruby beginners providing his insights on the Ruby language.
January 05, 2009
Rubyist Magazine Call for Papers Opens!
The second issue of The Rubyist Magazine is scheduled for February 2009, and this is your chance to be a part of it! Check out the site for info on writing, advertising, and anything else.
CUSEC 2008: Zed Shaw Speaks
Recorded almost a year ago (before the bank busts, and shortly after Zed’s first famous rant), this presentation was given to about 400 Canadian undergraduate software engineers and computer scientists. Zed talks about management and his ACL-killer at a bank job accompanied by Factor-powered slideware. Also: steaks, strippers, and statistics. Zed Shaw - The ACL is Dead - CUSEC 2008

N.B. This video might damage your vision of Zed swearing all the time and may make it seem like the last year of ranting was a terrible joke gone wrong. Oops. P.S. Check out this year’s lineup (Ingalls, Stallman, Bryant, Culver, Hwang, and Bowkett are just the keynotes). This is one of Canada's best kept secrets, and tickets are super cheap.
Ruby on Rails Tutorials
In the hope of helping people that are somewhat new to ruby/rails get up to speed, I've posted this selection of ruby on rails tutorials to help. I've tried to ensure they are still relevant and not teaching people things that hark back to the 1.0 days. Let me know if I've incorrectly included some which are out of date.
January 04, 2009
Load Model, for auto-loading models in your controller
Load Model is a Gemified plugin used to automatically load models in your controllers. Less effort doing the boring stuff, less magic than the REST controller plugin.
SourceClassifier 0.2.1
Have you ever needed to identify the programming language used in a snippet of code, for example in a pastie-style application or in a blog system? SourceClassifier identifies common programming languages using a Bayesian filter trained on a large corpus of examples. It is easy to extend to recognise other languages.
acl9: new authorization plugin for Rails
Role-based authorization system with a nice DSL for specifying access control rules. Available on github.
January 02, 2009
Krauter: A new router for Rails!
It's less than five minutes old, but Jeremy McAnally has released krauter, a new router for Rails. It's described as "Tiny (200 lines fool!), quick (adding routes so fast it hurts and competes with current router otherwise), and agile (OK...it's not more agile. But it sounds cool.)"
Ruby Testing Survey
The Merbist posted a survey of testing frameworks. Which framework do you use?
How to migrate a Rails app from using Attachment_fu to Paperclip
A run through on how to migrate a project from using Attachment_fu to Paperclip as attachment plugin. This includes all the steps for a seamless upgrade including changing the file layouts on Amazon S3.
Hash serialization in an ActiveRecord model
We don’t often think about serialization in Rails but it can be very useful sometimes. This small article contains a little trick if you want to serialize a Hash attribute, for example in order to store preferences or options in the database.
Automatically handle unexpected Ajax errors in Rails
A quick technique to get Ajax errors that work in a similar way to the standard rails error handling
Freelancing Tips for Ruby Developers
Some pointers and discussion about freelancing - with the focus on how to know what to charge and how to gain a bit of notoriety, taken from Rails Camp 4 in Australia.
January 01, 2009
Configatron 2.2.0, now with Ruby 1.9 Support
The latest version of Configatron now has support for Ruby 1.8.x, Ruby 1.9.1rc1, and JRuby 1.1.6 support.
Google's Ruby OpenSocial Library
Google has released opensocial-ruby-client, a library that enables you to work with OpenSocial services from Ruby. It's open source, but sadly you need to sign some sort of document before you can contribute patches and the like..
Send photos from iPhoto to Wordpress using Ruby
Garrick van Buren has written a clever little script that uses rb-appscript and XMLRPC to send photos from iPhoto to a Wordpress blog. It's surprisingly short and effective.
December 31, 2008
Make writing Rspec custom matchers a breeze
To be fair, custom matchers in rspec are pretty easy as is: create a class that implements a few methods and then define a method to wrap that class.

Taking that one step further, with this simple script you can define your own custom matchers with a one liner:
matcher(:be_even) {|number| number % 2 == 0}
matcher(:be_divisible_by) {|n, d| n % d == 0}
Ruby and Metaprogramming
Ruby is a lang that supports Metaprogramming effectively, and might be the best in that field. If you want to explore more on that topic, and how ruby can help you, then check this list of posts i wrote recently, i hope you will enjoy them
A quick tutorial on how to make the default of a hash a hash.
December 30, 2008
Get working quickly with a customised Rails project launcher
Always find yourself opening the same terminal windows and browser tabs when you start work on your Rails app? Try this script to automate the process. It's a simple script using the rb-appscript gem.
Ruby and Internal DSLs
A Domain-specific language(DSL) is a computer language that's targeted to a particular kind of problem, rather than a general purpose language that's aimed at any kind of software problem continue here...
Rails Test Book Design
Anybody want to comment on the design of a Rails testing book?
Fixjour: Another object mother
If nothing has felt quite right to you so far, check out Fixjour. It gives you the new_[model], create_[model] and valid_[model]_attributes methods and nothing else. Check out the README for more info.
Sanitize: A whitelist-based Ruby HTML sanitizer
Sanitize is a new whitelist-based HTML sanitizer for Ruby. Using a simple configuration syntax, you can tell Sanitize to allow certain elements, certain attributes within those elements, and even certain URL protocols within attributes that contain URLs. Any HTML elements or attributes that you don’t explicitly allow will be removed.
December 29, 2008
Leverage ActiveRecord with Non-Database Backed Objects
ActiveRecord comes with a lot of nice things that aren't dependent on having a database backed model. The most obvious example of this is the validation framework baked into ActiveRecord. Also, there are several plugins which add some useful behavior to ActiveRecord objects but don't rely on having a database.

Read the full post about the acts_without_database plugin
Scope Columns
ColumnScope to select only certain values from your DB. I often need only single attributes of an ActiveRecord instance. In the past I used something like select_values(SELECT_SQL) or find(:all, :select => SELECT_SQL_FRAGMENT).map! { |r| [r.title, r.teaser]} to conservativly get them. After some time I felt the redundant code tiring and wrote this tiny plugin on top of named scopes. Usage examples:

Article.selects(:title_and_teaser).with_author.all # => [<Article ...]
Product.ordered_by_name.select_all(:name_and_prize) # => [['Apple Pie', 3.80], ...]

You can find the source and more examples in my repository @ github.
December 28, 2008
Lockdown improvements
I'm working on a new version of Lockdown and would like to hear of any suggestions. more info...
In light of the Rails/Merb merge, how DHH is still being a jerk
http://skein.tumblr.com/post/66709064/its-about-the-ecology-stupid - The Rails/Merb merge isn't necessarily a bad idea. But rails-core needs to actually have a conversation about why people (a number of merbists) were so pissed off at the rails community that they left. And that can't happen until someone acknowledges that there was a legitimate problem.
Ruby callbacks
This blog post is about ruby’s callbacks(hooks): what are the available ones,and how practically we can use them? Ruby callbacks
December 27, 2008
Scalable Datasets with Bloom Filters and Ruby
When you're working with large datasets it's always nice to have a few algorithmic tricks up your sleeve, and Bloom Filters are exactly that - often overlooked, but an extremely powerful tool when used in the right context. Learn the theory and get started with Bloom Filters in Ruby.
Ever been confused by Leopard's patch level for Ruby?
In the comments on bryanl's blog post, "So, if you are using a mac, wanna know why you are using the wrong ruby?", Laurent Sansonetti explains the patch level for the Ruby version maintained by Apple.
Valid Attributes and Records for Unit/Integration testing
valid_attributes a Rails plugin that produces valid Records and attributes from a given yml file.
user = valid User #reord (unsaved)
strange_user = valid User, :name=>'Mr Strange' #slightly modified version...

Also Included: assert_invalid_attributes, a validation to test all validation rules DRY and with readable output.
#--> Failure: User.email expected to be invalid when set to s@sss
asser_invalid_attributes User, :email=>[nil,'','s@sss','xx@dd.s'], ...
Getting Started With Story testing in Cucumber
2 quick tutorials to get started with story-based testing, including some common steps and real-life-stories Cucumber Part 1 and Cucumber Part 2
Ruby reflection 2
This is the second post related to ruby's reflection API, the previous post was an extensive intro to this topic. While the current one will be lighter somehow, it would require you to focus a bit more on the content. Here we go:
December 26, 2008
Another Ruby weather API - NOAA
A new gem for pulling current conditions and daily forecasts from the National Oceanic and Atmospheric Association's weather service (a.k.a. weather.gov).
Ghetto contexts in Rails tests
If you're between a rock and a hard place because you can't add Shoulda or RSpec dependencies to your tests, check out this solution using lambdas.
Rails Monoculture Over
Foy Savas covers the Rails-Merb merge and what to make of it.
merb's provides/display in rails
DHH recently posted about bringing merb's provides/display into rails. Here is my take with a few tweaks.
December 25, 2008
Rails Unit Testing Using Context
A shallow dip into testing using Jeremy McAnally's Context gem
December 24, 2008
New rails plugin for easily adding emailed verifications to your models
Fixie Verifications is a Rails plugin that lets you add emailed verifications to your models. From the README:


class User < ActiveRecord::Base
has_verification_number
end

u = User.create

# An email with a random code is sent to joe@fixieconsulting.com.
# Say the code is "12345"
u.needs_verification!("joe@fixieconsulting.com")

# Either of these work
Verification.verify! "12345"
u.verify! "12345"

u.verified? # returns true

Prototype UI AutoComplete in Rails
Prototype UI autocomplete Using Ruby on Rails
Ezra Zygmuntowicz, Dec 15th 2008
patch -p0 rails-3.0 < merb-core.patch; done, there no more merb vs rails problems
December 23, 2008
rSnipt - Ruby Snipt Library!
rSnipt is a Ruby library I wrote to interact with Snipt.net. There's also a CLI client, which I think will be really useful to all Rubyists. Check it out, and enjoy! :)
Alternative Framworks and Rarb (Rails + Merb)
What is the fate of alternative framworks in the world of Rarb (Rails + Merb)?
Speeding up method missing
Some consideration when using method_missing and a simple technique to speed up method missing