問題描述
我想在使用 Rails 進行開發時查看我的數據庫中的數據(實際上在所有 3 個開發、測試和生產中).我沒有接觸過配置,所以應該很容易,但我找不到任何可用的信息.
I would like to view the data in my DB while developing with Rails (actually in all 3 of them development, test and production). I have not touched the configs, so it should be easy, but I was not able to find any usable info.
我不知道連接字符串可能是什么或在哪里輸入它,因為 Aptana (v.3) 似乎缺乏我從 Eclipse 知道的舊數據源瀏覽器視圖.有人能指出我正確的方向嗎?
I have no idea what the connection string could be or where to enter it, since Aptana (v.3) seems to lack the good old data source explorer view I know from Eclipse. Could someone point me into the right direction?
我正在使用 linux - Mint 12
I am working on linux - Mint 12
推薦答案
您忽略了您正在使用的操作系統.
You have neglected to mention the OS you are using.
一種方法是在終端中使用 sqlite3
命令.
One way is to use the sqlite3
command in your terminal.
sqlite3 db/development.sqlite3
但是,對于檢查行之類的事情,最好使用 rails 控制臺.
However, for things like inspecting your rows, you would be better using a rails console.
rails c
> User.all # Where user is your model.
注意:不要直接通過 sqlite3 更改您的數據庫架構,如果您來自不同的網絡堆棧背景,您可能已經習慣了這一點.這是因為下次運行遷移時,狀態將與 Rails 預期的不同.
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.
這篇關于如何訪問默認的 Rails sqlite 數據庫?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!