Sean’s Obsessions

Sean Walberg’s blog

Using Rails Models From Within an External Script

For some one off scripts I wanted to make use of a couple of models I created. I had no idea how simple it would be to load the rails environment from within a script:

1
2
require 'config/environment.rb'
p MyModel.find(:first)

Sweet! Rails is so… thoughtful.

Comments

I’m trying something new here. Talk to me on Twitter with the button above, please.