Install Native MySQL Gem - Edge Rails Stopped Including It

July 28th, 2008 No Comments

I decided to try out the latest edge Rails and I started getting this error:

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
/!\ FAILSAFE /!\ Mon Jul 28 22:58:38 -0600 2008
Status: 500 Internal Server Error
dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): Library [...]

Tags:   · ·

acts_as_state_machine - state is always nil

July 26th, 2008 No Comments

If you are using the acts_as_state_machine plugin to manage the state of your object keep this in mind:
If you are going to have an object like an order or something similar that likely has a field state_id to relate in a geographic state then you need to be sure to rename the column that acts_as_state_machine [...]

Tags:   · ·

Shoulda Doesn’t like ‘Status’

July 25th, 2008 No Comments

One of the models in a project I am working on right now ends in ’status’. Rails handles that just find but in my tests I started noticing an odd error:

test: Lookup should belong_to lookup_status. (LookupTest):
NameError: uninitialized constant LookupStatu

The Shoulda test looks like this:

should_belong_to :lookup_status

Nothing to complicated there. Should recognizes [...]

Tags:   · ·

Shoulda, assert_sent_email and Unreal Users

July 24th, 2008 No Comments

I have been banging my head against a problem in my testing. Using the UI everything worked as expected, but my tests were failing when I tried to see if emails were being sent in a specific case.
Here’s the test I was trying to run using Shoulda:

context “reset password for user that has not [...]

Tags:   · ·

Tip for Testing Email with Ruby on Rails and Shoulda

July 24th, 2008 No Comments

Shoulda comes with a great method for testing email called ‘assert_sent_email’. (If you try it and get a method missing error update Shoulda. Not that anyone wouldn’t know to just do that). No matter what you use to test email as long as you are in test mode your emails will be [...]

Tags:   · · ·

ActiveSalesforce and Ruby on Rails > 2.1

July 9th, 2008 2 Comments

We have to do an integration with Saleforce for a Rails project we are working on. I keep getting this error:
The :dependent option expects either :destroy or :delete (:nullify)
I posted to the Salesforce forums and didn’t get any response so I did some more investigation. Turns out there is a bug and a [...]

Tags:   · · · · ·

Checkbox list in Ruby on Rails using HABTM

July 3rd, 2008 7 Comments

Checkboxes are one of those things that look easy and should be easy, but they aren’t always easy. I needed a solution that could create a checkbox list of languages that a user speaks. So I don’t forget here’s how to do it:
The migrations are important. You have to be sure [...]

Tags:   · · · ·

51Weeks at ICLS

June 24th, 2008 3 Comments

Last year for our open ed conference here at Utah State I built an application called 51weeks to help preserve the presentations and to help people interact. Tomorrow it will be used at ICLS in the Netherlands. The hardest part about these kinds of applications is life cycle management. I am frequently [...]

Tags:   · ·

Ruby on Rails - render :action doesn’t run action

June 13th, 2008 No Comments

I want to be cool like everyone else so I use a REST methodology for most of my Rails controllers these days. I wasn’t ever quite sure how my views managed to maintain values for a given object (User, Post, etc) after a failed call to create that that did a render :action => [...]

Tags:   ·

Ajax calls using jQuery in Ruby on Rails

June 7th, 2008 No Comments

jQuery is the hot javascript library and it is small and it is cooler than Prototype, the default library that comes with Ruby on Rails. Ergo I plugged it in and pulled out everything else. The ajax calls are very simple and look like this:

$.post(”function_name”,{ key:value } ,function(data)
{
[...]

Tags:   · · ·