Check out example codes for "rails change database connection". It will help you in understanding the concepts better.

Code Example 1

ActiveRecord::Base.establish_connection({:adapter => "mysql", :database => new_name, :host => "olddev",
    :username => "root", :password => "password" })

Learn ReactJs, React Native from akashmittal.com