1

I created a REST API with rails 3.

I use namespace to create virtual environnement development and production, myapi.net/dev/function redirect to a controller in dev directory.

Everything works fine except that my app is now in production and I would like to use the development database when the url called contain /dev/

I know I can change the database in my model, but the model is the same in dev and prod.

Is there a way to do this ?

I know this is not really best practices when using an MVC but I need to do this before creating a real environnement.

Thanks for your help !

1 Answer 1

2

establish_connection is what you're looking for.

In your controller method:

def function
  ActiveRecord::Base.establish_connection :development
  ...
end
Sign up to request clarification or add additional context in comments.

2 Comments

It seems it doesnt' work :( When I try, got production datas !
hi! I'd be useful if you explained whatever you did to solve this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.