ActiveSupport :: Concern .. Deprecation Warning中的InstanceMethods模块

cab*_*ret 18 ruby activesupport deprecated sinatra

我有一个在Sinatra建立的投资组合网站.我有一段时间没有工作过,一直在做一些Rails.我昨天通过运行'gem update'更新了我的宝石列表.我不知道这是否与此有关,但我今天再次开始在投资组合网站上工作,我一直在收到一些弃用警告.

弃用警告:ActiveSupport :: Concern中的InstanceMethods模块将不再自动包含在内.请直接在Work中定义实例方法.(来自/Users/joris/Desktop/sinatra/portfolio/models/work.rb:2中包括)

我不知道如何解决这个问题,当我运行应用程序时,它不再起作用了..转到我的路线只返回Sinatra 404页面.(另外,Rails不是ActiveSupport的一部分吗?为什么会出现在我的Sinatra应用程序中......)

它在错误中提到的文件是work.rb:

class Work
  include MongoMapper::Document
     key :title, String
     key :url, String
     key :filename, String
     key :file, String
     key :description, String

    timestamps!
end
Run Code Online (Sandbox Code Playgroud)

这是我的主文件(portfolio.rb):

require "sinatra"
require 'twitter'
require 'RedCloth'
require 'html_truncator'
require 'digest/md5'

class Portfolio < Sinatra::Application

  require_relative 'config/init'
  require_relative 'helpers/init'
  require_relative 'models/init'
  require_relative 'routes/init'
Run Code Online (Sandbox Code Playgroud)

模型init文件(调用work.rb文件)具有以下内容:

require 'mongo_mapper'

MongoMapper.connection = Mongo::Connection.new('lalaland.com', 10070)
MongoMapper.database = 'hello'
MongoMapper.database.authenticate('lalala', 'hello')

require_relative 'post'
require_relative 'work'
Run Code Online (Sandbox Code Playgroud)

编辑:刚刚看到我也得到它 models/post.rb

弃用警告:ActiveSupport :: Concern中的InstanceMethods模块将不再自动包含在内.请直接在Post中定义实例方法.(来自/Users/joris/Desktop/sinatra/portfolio/models/post.rb:2中包括)

Fre*_*ung 41

您正在做的应用程序(或其依赖项)中的某个位置

module Blah
  extend ActiveSupport::Concern
  module InstanceMethods
    def foo
    end
  end
  ...
end
Run Code Online (Sandbox Code Playgroud)

和Active Support告诉你这样做

module Blah
  extend ActiveSupport::Concern
  def foo
  end
end
Run Code Online (Sandbox Code Playgroud)

你是对的,Active Support是Rails的一部分,但是像Active Record一样,它也可以在没有其余的rails的情况下使用.例如,Mongo mapper使用它,粗略地看一下它InstanceMethods在一堆地方使用不推荐的习语