Hi there, I'm pretty new to rails, but so far it's fun! But I couldn't find an answer to solve this problem the rails way: I deploy a webapp using capistrano and everything works fine. In my db I have a table that has some fix entries, like "categories", and I want them to move to the deployment server. What's the best way to make the data of a table move with it, when deploying? Regards, Chris
on 2009-05-13 22:09
on 2009-05-13 23:04
I would think you can do this with seed data OR just have one of your migration files add the categories like %w(cat1 cat2 cat3 cat4).each do |cat| Category.create(:name => cat) end Normally for production this is only done once then it stays in the db for each deployment after that. It almost sounds like you clear the db when you deploy is that correct? Is this for a test server or development?
on 2009-05-13 23:45
Hi Freddy, thanks for the hint, I guess this helps me out. :) At this point, I only set up the db structure in migrations, no data at all. So no data could be transfered to the server...
on 2009-05-14 11:36
Chris wrote: > Hi Freddy, > > thanks for the hint, I guess this helps me out. :) > > At this point, I only set up the db structure in migrations, no data > at all. > So no data could be transfered to the server... Setting up data in migrations is possible but awkward if you have more than a very small number of records. Fortunately, there are a couple of gems and plugins designed for seed data (I've never used any of them, but a quick Web search should get you some useful info), and it wouldn't be at all hard to write a simple Rake task or config item that reads data out of a YAML file or something. Best, -- Marnen Laibow-Koser http://www.marnen.org email@example.com