1 0 Archive | programming RSS feed for this section
post icon

Installing ImageMagick on Mac OS X Leopard

I recently just got the 24inch iMac and had to undergo the massive task of porting over everything from my MacBookPro. This included installing all the needed custom installs of Ruby, Rails, ImageMagick, RMagick, MySQL and configuring everything to work properly. I had the most trouble with ImageMagick, although it wasn’t that hard It still took me a bit to do. Now I hate mac ports, well I don’t hate but I don’t like how it install stuff everywhere. I like being able to control what’s being installed in a tidy fashion. So this is what I did to get ImageMagick working:

(more…)

Leave a Comment
post icon

Advanced Rails Recipes – Keeping Forms Dry and Flexible – Plugin

I’ve updated the previous patch of ElevatedFormBuilder to a Ruby on Rails plugin. You can now install it as a plugin from my github:

script/plugin install git://github.com/darrenterhune/elevated_form_builder.git

If anyone has any problems just add comments below.

Formtastic is far superior than this plugin so you should check that out instead.

Leave a Comment
post icon

Advanced Rails Recipes – Keeping Forms Dry and Flexible Patch

Update: This patch can now be installed as a rails plugin from my github.

I recently committed a patch for the “Keeping Forms Dry and Flexible” recipe found in Advanced Rails Recipes Book. The original recipe was written by Mike Mangino of Elevated Rails. The first time I used the recipe found in the book, I was pretty impressed… almost. Being a usability and accessibility freak that I am I saw that if you passed in the custom :label option (This is to print a custom label instead of the default table column name, which would be in this case… “Title”):

<%= f.text_field :title, :label => "custom label here" %>

This would print:

<label for="controller_title">Custom label here</label><input id="controller_title" type="text" value="some value here" size="30" name="controller[title]" label="custom label here"/>

Wha? There’s a label param in the input element? That’s not allowed!.  So I went off to Mike’s website and contacted him asking him if he had any updates to this recipe. He gladly created a new repository on github for me to pull from. I grabbed his new version of the error_handling_form_builder. Wow it’s different! Wow it’s got 2 form builders! One that lets you use templates like in the book and a more customizable one, that just uses content_tag methods to build a form. Both are pretty sweet and both use the same helper method. However when I tested, it still printed the label in the input. So I did a patch and Mike did a patch and now we have a dry, flexible, accessible, usable and badass form builder with 2 options for building forms! Or of course from Mike’s github.

Leave a Comment
post icon

RubyProf error “can’t convert Fixnum into String”

I recently maxxxxed out my memory limit on my regular dreamhost account at work causing 500 errors all over the place. This is now forcing me to start learning how to cache, and trace my apps for memory and performance. I also switched to PS with 300mb burstable to around 700mb. That should help out for now. Anyway, back to finding out which requests are drinking redbull… I installed the ruby-prof gem to find out. I ran a request with the param key added to the end of the url and wham! Errors? WTF? I copied the code right out of “Advanced Rails Recipes” correctly, and checked it 10 times? So what’s the error? “can’t convert Fixnum into String”? Well it seems that the printer class is trying to convert a number to a string:

response.body << printer.print("", 0)

Just change that to this and that:

response.body << printer.print("", '0')

Then it worked out fine! Hope that helps someone out cause I spent about 2 hours searching for the problem.

Leave a Comment
post icon

My Top Five Favorite Plugins For Rails

There are some pretty sweet plugins out there for Ruby on Rails, but being a beginer with this frame work I’ve found and used these five the most. In no particular order:

1) ATTACHMENT_FU:

Hmmmm, how do you say? Image, photo, graphic management with only writing about 10 lines of code? How bout, BOO YA YIPPIE WOO HOO go suck it PHP! JK I still love you php but just not like Ruby on Rails.

2) DELAYED_JOB

Delayed job is a plugin that let you send or offload processes into the background, so if you have a script that would normally take extremely long to do and don’t want the user waiting till it’s finished this is a plugin you want to checkout.

3) WILL_PAGINATE:

Wow a plugin for pagination! And I’m only writing: <%= will_paginate @subscribers %> Holly woowsers where do I sign up?

4) RESTFUL_AUTHENTICATION:

So authenticating can be downright hard, confusing and annoying… well to do it right and with no security flaws that is. So why not just use someone’s tried, testing and tough like a champ code that allows for admin authentication, sign up activation and more? This plugin rules and your only writing one line of code to tell it which methods should be closed to the public. It also gives you a wacka load of helpful methods to use all over your application.

5) PERMALINK_FU:

This is one cool plugin. When you have a CMS and you allow for people to add; lets say pages to their site, you can use this plugin by putting a line of code or two in your model to automatically create a friendly url. Example: Page called “This Plugin Rocks!” will create a url called this-plugin-rocks! It’s really that simple.

6) WHENEVER

Run scripts, rake tasks etc like cronjobs in pure Ruby. This is much easier than modifying your crontab. This plugin does it for you.

7) CACHE_FU

If you want caching and use memcache, this is a sweet plugin to checkout, although the documentation isn’t very good, you can do a ton of great caching with this cache_fu.

8) FACTORY_GIRL

Factories not fixtures? Yes please, write factories that make it way way easier for you to maintain data in Rails tests.

Leave a Comment