Configuring Rails from database

I have tendency to put as much as possible information into database. I prefer to place some data into DB instead for creation some constants in code. For example when I do develop YAFM, I do use this approach. Code will be available with 0.2 release in future. When exactly it will be available – I don’t know, since it is my lowest priority project.

Database
Creative Commons License photo credit: Tim Morgan

On the plus side You can give users ability to create new entities via web interface (in YAFM categories can be grouped into some bigger groups of expenses/incomes). But when do initialize such data when Rails application starts, You need remeber that no data can be available, more – tables can be missing. It will happen when You run migrations after first checkout with code. When migrations are run application environment is set up like in ‘real application’.

So, if You include initialization code in config/environment.rb code has to deal with missing tables or migration will fail with SQL error (missing table).

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.