Recommendations for a fast standalone ActiveRecord process?

17 views
Skip to first unread message

xop

unread,
Dec 5, 2013, 4:06:06 PM12/5/13
to rubyonra...@googlegroups.com
Hi,

I need to create a standalone script that uses ActiveRecord.

I want it to be as fast as possible, without loading a lot of extra elements.

It seems to work fine to use ActiveRecord::Base.establish_connection and
include my models/ files, but some of those models use the methods named:
    Rails.root
    Rails.env

What is the best way to allow the models to continue to use these function
calls, and yet avoid loading an entire Rails application?

Thanks,
David

Frederick Cheung

unread,
Dec 5, 2013, 4:13:26 PM12/5/13
to rubyonra...@googlegroups.com
Well you could always define them yourself - 

module Rails
  def self.root
    "hardcoded path"
  end
  def self.env
     ENV['RAILS_ENV'] || 'development'
  end
end

Fred 
Reply all
Reply to author
Forward
0 new messages