How to access default Rails sqlite db?

Solution 1:

You have neglected to mention the OS you are using.

One way is to use the sqlite3 command in your terminal.

sqlite3 db/development.sqlite3

However, for things like inspecting your rows, you would be better using a rails console.

rails c
> User.all # Where user is your model.

NOTE: Do not change your DB schema directly through sqlite3, something you may be used to if you come from a different web stack background. This is because the next time you run the migrations, the state will be different to what rails expects.

Solution 2:

Rails 3 provides a generic command for accessing the correct database client and pass in the name of the correct database for your current environment. This command is rails dbconsole which can be shortened to rails db

$ rails db
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> 

This command does not offer much more than Gazler's answer and in fact his advice to use the console is good advice however the plus side for this method is that it will use the correct client if your DB is different in other environments.

Solution 3:

use

SQLite> .tables

this will give you the list of all tables exist in the selected database

@@to activate the consol

SQLite> rails dbconsole

@@to show tables

SQLite>.tables

@@ to show all rows in a table

SQLite> select * from posts

Solution 4:

There is a great application to browse sqlite3 databases. SQLite Database Browser.

P.S. You mentioned that you are using Aptana studio. I have started my RoR learning with this IDE as well but later have discovered Sublime Text and never wanted to use anything else since, I advise you to check it out.

Cheers