Project

General

Profile

Actions

Defect #20394

closed

Patching the create method for User in Redmine version 3

Added by Mike Sweetman over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

Hello, I have a plugin that patches the "create" method in the Users controller. It worked fine in version 2, but I am trying to upgrade to version 3. I have tried versions 3.0.3 and 3.0.4 with the same error both times. Here's the excerpt from my patch that is giving me trouble:

require 'user'

module MailchimpUserPatch
    def self.included(base)
        base.send(:include, InstanceMethods)

        base.class_eval do
            unloadable
            belongs_to :deliverable

            alias_method_chain :create, :mailchimp_subscribe
            alias_method_chain :update, :mailchimp_subscribe
        end
    end

    module InstanceMethods
...
    end
end

And here is the error I am getting:

NameError: undefined method `create' for class `User'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method_chain'
/Users/Pyro/redmine-3.0/plugins/redmine_mailchimp/lib/mailchimp_user_patch.rb:11:in `block in included'
/Users/Pyro/redmine-3.0/plugins/redmine_mailchimp/lib/mailchimp_user_patch.rb:7:in `class_eval'
/Users/Pyro/redmine-3.0/plugins/redmine_mailchimp/lib/mailchimp_user_patch.rb:7:in `included'
/Users/Pyro/redmine-3.0/plugins/redmine_mailchimp/lib/mailchimp_user_patch.rb:78:in `include'
/Users/Pyro/redmine-3.0/plugins/redmine_mailchimp/lib/mailchimp_user_patch.rb:78:in `<top (required)>'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:360:in `require_or_load'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:317:in `depend_on'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:233:in `require_dependency'
/Users/Pyro/redmine-3.0/plugins/redmine_mailchimp/init.rb:2:in `<top (required)>'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/Pyro/redmine-3.0/lib/redmine/plugin.rb:155:in `block in load'
/Users/Pyro/redmine-3.0/lib/redmine/plugin.rb:146:in `each'
/Users/Pyro/redmine-3.0/lib/redmine/plugin.rb:146:in `load'
/Users/Pyro/redmine-3.0/config/initializers/30-redmine.rb:21:in `<top (required)>'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `block in load'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/engine.rb:652:in `block in load_config_initializer'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/notifications.rb:166:in `instrument'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/engine.rb:651:in `load_config_initializer'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/engine.rb:615:in `each'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/engine.rb:615:in `block in <class:Engine>'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/initializable.rb:30:in `instance_exec'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/initializable.rb:30:in `run'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/initializable.rb:44:in `each'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/initializable.rb:44:in `tsort_each_child'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/initializable.rb:54:in `run_initializers'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/application.rb:352:in `initialize!'
/Users/Pyro/redmine-3.0/config/environment.rb:14:in `<top (required)>'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/application.rb:328:in `require_environment!'
/Users/Pyro/.rvm/gems/ruby-2.1.2/gems/railties-4.2.3/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/Users/Pyro/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
/Users/Pyro/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => redmine:plugins:migrate => environment
(See full trace by running task with --trace)

Can anyone help me out?

Actions #1

Updated by Toshi MARUYAMA over 9 years ago

  • Status changed from New to Closed
  • Resolution set to Invalid
Actions

Also available in: Atom PDF