I have a portfolio website built in Sinatra. I haven't worked on it for a while, been doing some Rails. I updated my gem list yesterday by running 'gem update'. I don't know if this has anything to do with that, but I started working on the portfolio website again today and I've been getting some deprecation warnings.
我有一个在Sinatra建立的投资组合网站。我有一段时间没有工作,一直在做一些Rails。我昨天通过运行'gem update'更新了我的宝石列表。我不知道这是否与此有关,但我今天再次开始在投资组合网站上工作,我一直在收到一些弃用警告。
DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in Work instead. (called from include at /Users/joris/Desktop/sinatra/portfolio/models/work.rb:2)
弃用警告:ActiveSupport :: Concern中的InstanceMethods模块将不再自动包含在内。请直接在Work中定义实例方法。 (来自/Users/joris/Desktop/sinatra/portfolio/models/work.rb:2中包括)
I'm not sure how to fix this and when I run the application it doesn't work anymore.. going to my routes just returns the Sinatra 404 page. (Also, isn't ActiveSupport part of Rails? Why is this coming up in my Sinatra app..)
我不知道如何解决这个问题,当我运行应用程序时,它不再起作用了..转到我的路线只返回Sinatra 404页面。 (另外,Rails不是ActiveSupport的一部分吗?为什么会出现在我的Sinatra应用程序中......)
The file it mentions in the error is work.rb:
它在错误中提到的文件是work.rb:
class Work
include MongoMapper::Document
key :title, String
key :url, String
key :filename, String
key :file, String
key :description, String
timestamps!
end
This is my main file (portfolio.rb):
这是我的主文件(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'
The models init file (which calls the work.rb file) has these contents:
模型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'
EDIT: Just saw I'm also getting it for models/post.rb
编辑:刚看到我也为模特/ post.rb得到它
DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in Post instead. (called from include at /Users/joris/Desktop/sinatra/portfolio/models/post.rb:2)
弃用警告:ActiveSupport :: Concern中的InstanceMethods模块将不再自动包含在内。请直接在Post中定义实例方法。 (来自/Users/joris/Desktop/sinatra/portfolio/models/post.rb:2中包括)
2 个解决方案
#1
41
Somewhere in your app (or its dependencies) you're doing
您正在做的应用程序(或其依赖项)中的某个位置
module Blah
extend ActiveSupport::Concern
module InstanceMethods
def foo
end
end
...
end
and Active Support is telling you to do
和Active Support告诉你这样做
module Blah
extend ActiveSupport::Concern
def foo
end
end
You're right that Active Support is part of Rails, but like Active Record it can also be used without the rest of rails. Mongo mapper uses it for example, and at a cursory glance it uses the deprecated InstanceMethods
idiom in a bunch of places
你是对的,Active Support是Rails的一部分,但是像Active Record一样,它也可以在没有其余的rails的情况下使用。例如,Mongo mapper使用它,粗略地看一下它在一堆地方使用不推荐使用的InstanceMethods成语
#2
3
It looks like this was patched earlier this month in the mongo_mapper gem, so I would expect the fix to make it into the next release:
看起来本月早些时候在mongo_mapper gem中打了补丁,所以我希望修复程序能够进入下一个版本:
https://github.com/jnunemaker/mongomapper/commit/d2333d944ce6ae59ecab3c45e25bbed261f8180e
https://github.com/jnunemaker/mongomapper/commit/d2333d944ce6ae59ecab3c45e25bbed261f8180e
#1
41
Somewhere in your app (or its dependencies) you're doing
您正在做的应用程序(或其依赖项)中的某个位置
module Blah
extend ActiveSupport::Concern
module InstanceMethods
def foo
end
end
...
end
and Active Support is telling you to do
和Active Support告诉你这样做
module Blah
extend ActiveSupport::Concern
def foo
end
end
You're right that Active Support is part of Rails, but like Active Record it can also be used without the rest of rails. Mongo mapper uses it for example, and at a cursory glance it uses the deprecated InstanceMethods
idiom in a bunch of places
你是对的,Active Support是Rails的一部分,但是像Active Record一样,它也可以在没有其余的rails的情况下使用。例如,Mongo mapper使用它,粗略地看一下它在一堆地方使用不推荐使用的InstanceMethods成语
#2
3
It looks like this was patched earlier this month in the mongo_mapper gem, so I would expect the fix to make it into the next release:
看起来本月早些时候在mongo_mapper gem中打了补丁,所以我希望修复程序能够进入下一个版本:
https://github.com/jnunemaker/mongomapper/commit/d2333d944ce6ae59ecab3c45e25bbed261f8180e
https://github.com/jnunemaker/mongomapper/commit/d2333d944ce6ae59ecab3c45e25bbed261f8180e