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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/56addb8d-41cc-4efc-aff0-060f79c8b688%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Frederick Cheung
2013-Dec-05 21:13 UTC
Re: Recommendations for a fast standalone ActiveRecord process?
On Thursday, December 5, 2013 9:06:06 PM UTC, xop wrote:> > 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? > > > 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/390bae8a-f7c6-4c0a-b637-172494005a7d%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.