giddie / redmine_default_assign

Redmine ticket #482:Default assignment setting -- converted to a plugin and then extended.
Other
34 stars 26 forks source link

Fixed - Running migration on Rails 5 #40

Open olivierIllogika opened 4 years ago

olivierIllogika commented 4 years ago

Hi, On a fresh install of Redmine with the following:

Redmine version                4.0.4.stable
Ruby version                   2.5.5-p157 (2019-03-15) [x86_64-linux-gnu]
Rails version                  5.2.2.1

We ran into errors when running the migration command bundle exec rake redmine:plugins:migrate RAILS_ENV=production

First error was:

  Message from application: undefined method `to_prepare' for ActionDispatch::Callbacks:Class
Did you mean?  to_param (NoMethodError)
  /usr/share/redmine/plugins/redmine_default_assign/init.rb:12:in `<top (required)>'

which was fixed by replacing (in init.rb):

- ActionDispatch::Callbacks.to_prepare
+ ActiveSupport::Reloader.to_prepare

(there's probably a better way to do this using a Rails::VERSION::MAJOR check)

Second error was:

StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class AddDefaultAssigneeToProject < ActiveRecord::Migration[4.2]
/usr/share/rubygems-integration/all/gems/activerecord-5.2.2.1/lib/active_record/migration.rb:528:in `inherited'
/usr/share/redmine/plugins/redmine_default_assign/db/migrate/001_add_default_assignee_to_project.rb:1:in `<top (required)>'

which was fixed by adding [5.0] in db/migrate/001_add_default_assignee_to_project.rb: class AddDefaultAssigneeToProject < ActiveRecord::Migration[5.0]

giddie commented 4 years ago

Thanks; would you mind doing a pull request for this?