【发布时间】:2017-02-28 12:40:13
【问题描述】:
我正在使用 Rails 4.2.6 并且出现奇怪的错误(使用 HeadFirst 书籍、项目和目录名称 - “mebay”学习 rails):
我需要创建项目只使用“读取”的 CRUD - 所以我运行:
~/mebay $ rails generate model ad name:string description:text price:decimal seller_id:integer email:string img_url:string
Running via Spring preloader in process 8400
invoke active_record
identical db/migrate/20161018144410_create_ads.rb
identical app/models/ad.rb
invoke test_unit
identical test/models/ad_test.rb
identical test/fixtures/ads.yml
我的 db/migrate/20161018144410_create_ads.rb 来了:
class CreateAds < ActiveRecord::Migration
def change
create_table :ads do |t|
t.string :name
t.text :description
t.decimal :price
t.integer :seller_id
t.string :email
t.string :img_url
t.timestamps null: false
end
end
end
(对我来说看起来还不错,基于早期的项目)
然后,据我了解,我需要创建数据库(我使用 sqlite):
~/mebay $ rake db:migrate
但在那之后,我的 development.sqlite3 仍然为空
我做错了什么?
【问题讨论】:
-
在你执行
rake db:migrate之后,日志说了什么? -
@araratan,
~/mebay $ rake db:migrate --trace ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Invoke db:load_config (first_time) ** Execute db:load_config ** Execute db:migrate ** Invoke db:_dump (first_time) ** Execute db:_dump ** Invoke db:schema:dump (first_time) ** Invoke environment ** Invoke db:load_config ** Execute db:schema:dump
标签: ruby-on-rails ruby sqlite rake