I''m trying to figure out the best way to manage multiple sets of data across different environments. I have a situation where I want to automatically load some dummy data into my development environment but I do not want that data to be loaded when I deploy to production. I would imagine that this is a relatively common situation and I''m wondering what people consider to be the best practice for dealing with this type of issue. My latest idea is to simply create data only migrations for my dev data and just wrap the entire body of the up method with with an --if RAILS_ENV == ''development''-- This will probably work fine for my needs, but it seems a little hacky and the Agile Web Dev w/ Rails book actually specifically warns against using migrations to load data not intended for production (even though they don''t follow their own advice in the example app) so I''m thinking there''s got to be a better way or at least some existing convention for dealing with this problem. Any ideas or tips would be much appreciated. Thanks in advance. -Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
you could probably use the same trick in the fixtures. <% if RAILS_ENV == ''development'' then %> ... <% end %> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve mentioned this on a similar thread.. I find Rake tasks to be especially valuable for setting up a database. In lib/tasks, create a file called import.rake. In there, do something like namespace :db do namespace :development do desc "bootstraps the dev database" task :import => :environment do User.create :login=>"admin", :password=>"1234", :password_confirmation=>"1234", :email=>admin-FBj3rGVNSac4Q++5jOxPmw@public.gmane.org Product.create :name=>"Widget", :price=>15.99, :url=> http://www.foo.com/widget.jpg end end # end development namespace end # end db namespace So then rake db:development:import That''s a really simple approach. You could get a little more sophistcated with Rake though and determine what to do based on the environment. This is verbose to show you some possibilities. Hope that helps! On Nov 27, 2007 3:47 AM, Thorsten Mueller <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > you could probably use the same trick in the fixtures. > > <% if RAILS_ENV == ''development'' then %> > ... > <% end %> > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---