简体   繁体   中英

Rails database empty after cloning from another computer via GitHub

I just cloned a rails project I've been working on but unfortunately when I went to modify some of the pre-existing records from my models the database appears to have no recollection of them. While my models are still in-tact its their instances that are not. I did the proper procedure of bundling, and running a migration but no luck. Is there something I'm missing to retrieve these records that were saved on my other computer?

Update:

I've just come to realization that I would most likely have to seed the database to retrieve my records. Correct me if I'm wrong but if I were to go this route that would mean that I'd have to manually input each instance of my model within the seed file. Is there a better way to do this especially if you have a large database?

in my rails app i have a bootstrap.rake file that sets the basic database values that are created upon the initial roll out / installation of the app.

the file lives in rails_app_directory/lib/tasks/bootstrap.rake

do you have anything like this?

this is an example of the kind of code included in the file....

desc "Set a standard layout"
  task :default_page_layouts => :environment do
    puts "Loading default (standard) page layout."

    PageLayout.create(:name=>"Standard", :filename => 'standard', :description => "Standard page layout")
    PageLayout.create(:name=>"Main", :filename => 'main', :description => "Main/Home page layout")
    PageLayout.create(:name=>"Testimonials", :filename => 'testimonials', :description => "For viewing all approved testimonials.")
    PageLayout.create(:name=>"Events", :filename => 'events', :description => "For viewing all events.")
    PageLayout.create(:name=>"Content", :filename => 'content', :description => "For viewing individual content items.")
  end
end

in this case, the table "page_layouts" has the fields "name", "filename" and "description"

For my updated question I ended up choosing the gem, Yamldb and followed instructions from this post . If anyone knows of any better alternatives I'm all ears.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM