Error in new project boot.rb

When I create a new 2.0 project (rails project_name) Aptana shows what appears to me to be a valid error in boot.rb

The line:

if version = self.class.gem_version

is an assignment Should this not read:

if version == self.class.gem_version

   def load_rails_gem       if version = self.class.gem_version         gem 'rails', version       else         gem 'rails'       end     rescue Gem::LoadError => load_error       $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)       exit 1     end

There is also a second error reported in the (rescue Gem::LoadError => load_error) of "unused local variable load_error"

I changed the first problem to ==, but I am not sure what to do about the second.

Thanks in advance.

Hi,

You don't have to change anything. you can read "if version = self.class.gem_version" as "if (version = self.class.gem_version) != nil"

For the second issue, you could just delete the "=> load_error" part, but I wouldn't bother, I won't waste my time on every little warning your IDE is giving you :slight_smile:

OK,

I am now confused. You are saying that the statement

"if version = self.class.gem_version" is testing whether the assignment was successful?

Could someone please explain this?

Thanks in advance.

Actually, I get it now.

A) It IS an assignment AND a test. B) It is written in a compact and confusing manner.

It should say: (well at least it would more easily understood :slight_smile:

   def load_rails_gem       version = self.class.gem_version # an assignment       if version # a test         gem 'rails', version       else         gem 'rails'       end

Thanks again.