New Feature: PocketQuote, to help with comparision shopping

At Nail Your Mortgage (NYM), we don’t just believe in “Truth in Lending”, we help our customers uncover the truth on a daily basis.
We also realize that pricing of mortgages is very opaque and shopping for mortgages is a daunting task. In our quest to simplify mortgage shopping, we have added a new tool that, we believe, will greatly simplify comparison of mortgages. This new tool is called PocketQuote. Here is some fact about this tool.
What is a
?
- A PocketQuote is a guaranteed mortgage quote that you can generate anonymously, for free.
- A PocketQuote lists all criteria based on which pricing is determined. This is important since most brokers will advertise their best rates, which may or may not apply to your specific situation.
- A lowest rate guarantee from Nail Your Mortgage to stand by flat fee ($750 in IL).
- Best of all, it is anonymous. You are not required to register or share your email/name to get this guarantee from us. Nail Your Mortgage is confident that a fair comparison will reveal that NYM costs are the lowest under any circumstances.
We are so confident in our lowest price guarantee that we encourage borrowers to shop around. PocketQuote is an example of that. We highly recommend our clients to print a PDF quote and send it to other brokers to match beat our rate. Client and their brokers can visit our website anytime to get the latest rate.
Nail Your Mortgage is one of the only handful of mortgage brokers (probably the only) that doesn’t add any markup to the wholesale rate that we get from Lender. Our PocketQuote Guarantee ensures that our fees to consumer ($750 in IL) will never change, irrespective of the amount of loan you buy.
If you are in the market for refinance or purchasing a new home, you ought to check PocketQuote out.

