Code Monkey home page Code Monkey logo

db-switch's People

Contributors

serggl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

db-switch's Issues

Can't Load Second DB

I have two identical tables on the same host, same login, everything, just different instances with different data. When I try to run

ActiveRecord::Base.connect_to(:replica_one) do    
  @project = Project.first
end

With my database.yml looking like:

default: &default
  adapter: sqlserver
  host: HOST_NAME
  username: USERNAME
  password: PASSWORD
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  database: db1

replica_one:
  development:
    <<: *default
    database: db2

The db switch does not occur. I tried printing the ActiveRecord::Base.configurations, I get:

{
  "default": {
    "adapter": "sqlserver",
    "host": "HOST_NAME",
    "username": "USERNAME",
    "password": "PASSWORD",
    "pool": 5,
    "timeout": 5000
  },
  "development": {
    "adapter": "sqlserver",
    "host": "HOST_NAME",
    "username": "USERNAME",
    "password": "PASSWORD",
    "pool": 5,
    "timeout": 5000,
    "database": "crucible02"
  }
}

There is no mention of replica_one anywhere. Is there a setup step that's missing in the README or something I'm doing wrong?

Not working with activerecord relations

After a lot of search i found your gem for switching db connections for my slave database. But it does not seems to be working properly

Here is an example,

ActiveRecord::Base.connect_to(:replica_one) do User.first end

The above one works fine. But the below does not works. Not sure but all similar gems like octopus and others also have the same issue.

ActiveRecord::Base.connect_to(:replica_one) do User.where(id: 1) end

Any help would be greatly appreciated..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.