U
U
Unoobee2015-12-01 08:48:26
Ruby on Rails
Unoobee, 2015-12-01 08:48:26

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

When accessed through the console, it says:
=> Item(Table doesn't exist)
I know that a lot of things are missing, but I don't know what. Where can I read about this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Burmakin, 2015-12-01
@Unoobee

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 question

Ask a Question

731 491 924 answers to any question