jrupesh / event_notifications

Redmine event notifications : Add event notification options to the each event at the redmine project. For EX: notifications can be enabled / disabled on each document added or news added. Further the tracking can be done at the issue tracker level.
BSD 3-Clause "New" or "Revised" License
28 stars 26 forks source link

Error alias_method on install #46

Open mverberg opened 5 years ago

mverberg commented 5 years ago

After installing the plugin in Redmine 4.0.1 on Rails 5.2.2 and Ruby 2.5.3 using Mysql2:

bundle exec rake redmine:plugins:migrate RAILS_ENV=production

rake aborted! NoMethodError: undefined method alias_method_chain' for User (call 'User.connection' to establish a connection):Class Did you mean? alias_method /home/redmine/live/plugins/event_notifications/lib/event_notification/patches/user_patch.rb:11:inblock in included' /home/redmine/live/plugins/event_notifications/lib/event_notification/patches/user_patch.rb:9:in class_eval' /home/redmine/live/plugins/event_notifications/lib/event_notification/patches/user_patch.rb:9:inincluded' /home/redmine/live/plugins/event_notifications/lib/event_notification/patches/user_patch.rb:183:in include' /home/redmine/live/plugins/event_notifications/lib/event_notification/patches/user_patch.rb:183:in<top (required)>' /home/redmine/live/plugins/event_notifications/init.rb:4:in <top (required)>' /home/redmine/live/lib/redmine/plugin.rb:173:inblock in load' /home/redmine/live/lib/redmine/plugin.rb:164:in each' /home/redmine/live/lib/redmine/plugin.rb:164:inload' /home/redmine/live/config/initializers/30-redmine.rb:21:in <top (required)>' /home/redmine/live/config/environment.rb:14:in<top (required)>' /usr/bin/bundle:23:in load' /usr/bin/bundle:23:in

' Tasks: TOP => redmine:plugins:migrate => environment (See full trace by running task with --trace)

I found that the alias_method_chain is depreceated and have to be replaced. I really like to use your plugin, can you fix the bug?

with kind regards, Marcel

ajernejcic commented 5 years ago

same here. Ubuntu 18.4, ruby 2.5.1p57, rails 5.2.2

cybicz commented 5 years ago

is there any solution? thanks

mkaminski9193 commented 5 years ago

Also same issue. Ubuntu 18.04, ruby 2.5.1.p57, rails 5.2.3, Redmine 4.0.4

hi-ko commented 4 years ago

It seems @jrupesh is no longer active. This ticket is a duplicate to #45 Maybe there is someone with required ruby skills to step in for this project to migrate the code for redmine 4 / latest ruby? The code should be refactored anyway since the patches contain copied code which has been changed in 4.0.

ranaur commented 4 years ago

The method alias-method-chain is depracated. More info on https://www.justinweiss.com/articles/rails-5-module-number-prepend-and-the-end-of-alias-method-chain/

sphereweb83 commented 4 years ago

Anyone has a fix?

mpauz commented 4 years ago

I've just changed some methods, installed withoud errors, but not tested yet.. I'm not programmer, i hope someone remake normal, because i need only receive emails on any new task in one project when i've checked: only for things i watch or i'm involved in plugins->event_notifications->lib->event_notification->patches

in each *.rb need to rewrite alias_method_chain into alias_method

Like:

user.rb:

alias_method_chain 'notified_project_ids=', 'events' -This one i dont know how to replace

      #alias_method_chain :update_notified_project_ids, :events
      #alias_method_chain :notify_about?, :event

      alias_method :update_notified_project_ids_without_events, :update_notified_project_ids
      alias_method :update_notified_project_ids, :update_notified_project_ids_with_events

      alias_method :notify_about_without_event?, :notify_about?
      alias_method :notify_about?, :notify_about_with_event?

project_patch.rb

alias_method_chain :notified_users, :events

      alias_method :notified_users_without_events, :notified_users
      alias_method :notified_users, :notified_users_with_events

journal_patch.rb

alias_method_chain :notified_users, :events

      alias_method :notified_users_without_events, :notified_users
      alias_method :notified_users, :notified_users_with_events

AND aswell need to uncoment def notified_users_with_events all lines

Please check other .rb files in patches

Both migrate files need add version: (DB-->MIGRATE-->001 and 002

class AddEventColToMembers < ActiveRecord::Migration

class AddEventColToMembers < ActiveRecord::Migration[4.2]

init.rb

ActionDispatch::Callbacks.to_prepare do

ActiveSupport::Reloader.to_prepare do

RolandSM commented 3 years ago

Hello, I changed acc. latest post all files and remine starts, but some issues results in an 404er when I try to open. If I remove the event_notification plugin all works. If I only DISABLE in configuration also 404 happens.