Archive: November, 2009

18 years

18 years ago Freddie Mercury left us. God save the Queen.

M.

will_paginate problem

Sometimes, a search has to be coded in an application and if you are using rails, probably you’ll use will_paginate. It is a good piece of software, easy to install and easy to use but, if it’s not used correctly, problems may appear.

I use it using a form_for rails’s tag and four search criteria in it. After coding it, I added will_paginate and after doing my first search, I paginated to the second page…it came empty. After googling a little, I noticed that I was sending info using POST method and will_paginate needs GET method to work properly, so the only thing needed was:

:html => { :method => :get}

and it worked perfectly, passing parameters to the next pagination.

Hope this helps, it’s something silly but sometimes silly things made people go into the dark side of coding ;-)

M.

Problem installing rmagick (using ruby 1.9.1)

Hi dudes

I’m coding my web application and I need to use the simple_captcha gem, which uses rmagick to generate captchas. I’m trying to install it, I already have imagemagick installed in my debian sid, and I found the following problem


ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for cc... yes
checking for Magick-config... no
Can't install RMagick 2.12.2. Can't find Magick-config in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin

Googling a little I found this page which explains what to do, which is ‘apt-get install libmagickcore-dev‘ as root or using sudo.

After this, a new error appears


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

/usr/bin/ruby1.9.1 extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for cc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.3.5... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.12.2. Can't find MagickWand.h.

And a new action is taken ‘apt-get install libmagickwand-dev‘.

Problems solved and gem installed.

M.

Problem uploading file using ruby 1.9.1 and rails 2.3.3

Hi there

I’m coding an application which has to upload files to the server. I have found an error when the uploaded file is saved in server directory. The message from system is

Status: 500 Internal Server Error
invalid byte sequence in US-ASCII

If you are in the same situation and want to solve it (it’s a rack 1.0.1 gem problem), you have three options:

  • Wait for a new rack release.
  • Apply the patch (I don’t know where it is).
  • Apply manually the solution provided here.

Choose one

M.

Trying again

Hi there

After having a baby, there is not a lot of time to do things as I used to do before. I’ll try to write entries to this blog and share ideas, code and useless things with all people who read this humble blog.

Those days I’m trying to code an web app to allow people who like music upload those songs (covers, non-published songs and so on) which come from nowhere but are amazing. I wish I finished it in two or three weeks and publish it under a cool domain.

See you

M.