我正在使用 Devise gem 并拥有 2 个控制器:
1:控制器/管理员/mailings_controller.rb:
class Admin::MailingsController < ApplicationController
def self.send_emails
...
RegistrationsController.create
...
end
end
2:控制器/registrations_controller.rb:
class RegistrationsController < Devise::RegistrationsController
...
# POST
def create
# do some stuff
super
# do some stuff
end
...
end
但是当我执行(在控制台中)...
Admin::MailingsController.send_emails
……我明白了……
"NoMethodError: undefined method `create' for RegistrationsController:Class"
为什么?以及如何解决这个问题?
rake routes
...显示没有问题:
user_registration POST -> /users(.:format) -> registrations#create