Upgrading to ruby 1.9: rbx-require-relative requires Ruby version ~> 1.8.7
If you are upgrading from ruby 1.8 or Ruby Enterprise 1.8.7 to ruby 1.9.2, you may encounter this error.
Installing rbx-require-relative (0.0.5) Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/ bundler/issues so that we can fix it. Thanks!/Users/sjain/.rvm/rubies/ruby-1.9.2-p290/ lib/ruby/site_ruby/1.9.1/rubygems/ installer.rb:364:in `ensure_required_ruby_version_met': rbx-require-relative requires Ruby version ~> 1.8.7. (Gem::InstallError)
This most likely happens because you are declaring a dependency on ruby-debug gem in your Gemfile.
group :development do gem 'ruby-debug' end
With ruby 1.9, you need to update this with new gem name ruby-debug19.
group :development do gem 'ruby-debug19' end
This will eliminate the dependency on rbx-require-relative and fix the issue.
Developing webapp that require you to expose your local machine on web
If you’ve ever developed facebook applications or have needed to integrate with paypal payment service, you know that those services require a reverse connection from their servers to your webapp to complete full circle. The process of making your webapp, running on your machine during development, to outside world was painful at best.
Not anymore. With this service called “localtunnel”, it is a piece of cake.
Setting environment variables in Max OSX
Any a developer switching from linux to mac, the way to set environment variables is similar yet different enough that is annoying at times. I have so far failed to find a good documentation on where and how to set those in mac osx. Today I found one here.
My takeaway:
Mac OS X applies .bash_profile and .profile only for Terminal.app environment and Apple’s technical documentation suggests using ~/.MacOSX/environment.plist for other applications. So, by default PATH value will differ for RubyMine and the console.
For managing the global environments, it also recommends a system preference pane app. This worked for me.
Debugging Passenger Memory Issues
There was an interesting thread on ruby-passenger application server newsgroup recently: http://groups.google.com/group/phusion-passenger/browse_thread/thread/f48ad0eb018a2482
Here is my take away:
# returns [class, count] tuples for all active records in the heap def ar_space GC.start h = Hash.new(0) ObjectSpace.each_object do |o| next if o.__id__ == self.__id__ next unless ActiveRecord::Base === o h[o.class.to_s] += 1 end return h.sort{|a,b| -(a[1]<=>b[1])} end
Nifty little snippet to fetch number of active record objects on heap. I am guessing, incorporating this as Controller after_filter can help with cost of each request..
Deploy at will!
Shamelessly copying one point from a github blog. It is that good.
Deploy at Will!
At the first RailsConf I had the pleasure of hearing Martin Fowler deliver an amazing keynote. He made some apt metaphors regarding agile development that I will now paraphrase and mangle.
Imagine you’re tasked with building a computer controlled gun that can accurately hit a target about 50 meters distant. That is the only requirement. One way to do this is to build a complex machine that measures every possible variable (wind, elevation, temperature, etc.) before the shot and then takes aim and shoots. Another approach is to build a simple machine that fires rapidly and can detect where each shot hits. It then uses this information to adjust the aim of the next shot, quickly homing in on the target a little at a time.
The difference between these two approaches is to realize that bullets are cheap. By the time the former group has perfected their wind detection instrument, you’ll have finished your simple weapon and already hit the target.
In the world of web development, the target is your ideal offering, the bullets are your site deploys, and your customers provide the feedback mechanism. The first year of a web offering is a magical one. Your customers are most likely early adopters and love to see new features roll out every few weeks. If this results in a little bit of downtime, they’ll easily forgive you, as long as those features are sweet. In the early days of GitHub, we’d deploy up to ten times in one afternoon, always inching closer to that target.
Make good use of that first year, because once the big important customers start rolling in, you have to be a lot more careful about hitting one of them with a stray bullet. Later in the game, downtime and botched deploys are money lost and you have to rely more on building instruments to predict where you should aim.
Javascript Garden
If you consider yourself a beginner or intermediate Javascript developer and feel the need to advance, here’s something that may be right up you ally: Javascript Garden.
Mocha unexpected invocation errors
If you find that your tests pass when run alone but fail with “unexpected invocation” inside “rake test”, you are most likely seeing behavior that is caused by mocha load order.
This is a documented gotcha with mocha. And also discussed here.
It happens when mocha gem is listed as library dependency inside rails app. The library gets loaded too soon. The fix is to load mocha after rails has booted up.
For rails < 3.0.0, this means removing -- config.gem 'mocha' -- entry from config/environment.rb and adding -- require 'mocha' -- at the bottom of test/test_helper.rb.
For rails >= 3.0.0, this means adding — :require => false — inside Gemfile entry as follows.
# Gemfile group :test do gem 'mocha', :require => false end
And then adding following line at the bottom of test/test_helper.rb:
# test_helper.rb require 'mocha'
Installing RMagick gem on Mac OSX
Commands for installing image-magick package and rmagick gem on max osx:
sudo port install tiff -macosx imagemagick +q8 +gs +wmf sudo gem install rmagick
ActiveRecord::MissingAttributeError: missing attribute — a bug or a feature?
Sooner or later, the need arises to assign default values to model attributes. In rails this is usually done in model’s after_initialize() with a new_record? guard.
Something like:
class User def after_initialize if new_record? self.country = "US" end end end
This initializes the object with proper default so the UI form gets properly populated and the database gets proper default if user hasn’t overridden it.
Sometimes, you realize that you have (pre-existing?) objects in database that also need the same default if the current value is nil. In such case, you may modify your initializer like this:
class User def after_initialize self.country ||= "US" end end
This works for both scenarios: User.new and User.find.
However, it introduces a behavior that may not be apparant immediately.
$ script/console ree> User.find(u.id) User Load (0.9ms) SELECT * FROM `users` WHERE (`users`.`id` = 1) ree> User.exists?(:id => u.id) RateSearch Load (0.6ms) SELECT `users`.id FROM `users` WHERE (`users`.`id` = 1) LIMIT 1 ActiveRecord::MissingAttributeError: missing attribute: country /[prj]/app/models/User.rb:3:in `after_initialize'
A closer look reveals that ActiveRecord tries to be smart and only fetch ‘id’ column when performing Model.exists? call.
Many people have tripped this and logged it as a bug. The report has been silently ignored, and I believe, for good/performance reasons.
So, what do we get around it? Here’s one way.
class User def after_initialize self.country ||= "US" rescue ActiveRecord::MissingAttributeError # this should only happen on Model.exists?() call. It can be safely ignored. end end
As they say, it is not a bug, it is a feature.