Monday, February 13, 2012

Setting rvm gemset in vim

I was having a problem setting my rvm gemset manually in vim using vim-rvm.  I would do a "Rvm gemset use rails234", but then doing a "Rvm info" showed that the gemset was not set.

I finally figured out that if I set the ruby version and the gemset all at once, it would stick, as in "Rvm 1.8.7-oldgem@rails234".

If you have to set your rvm stuff manually in vim and you run into the same problem, hopefully this will help.

Tuesday, February 22, 2011

Rails 3 Upgrade Gotchas

We are in the process of upgrading a very large Rails 2 app to Rails 3. I decided that this would be an excellent time to actually update this blog! So, I'm going to try to post a quick blurb every time I run into a gotcha that bites me. Here is the first one:

Switching to the mysql2 gem to use with Rails 3, got it included in your gemfile, still won't work?

Make sure you change your adapter: settings in your database.yml to "mysql2".

Thursday, June 4, 2009

Deploying from RubyMine

I'm really enjoying RubyMine. I like the git integration. It's nice to not have to open up a terminal just to commit/push changes.

Currently, there is not similar built in support for Capistrano, but it's easy enough to fake. Just go to Run/Run and add a new entry with the following parameters:

Ruby Script: /usr/bin/cap
Script Arguments: deploy (if you do multi-stage, you can do "production deploy", etc.)
Working Directory: local RAILS_ROOT dir

Leave everything else as default and you are good to go.

Wednesday, April 16, 2008

Getting Radiant and Exception Notifier to play nice together

I recently had a need to install the Exception Notifier plugin in Radiant.  I used this excellent post from Casper Fabricus to get it working with Radiant, but I wanted to have it included in every controller, even the Radiant ones, not just the ones in our various extensions.

Since Radiant is a gem, you don't have direct access to it's application controller to be able to add the includes.  It took me a little while to figure this out, but I finally hit on adding these lines to the bottom of the library file that Casper creates in his article:

class ActionController::Base
  include ExceptionNotifiable
  alias :rescue_action_locally :rescue_action_in_public
end

This causes Exception Notifier to be available for all controllers, even Radiants'.

Tuesday, January 29, 2008

Enough with the ninjas!

Hey Rails community. Can you stop using the term "ninja"? The first four million times it was used in job posts, About Us links, and blog articles were hilarious and felt fresh as a baby's bottom. But now, its starting to get a little old.

I think that before someone is allowed to use this word, they have to fulfill the following requirements:

1. Wear black pajamas in public for an entire year.
2. Assassinate a head-of-state.
3. Code an entire Rails app while holding a pair of nunchucks.

Friday, December 28, 2007

Temporarily Turning Off Acts_As_Solr

In a current project, I need to run a rake task that populates a Person table with data from Active Directory. The Person table uses acts_as_solr.

The problem is that the Net:LDAP gem and acts_as_solr seem to conflict with each other. When I define acts_as_solr in the Person table, I get a bind error in Net:LDAP. I have tried changing port numbers for acts_as_solr, but no go.

So, here's a work around that might be helpful to others. What I want is the ability to temporarily turn off acts_as_solr in the Person model, run the rake task to populate the table, then turn acts_as_solr back on.

First, in the Person model here is how include acts_as_solr:

acts_as_solr if AppConfig.solr_on

So, acts_as_solr will only be included if a global variable called solr_on is true.

Now, in the rake task, I first set solr_on to false:

AppConfig.solr_on = false

Then, I re-load the Person class, so that acts_as_solr will not be included:

load "#{RAILS_ROOT}/app/models/person.rb"

Finally, at the bottom of the rake task, I set solr_on back to true and re-load the Person class, so that acts_as_solr will be included. I also reindex solr so that the added records will be included:

AppConfig.solr_on = true
load "#{RAILS_ROOT}/app/models/person.rb"
Person.rebuild_solr_index

This might be beneficial in a more generic context.

Friday, December 21, 2007

Mac Ports upgrade of ruby breaks dbi/odbc

In case anyone else runs into this hair-puller-outer:

I upgraded the Mac Ports version of ruby on my Macbook and suddenly my rake tasks that use dbi/odbc were bombing saying ruby couldn't find the ODBC driver for dbi. I made sure my rb-dbi and rb-odbc were the latest ports, but no go. Finally, I uninstalled rb-odbc and reinstalled rb-odbc, same version, and things started working again. Go figure.