Blog

Wednesday, May 6, 2009

undefined method `reenable' (Rake)

Having an issue with rake db:migrate? Update rake:
$ sudo gem update rake

Saturday, May 2, 2009

Installing Feedzirra on CentOS 5.2 64-bit

I was installing Feedzirra gem on Centos 5.2 64-bit. It appeared I had a few 32-bit libraries installed instead of the 64-bit libraries which gave me a bunch of incompatible library messages. Anyway the following yum install and symlink got me on the right track:
sudo yum install libxml2-devel libxslt-devel krb5-devel libidn-devel
sudo ln -sf /lib64/libcom_err.so.2 /lib64/libcom_err.so

Friday, February 6, 2009

Hint: After updating a Bundle you should update Textmate Support

$ /Library/Application Support/TextMate
$ svn co http://svn.textmate.org/trunk/Support
For example, after updating the Ruby Bundle I got this error:
run_script.rb:1:in `require': no such file to load -- /Applications/Editors/TextMate.app/Contents/SharedSupport/Support/lib/tm/executor (LoadError) from /Users/user/Library/Application Support/TextMate/Bundles/Ruby.tmbundle/Support/RubyMate/run_script.rb:1
For more information about Bundles see the Textmate site. Credits: http://lists.macromates.com/textmate/2008-September/026802.html

Monday, January 5, 2009

Cannot connect with Capistrano or sFTP on CentOS

If you are trying to do a "get" operation with Capistrano and receive the following error:
/Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:156:in `[]=': undefined method `[]=' for nil:NilClass (NoMethodError)
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:207:in `handle_error'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:48:in `process!'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:43:in `loop'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:43:in `process!'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:11:in `process'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/configuration/actions/file_transfer.rb:40:in `transfer'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/configuration/connections.rb:170:in `execute_on_servers'
 from /Library/Ruby/Gems/1.8/gems/net-ssh-2.0.3/lib/net/ssh/transport/algorithms.rb:296:in `each_slice'
  ... 17 levels...
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/cli/execute.rb:14:in `execute'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/bin/cap:4
 from /usr/bin/cap:19:in `load'
 from /usr/bin/cap:19


or a simple sftp connection and get the following error:
Request for subsystem 'sFTP' failed on channel 0

It is likely your sftp server is not running due to a mis-configuration in the /etc/ssh/ssh_config file. For CentOS 5.2 Final on a 64-bit architecture I made the following change:
  # The default is incorrect
  # Subsystem sftp /usr/lib/openssh/sftp-server
  Subsystem sftp /usr/libexec/openssh/sftp-server  

The restart ssh server using:
$ sudo /etc/init.d/sshd restart

Monday, December 1, 2008

Setting up a Business in Ontario

Setting up your own business is a pretty straight forward affair, when you know how. Here are the basics:

  1. Register your Trade Name
  2. Setup Bank Account - typically with your current bank
  3. Register Business Number - Online Registration

Additional References

Saturday, November 15, 2008

Updating Ruby Gems

I was trying to update my RubyGems to 1.3.1 on OSX 10.5.5 to tryout the Merb Peepcode Screencast with the following command and got the resulting error:


So instead I tried the RubyGems update gem which worked:


Monday, March 17, 2008

Fundamentals: How Associations are Validated

Summary: Adding validates_associated method to your parent ActiveRecord classes will ensure both the parent and child class are valid before saving.

In this posting we will use the same model as our last post When Associations Get Saved.

Last time, we established that associated child models are automatically saved when the parent is saved. For example:


Here the associated address is saved when account is saved. But how does validation play into the saving of associations?

In this example, we have added no additional validation rules:


Although the account is valid, the address is not, it is missing the street address. When account is saved, it attempts to save the address model, but it cannot. Typically in this scenario we would prefer that the parent model is not saved if the child model in invalid and cannot be saved. How can we achieve this?

Add the following to your account model:


And observe the difference in model behavior:


As you can see an exception is raised when the account is saved as the address is invalid.

In conclusion, when a dependent model needs to be valid add the validates_associcated method to the parent model.

Please note this blog is no longer maintained. Please visit CivilCode Inc - Custom Software Development.