Feb 4, 2010

Quick Tip: Access your Rails Helper from the console

Earlier today I was investigating a problem with some code that worked in development but failed in staging. It all centered around one of my helper methods. Being a bit lazy at the time, I tunneled into the server and dropped into console. But there was a problem.. I couldn't access my helper method from script console.. so what to do?


Luckily, you can pull the helper in fairly easily. In my case I wanted to pull in a TeamsHelper.. I did so using the following command:

helper.extend TeamsHelper


After that, getting to a method in my Teams Helper was straight forward. For example

helper.current_status(Team.first)
=> Active


No comments:

Post a Comment