1 0 Tag Archives: plugins
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

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, which just won’t happen. It was pretty obvious what was happening:

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

Right there! It’s trying to append the request body to the printer class with a integer passed as a hash. I haven’t looked at the ruby-prof code but the class doesn’t like that. So I just put quotes around it.

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