简体   繁体   中英

rails server not reflecting changes to seed.rb file

new to rails and programming in general.

I have a rails app I'm working on that I cannot figure out what's going on.

My index.rb file displays a set of pins. These pins are created and stored under db > seeds.rb

When I want to add a new pin, I create it in seeds.rb and it comes up on my index.rb file (after running rake db:seed).

However, once I delete it, and rake again, it's still there and will never go away.

I can make other changes and those are reflected no problem, it's just with my seed.rb file that the issues happens.

I've tried restarting my rails server, nothing works.

This is on localhost (rails s) Using postgresql Using latest version of rails

I think you have understood the idea of seeding wrong. It should only be used to add initial data to the database. When you run rake db:seed , it will add the data you defined in your seed.rb file to the database, which is associated with the environment you are currently running.

So you have to truncate/delete the content of the database and seed it again to get the changes in your seed.rb file reflected.

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