問題描述
我想在使用 Rails 進(jìn)行開發(fā)時(shí)查看我的數(shù)據(jù)庫(kù)中的數(shù)據(jù)(實(shí)際上在所有 3 個(gè)開發(fā)、測(cè)試和生產(chǎn)中).我沒有接觸過配置,所以應(yīng)該很容易,但我找不到任何可用的信息.
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.
我不知道連接字符串可能是什么或在哪里輸入它,因?yàn)?Aptana (v.3) 似乎缺乏我從 Eclipse 知道的舊數(shù)據(jù)源瀏覽器視圖.有人能指出我正確的方向嗎?
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
推薦答案
您忽略了您正在使用的操作系統(tǒng).
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
但是,對(duì)于檢查行之類的事情,最好使用 rails 控制臺(tái).
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 更改您的數(shù)據(jù)庫(kù)架構(gòu),如果您來(lái)自不同的網(wǎng)絡(luò)堆棧背景,您可能已經(jīng)習(xí)慣了這一點(diǎn).這是因?yàn)橄麓芜\(yùn)行遷移時(shí),狀態(tài)將與 Rails 預(yù)期的不同.
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.
這篇關(guān)于如何訪問默認(rèn)的 Rails sqlite 數(shù)據(jù)庫(kù)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!