我是新來的鐵軌/紅寶石,我想知道我怎麼能仔細檢查,如果我的數據庫架構正確建立在軌控制檯Rails的控制檯數據庫架構檢查
在rails c
ActiveRecord::Base.connection.tables
給我的輸出
["schema_migrations", "users", "expense_pictures", "income_pictures", "income_texts", "expense_texts"]
如何檢查控制檯內是否正確構建了以下模式?
從用戶到IncomePictures和ExpensePictures外鍵。 IncomePictures到ExpensePictures也是外鍵到相應的文本
這裏是我的模型:
class ExpensePicture < ActiveRecord::Base
belongs_to :user
mount_uploader :image, ImageUploader
has_one :expense_text
end
class ExpenseText < ActiveRecord::Base
belongs_to :expense_pictures
end
class IncomePicture < ActiveRecord::Base
belongs_to :user
mount_uploader :image, ImageUploader
has_one :income_text
end
class IncomeText < ActiveRecord::Base
belongs_to :income_pictures
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:rememberable, :validatable
has_many :expense_pictures
has_many :income_pictures
end
列出了一些工具,可視化的Rails schema.rb我很新,我覺得有點用全部丟失遷移和掠奪遷移執行的魔力。我現在有這個。我覺得,如果我sitll缺少的東西http://dpaste.com/2TKPYPK – Liondancer
@Liondancer所以你當前的數據庫架構是不是你所期望的? –
Umm im jsut不知道是否有外鍵連接 – Liondancer