Tuesday, October 28, 2008

Ruby on Rails - try catch finally block equivalent - exception catching

Looking for Ruby equivalent for "try catch finally"?

I also have a problem with that from time to time ;)
Its "begin rescue ensure end"
begin
somecode()
rescue

puts "Error #{$!}"
ensure

this_code_will_execute_always()
end

Sunday, October 26, 2008

1 error prohibited this user from being saved - rails form error_messages

If you have validated errors you can see the following messages:

1 error prohibited this user from being saved
there were problems with the following fields:
....

annoying and not very accurate - aren't they?

If you want to change these default messages try to pass some extra params to the error_messages method:
form_for(@user,:url => { :action => "login" }) do |f| %>
f.error_messages(
:header_message => 'X errors, please find red marks',
:message => 'Following errors were found:')

Monday, April 21, 2008

RMagic installation Error: Can't find MagickCore.h.

While installing RMagic gem (Windows XP) I had the following error:
Can't install RMagick. Can't find MagickCore.h

After many attempts I have downloaded the bundled version (containing both ImageMagic and RMAgic.gem)


http://files.rubyforge...../RMagick-2.0.0-ImageMagick-6.3.7-8-Q8.zip


After installing the ImageMagic from the zip file and doing the following

gem install rmagick --local

I got:
Successfully installed rmagick-2.0.0-x86-mswin32
1 gem installed



It finally works!

Sunday, April 20, 2008

First post

Few days ago I've started my adventure with rails - so right now I'm at the very beginning of the road (of the rails? :) Whenever I will see something interesting or hard for me I'll try to describe it here. Hope it will help somebody ;)