The Redmine plugin tutorials explain how to wrap core models but what I need is to add another column to the journals table. I need a boolean field inserted in the journals model. Creating another model with a 'belongs_to :journal' relation seems like an overkill. Can this be done with a plugin? I should note that I am a rails newbie.
+2
A:
You just have to create the appropriate migration.
In your plugin's directory, create the file db/migrate/update_journal.rb
with the following :
class UpdateJournal < ActiveRecord::Migration
def self.up
change_table :journal do |t|
t.column :my_bool, :boolean
end
end
def self.down
change_table :journal do |t|
t.remove :my_bool
end
end
end
Then you can execute the task rake db:migrate_plugins RAILS_ENV=production
to update your database with the new field.
After executing the migration, your journal database will have the my_bool
field that you'll be able to call like every other field.
Damien MATHIEU
2009-11-11 15:16:14