Thursday, April 8, 2010

Difference between "and" and "&&"

klasses = ['last'] && txt = '' if idx == (tabs.length - 1)


At the end of this statement klasses will contain "".

klasses = ['last'] and txt = '' if idx == (tabs.length - 1)


At the end of this statement klasses will contain ['last'] which was what I intended. But the first statement wasn't returning that.

A good explanation is here http://stackoverflow.com/questions/1426826/difference-between-and-and-in-ruby

Thursday, March 18, 2010

Missing gems even though they are present

Have you seen the following only to realize all those are already installed?

Missing these required gems:
rspec = 1.3.0
rspec-rails = 1.3.2

My environment.rb has entries for both of them like:

config.gem 'rspec', :version => '1.3.0'
config.gem 'rspec-rails', :version => '1.3.2'

After a lot of hair pulling I found we need to add another argument to that config.gem. The following fixed the problem:

config.gem 'rspec', :version => '1.3.0', :lib => false
config.gem 'rspec-rails', :version => '1.3.2', :lib => false