![](/img/trans.png)
[英]Ruby on Rails: SQLite3::SQLException: no such column:
[英]ruby (5) on rails - SQLite3::SQLException: no such table
我在我的SQLite數據庫中創建了另一個表,但遺憾的是無法通過rails控制台訪問它。 我通過GUI(SQL Browser的數據庫瀏覽器)添加了一行數據,現在我正在嘗試訪問它,但它給出了錯誤“ActiveRecord :: StatementInvalid:SQLite3 :: SQLException:no such table:”
在我的架構中,我已經可以看到它:
create_table "user_information", force: :cascade do |t|
t.string "charity_name", limit: 100
t.string "res_exp_contact_name", limit: 50
t.string "res_exp_contact_email", limit: 100, default: "", null: false
t.string "grants_contact_name", limit: 50
t.string "grants_contact_email", limit: 100, default: "", null: false
t.boolean "submission_status_res_exp"
t.integer "submission_status_grants"
t.string "category"
t.string "username"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "password_digest"
t.index ["username"], name: "index_user_information_on_username"
end
這就是終端的樣子:
ck$ rails console
Running via Spring preloader in process 8442
Loading development environment (Rails 5.1.4)
Cannot read termcap database;
using dumb terminal settings.
irb(main):001:0> user = UserInformation.first
UserInformation Load (0.2ms) SELECT "user_informations".* FROM
"user_informations" ORDER BY "user_informations"."id" ASC LIMIT ?
[["LIMIT", 1]]
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table:
user_informations: SELECT "user_informations".* FROM
"user_informations" ORDER BY "user_informations"."id" ASC LIMIT ?
from (irb):1
有誰知道解決這個問題? 我很感激任何提示! :-)
解決了它。 答案是你總是將表命名為復數,所以我添加了一個將我的表從“user_information”重命名為“user_informations”的遷移。 現在它有效!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.