Nikolay Burlov
2011-Jul-19 06:45 UTC
ActiveRecord::Base.establish_connection in development and production envs
Hi, guys! Background: I''ve resque workers in my application. These workers do several jobs that associated with DB. In development environment, I''ve no need to provide some additional configuration for db, they are use development database. But then I switching to production env, I set ActiveRecord::Base.establish_connection with my production DB parameters. Problem: When I''m switch back to development env, I''ve to comment ActiveRecord::Base.establish_connection every time. Hope, anybody can help me and provide a better approach for this situation. Sincerely, Nikolay Burlov. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder
2011-Jul-19 14:22 UTC
Re: ActiveRecord::Base.establish_connection in development and production envs
On Mon, Jul 18, 2011 at 11:45 PM, Nikolay Burlov <kohgpat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve resque workers in my application. These workers do several jobs > that associated with DB. In development environment, I''ve no need to > provide some additional configuration for db, they are use development > database. But then I switching to production env, I set > ActiveRecord::Base.establish_connection with my production DB > parameters. > > Problem: > When I''m switch back to development env, I''ve to comment > ActiveRecord::Base.establish_connection every time.Can''t you just wrap that in a conditional statement based on the environment, e.g. if Rails.env == "production" ActiveRecord::Base.establish_connection(option_hash) end FWIW, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
kohgpat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2011-Jul-19 16:26 UTC
Re: ActiveRecord::Base.establish_connection in development and production envs
Yeah, I''ve thought about this. But I wasn''t sure that this approach is best. Thank you! Sincerely, Nikolay Burlov. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.