Forum: Ruby on Rails Keep fix data in database table while deploying

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
37df158edd0f4ca5fc2fff2e87f43487?d=identicon&s=25 Chris B. (fabrik42)
on 2009-05-13 20:09
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
4c438a80fc30661ad619ea177cf9cbd0?d=identicon&s=25 Freddy Andersen (Guest)
on 2009-05-13 21:04
(Received via mailing list)
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?
F6eb092f8b484121123f54ac283c03ca?d=identicon&s=25 Chris (Guest)
on 2009-05-13 21:45
(Received via mailing list)
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...
Dd2d775dea75b381edb1bbf0600a0907?d=identicon&s=25 Marnen Laibow-Koser (marnen)
on 2009-05-14 09: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
marnen@marnen.org
This topic is locked and can not be replied to.