disabling color sql logs in rails

I use Aptana IDE (Eclipse) and the escape characters do not look nice in the default console. The way to prevent this is to do:

ActiveRecord::Base.colorize_logging = false

for example in your development.rb file.

I mean rails 2.3.4. If this does not work for you (other version of rails or whatever) just look at the format_log_entry(message, dump = nil) method of class AbstractAdapter in your rails environment RAILS_HOME/active_record/connection_adapters/abstract_adapter or something.

Posted by wojtek Thu, 05 Nov 2009 14:39:00 GMT




rconv rails rake task test:test:rcov overwrites its output

Problem:

rake test:test:rcov

overwrites its output.

Semi-solution that I use: add to Rakefile

namespace :rcov do
  TESTS_DIR = 'test'
  Rcov::RcovTask.new(:all) do |rcov|
    rcov.pattern    = FileList["#{TESTS_DIR}/**/*test*.rb"]
    rcov.output_dir = 'coverage'
    rcov.verbose    = true
    rcov.rcov_opts << "--sort coverage"
  end
end

Then use the task:

rake rcov:all

Posted by wojtek Fri, 05 Jun 2009 12:55:00 GMT




rails tests uninitialized constant ActiveRecord

Problem: while running tests you get

uninitialized constant ActiveRecord (NameError)

Solution: in my case it was that I was tired and ran the tests no on the test class bu on the model class! Strange error though.

Posted by wojtek Mon, 01 Jun 2009 14:25:00 GMT




rails 2.3.2 uninitialized constant ActionView::Helpers::FormHelper

Problem:

/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in `load_missing_constant':NameError: uninitialized constant ActionView::Helpers::FormHelper
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:443:in `load_missing_constant':NameError: uninitialized constant ApplicationController

Solution: for me it was that I did

require "calendar_date_select"

in environment.rb before the config. You have to move that require line to the end of the file.

Posted by wojtek Sun, 31 May 2009 08:20:00 GMT




NotIdentifiedByImageMagickError paperclip rails error

Problem:

 Paperclip::NotIdentifiedByImageMagickError in Ebook categoriesController#create
 is not recognized by the 'identify' command.
vendor/plugins/paperclip/lib/paperclip/geometry.rb:24:in `from_file'

Solution: you probably did not specify your form as multipart

(...)
form_for @model_name, :html => { :multipart => true } do |f| 
(...)

Posted by wojtek Sun, 17 May 2009 19:10:00 GMT




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




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




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