devise - 使用 Rails 5 API 修复 Devise 的 alias_method_chain 问题?

标签 devise ruby-on-rails-5

Devise 一直给我这条消息 DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from <class:RouteSet> at /.../.rvm/gems/ruby-2.2.3/gems/devise-3.3.0/lib/devise/rails/routes.rb:27) 这就是 Devise 的 paths.rb 的样子

module ActionDispatch::Routing
  class RouteSet #:nodoc:
    # Ensure Devise modules are included only after loading routes, because we
    # need devise_for mappings already declared to create filters and helpers.
    def finalize_with_devise!
      result = finalize_without_devise!

      @devise_finalized ||= begin
        if Devise.router_name.nil? && defined?(@devise_finalized) && self != Rails.application.try(:routes)
          warn "[DEVISE] We have detected that you are using devise_for inside engine routes. " \
            "In this case, you probably want to set Devise.router_name = MOUNT_POINT, where "   \
            "MOUNT_POINT is a symbol representing where this engine will be mounted at. For "   \
            "now Devise will default the mount point to :main_app. You can explicitly set it"   \
            " to :main_app as well in case you want to keep the current behavior."
        end

        Devise.configure_warden!
        Devise.regenerate_helpers!
        true
      end

      result
    end
    alias_method_chain :finalize!, :devise
  end

这里可以快速修复吗?

最佳答案

该设计候选版本支持 Rails 5,将其放入 ol' Gemfile

gem "devise", '~> 4.0.0.rc1'

关于devise - 使用 Rails 5 API 修复 Devise 的 alias_method_chain 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33072535/

相关文章:

ruby-on-rails - Heroku Websocket 到自定义域

ruby-on-rails - 验证用户! Api 版本控制轨后方法不起作用

ruby-on-rails - 如何在 Ruby on Rails 服务器上验证从 Android 发送的 Google token ID?

nested - fields_for 不保存 Rails 5.0.1 中的嵌套参数

mysql - 验证同一个表中引用同一个表的两个外键

ruby-on-rails - FactoryBot has_many 通过关联出现 NoMethodError 'each'

mysql - 如何使用 Rails 5 迁移在 MySQL 中添加 JSON 列

ruby-on-rails - 设计 Flash 方法 Rails

ruby-on-rails - 设计和设计 token 认证

ruby-on-rails - 在电子邮件中创建一个绕过登录但仍有助于身份验证的链接