vendredi 28 août 2015

How to seed sqlite3 with Rails seed.rb?

To whom it may concern,

Basic Rails app. Created a model called "Images" via rails g model images url:string

Put some jpg's in the Public folder and set up seed.rb file like this:

    images = Image.create([
        { url: "/public/images/01.jpg"},
        { url: "/public/images/02.jpg"},
        { url: "/public/images/03.jpg"},
        { url: "/public/images/04.jpg"},
        { url: "/public/images/05.jpg"},
        { url: "/public/images/06.jpg"},
        { url: "/public/images/07.jpg"},
        { url: "/public/images/08.jpg"},
        { url: "/public/images/09.jpg"},
        { url: "/public/images/10.jpg"},
        { url: "/public/images/11.jpg"},
        { url: "/public/images/12.jpg"},
        { url: "/public/images/13.jpg"},
        { url: "/public/images/14.jpg"},
        { url: "/public/images/15.jpg"},
        { url: "/public/images/16.jpg"},
        { url: "/public/images/17.jpg"},
        { url: "/public/images/18.jpg"},
        { url: "/public/images/19.jpg"},
        { url: "/public/images/20.jpg"}
    ])

Ran rake db:setup, rake db:seed, and rake db:migrate to try to seed the sqlite3 data base.

I go into db/development.sqlite3 and run .databases and find nothing. I run .tables and find nothing.

sqlite> .databases
seq  name             file                                                      
---  ---------------  ----------------------------------------------------------
0    main 

Why did this not seed the database?

Thanks!

Peter

Aucun commentaire:

Enregistrer un commentaire