This is a response to the email I’ve been getting asking me how to use fixtures to load data into a database.
You want to create dummy entries in your Rails app, either for testing, for development, or for production, to make your site appear popular. Whatever the reason, populating your database can be done easily [...]SHARETHIS.addEntry({ title: "How To Use Fixtures to Populate Your Database in Rails", url: "http://biodegradablegeek.com/2008/07/how-to-use-fixtures-to-populate-your-database-in-rails/" });
This is how I populate my database when I have a lot of data but can’t be bothered to write more than a quick throw-away hack. This doesn’t use fixtures, nor migrations (nothing wrong with them, I wuv migrations). Just a ruby file and the Rails console (this is optional actually).
I create a new rb [...]SHARETHIS.addEntry({ title: "Simple Way to Populate a Database in Rails", url: "http://biodegradablegeek.com/2008/03/simple-way-to-populate-a-database-in-rails/" });
This short tutorial will be beneficial for you if database relationships and keywords like belongs_to and has_many confuse you, or if you’re trying to find out how relationships are implemented in Rails. As we create a small demonstration project, you’ll see that one beauty of Rails is how it does most of the work gluing [...]SHARETHIS.addEntry({ title: "Understanding Basic Database Relationships in Rails", url: "http://biodegradablegeek.com/2007/12/understanding-basic-database-relationships-in-rails/" });
NOTE: If you are experiencing segmentation faults with vim and rails.vim, see this post.
When coding in Ruby on Rails, you’ll usually be switching between files and running scripts a lot. It can be time-consuming and frustrating coding Rails using a traditional text editor designed for working on big files individually. Vim lets you hop around [...]SHARETHIS.addEntry({ title: "Using Vim as a Complete Ruby on Rails IDE", url: "http://biodegradablegeek.com/2007/12/using-vim-as-a-complete-ruby-on-rails-ide/" });
Friday, July 11, 2008
5 Comments