Answer the question
In order to leave comments, you need to log in
How to get information from establish_connection in Rails?
You need to get information from a database that has a non-rail structure.
Available:
class Item < ActiveRecord::Base
self.establish_connection(
adapter: "mysql2",
host: "localhost",
port: "3306",
username: "root",
password: "123456",
database: "test"
)
end
Answer the question
In order to leave comments, you need to log in
If I remember correctly, you also need to specify a table for the model:self.table = 'table_name'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question