rails undefined method updated?

Problem:

NoMethodError (undefined method `updated?' for my_something

Solution: Use

self.my_something

insted of

 @my_something

when assigning to object attribute supplied by belongs_to association.

Posted by wojtek Sat, 16 May 2009 14:19:00 GMT




rmagick ubuntu installation problem

Problem:

Can't install RMagick 2.9.1. Can't find MagickCore.h.

Solution:

apt-get install libmagick++9-dev

Posted by wojtek Fri, 17 Apr 2009 16:30:00 GMT




ruby net sftp problem

Problem:

/var/lib/gems/1.8/gems/net-sftp-2.0.2/lib/net/sftp.rb:43:in `start': undefined method `shutdown!' for nil:NilClass (NoMethodError)

Solution: you are using old SFTP API, the start(…), etc method signatures have changed. Use the new methods (http://net-ssh.rubyforge.org/sftp/v2/api/index.html). I tried to pass the password as the third parameter, but it was to be the options parameter to be passed :password => “pass”.

Nevertheless the bug is still there, there is not shutdown! method.

Posted by wojtek Mon, 13 Apr 2009 19:40:00 GMT




ruby gem update system is disabled on Debian

Problem:

ERROR:  While executing gem ... (RuntimeError)
    gem update --system is disabled on Debian. RubyGems can be updated using the official Debian repositories by aptitude or apt-get.

Unfortunately the apt-get update does not help at all.

Solution:

gem install update_rubygems
cd /var/lib/gems/1.8/bin
./update_rubygems

or

gem install rubygems-update
cd /var/lib/gems/1.8/bin
./update_rubygems

Posted by wojtek Sun, 12 Apr 2009 18:49:00 GMT




rails ActiveScaffold TemplateError problem

Problem:

ActionView::TemplateError (XYZController missing ActiveScaffold) on line #14 of vendor/plugins/active_scaffold/frontends/default/views/_form_association.rhtm

Solution: you forgot to add “active_scaffold” to the XYZController.

Posted by wojtek Tue, 24 Feb 2009 16:18:00 GMT




rmagick image size (dimensions)

How to determine the size of an image in RMagick? I spent over 10 minutes figuring it out :) Example:

require 'RMagick'
img=Magick::Image.read("IMG.PNG").first
img.rows
img.columns

Posted by wojtek Sat, 24 Jan 2009 14:53:00 GMT




aptana out of memory

Aptana Rad Rails complains that it is out of memory “An out of memory error has occurred”.

The solution is to edit AptanaStudio.ini, eg.:

-name
Aptana
Studio
-vmargs
-XX:MaxPermSize=256M
-Xmx512M
-Xms128M
-Djava.awt.headless=true

Posted by wojtek Sun, 18 Jan 2009 18:38:00 GMT




windows rails SaltedHashLoginGenerator generation problem

While doing:

ruby script/generate salted_login User Localization

I got:

Gem::SourceIndex#search support for Regexp patterns is deprecated
c:/programs/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/rails_generator/lookup.rb:211:in `each' is outdated
  dependency  localization
Gem::SourceIndex#search support for Regexp patterns is deprecated
c:/programs/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/rails_generator/lookup.rb:211:in `each' is outdated
      exists    lang
   identical    lib/localization.rb
   identical    config/environments/localization_environment.rb
   identical    test/unit/localization_test.rb
   identical    lang/localizations.yaml
   identical    README_LOCALIZATION
   identical    LICENSE_LOCALIZATION
   identical  lib/user_system.rb
   identical  app/controllers/user_controller.rb
   identical  test/functional/user_controller_test.rb
   identical  app/helpers/user_helper.rb
   identical  app/models/user.rb
   identical  app/models/user_notify.rb
      exists  db/migrate
      create  test/mocks/test/user_notify.rb
No such file or directory - C:/xyzxyz/test/mocks/test/user_notify.rb

The solution was to create the folders test/mocks/ and test/mocks/test.

Posted by wojtek Thu, 15 Jan 2009 20:12:00 GMT




ruby sqlite3 windows vista problem

Problem:

C:\Users\wojtek>gem install sqlite3-ruby

Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3-ruby:
        ERROR: Failed to build gem native extension.

c:/Programs/ruby/bin/ruby.exe extconf.rb install sqlite3-ruby
checking for fdatasync() in rt.lib... no
checking for sqlite3.h... no

nmake
'nmake' is not recognized as an internal or external command,
operable program or batch file.


Gem files will remain installed in c:/Programs/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to c:/Programs/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out

Solution: follow the tutorial http://wiki.rubyonrails.org/rails/pages/HowtoUseSQLite and the additional info http://domhackers.blogspot.com/2008/09/sqlite3-ruby-gem-on-windows.html

Posted by wojtek Mon, 29 Dec 2008 10:13:00 GMT




ruby gems private method specification_version problem

/usr/lib/ruby/1.8/rubygems/source_index.rb:86:in `load_specification': private method `specification_version=' called for # (NoMethodError)
        from /usr/lib/ruby/1.8/rubygems/specification.rb:401:in `initialize'
        from (eval):1:in `new'
        from (eval):1:in `load_specification'
        from /usr/lib/ruby/1.8/rubygems/source_index.rb:121:in `eval'
        from /usr/lib/ruby/1.8/rubygems/source_index.rb:86:in `load_specification'
        from /usr/lib/ruby/1.8/rubygems/source_index.rb:121:in `load_gems_in'
        from /usr/lib/ruby/1.8/rubygems/source_index.rb:120:in `each'
        from /usr/lib/ruby/1.8/rubygems/source_index.rb:120:in `load_gems_in'
         ... 8 levels...

Try

ruby -v

because you probably have 1.8.x. If so, install ruby 1.9 and execute the code with it.

Unfortunately in ubuntu there seems to be a problem with the packages dependency. If you install rubygems package you get ruby1.8 also. The solution is to run the code explicitly with “ruby1.9” instead of “ruby” or for your own responsibility:

rm /usr/bin/ruby
ln -s /usr/bin/ruby1.9 /usr/bin/ruby

You may then get a:

/usr/bin/gem:9:in `require': no such file to load -- rubygems (LoadError)
        from /usr/bin/gem:9

This is because ruby1.8 had the gems installed, not 1.9. You can check that through:

locate rubygems.rb

The solution is to install gems for ruby1.9 as well. But there is another problem, The ruby1.9 has no complete rake installed.

So the best thing to do in my opinion is not waste time and do something like:

apt-get remove ruby ruby1.9 ruby1.8 rubygems rake
cd /opt/install
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.0-5.tar.bz2
tar -xf ruby-1.9.0-5.tar.bz2
cd ruby-1.9.0-5
./configure --prefix="/opt/ruby1.9"
make
make install

And then setup your $PATH, edit .bashrc or whatever (.profile, …) and place the parth to /opt/ruby1.9/bin dir in it.

export GEM_HOME=$HOME/opt/gems
export GEM_PATH=$HOME/opt/gems/gems
export PATH=$PATH:/opt/ruby1.9/bin

This worked for me.

You can also have a look at: /2009/06/08/ruby-1-8-6-in-ubuntu-9-04-64-minimal

Posted by wojtek Tue, 11 Nov 2008 13:11:00 GMT