Query databases in ruby on rails

3

I'm trying to learn rails, and the issue of databases has made it a bit difficult to understand. Create a database by console and subsequent migration, this is supposed to create 3 databases (dev, test and production). But when viewing the bd server from a database administrator (eg: myqlworkbench) none of those created databases appear. Is there any way to manage them in graphical mode or are they just "virtual" databases?

    
asked by daniel2017- 03.02.2017 в 15:42
source

4 answers

1

When you create by default a first application rails, is configured to use sqlite as a database so when you run rake db:create and rake db:migrate you are creating new databases in this manager bd, to explore them you could use some sqlite client tool and open the files hosted in the / db folder of your project.

    
answered by 03.02.2017 в 16:05
1

Once you create a migration, you must run on the console:

rake db:create

and then

rake db:migrate
    
answered by 03.02.2017 в 18:56
1

By default, rails use sqlite and by default when you run rails commands run them in development environment, so once you run rake db:create and rake db:migrate you'll get < strong> a sqlite database real in the /db directory, usually with the name development.sqlite3 or similar. To manage it graphically you can use sqlitebrowser

You can also configure MySQL or PostgreSQL for which you have to edit the file database.yml with the data of the databases and in your server that data must match.

    
answered by 04.02.2017 в 06:05
0

hello I understand what you ask exactly you would have to change to my sql and localhost by default of the mysql .. with another database I do not know. you recommend that you use this command in the console rails g scaffold nombre_tabla_campo1:string campo2:integer campo3:integer since it generates the CRUD. add modify update and destroy. Apart from the controllers and the views, you would only have to execute that and it would be easier for you to learn.

    
answered by 27.11.2017 в 19:14