- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我有一个用 Sinatra 构建的投资组合网站。我已经有一段时间没有研究它了,一直在做一些 Rails。我昨天通过运行“gem update”更新了我的 gem 列表。我不知道这是否与此有关,但我今天再次开始在投资组合网站上工作,并且收到了一些弃用警告。
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)
我不确定如何解决这个问题,当我运行该应用程序时它不再工作了..转到我的路线只会返回 Sinatra 404 页面。 (此外,ActiveSupport 不是 Rails 的一部分吗?为什么它会出现在我的 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
这是我的主文件(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'
模型初始化文件(调用 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'
编辑:刚刚看到我也在为 models/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)
最佳答案
您正在执行的应用(或其依赖项)中的某处
module Blah
extend ActiveSupport::Concern
module InstanceMethods
def foo
end
end
...
end
Active Support 会告诉您这样做
module Blah
extend ActiveSupport::Concern
def foo
end
end
您说得对,Active Support 是 Rails 的一部分,但与 Active Record 一样,它也可以在没有其他 Rails 的情况下使用。例如,Mongo 映射器使用它,粗略地看一下,它在很多地方使用了已弃用的 InstanceMethods
习语
关于ruby - ActiveSupport::Concern.. 弃用警告中的 InstanceMethods 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8683536/
我有两个文件: x.py class BF(object) def __init__(): . . def add(self,z): . . y.py from y
我正在尝试通过类变量调用外部函数。以下是我的真实代码的简化: def func(arg): print(arg) class MyClass(object): func_ref = N
我试图在另一个实例方法的事件处理程序中调用实例方法,但我得到函数未定义,我认为这是因为在事件处理程序中“this”指的是 DOM 元素而不是实例: function MyObject(somethin
html 中的多个复选框,如果选择了 None,我希望我的用户重定向到同一页面。 我应该通过 Javascript 执行此操作吗?或者 if request.method == 'POST':
我不断收到此错误: TypeError: 'instancemethod' object has no attribute '__getitem__' 根据我对 django 网站的特殊看法,我正在玩
我遇到了pickle的问题,代码是: import cPickle class A(object): def __init__(self): self.a = 1 de
我正在尝试创建一个 python 类来使用我的 Raspberry Pi 控制步进电机。它主要有效,但是每当我将列表定义为类变量时,我都会收到“'instancemethod' object has
我正在向 sequelize 模型添加一个实例方法。根据the documentation我应该能够引用 this.name,但我能看到的唯一值是 this.dataValues.name。我没有理由
我爱ActiveSupport::Concern . 它使向您的类添加功能变得容易,而且语法很好。 无论如何,在 Rails 3.2 中,InstanceMethods 模块已被弃用。如果我理解正确,
我正在使用sequelize 连接到mysql 数据库进行开发。我有一个名为 Dealer 的模型: 'use strict'; module.exports = function(sequelize
在我们的代码库中,SWIG 结合了 Python 和 C++。 C++ 类有时会像这样被赋予 Python 扩展: %pythoncode %{ def DiscreteKey_baseData(se
我有一个如下所示的数据框: id ttp var cap_util wip 0 ADLL 3.333333 6.003725e-
我正在模拟循环算法,下面列出的代码给我错误 RR.Przesuniecie[Oczekujace_procesy] TypeError: 'instancemethod' object is unsu
我对 python 和线程还很陌生。我正在尝试编写一个使用线程和队列的程序,以便使用凯撒密码加密 txt 文件。当我单独使用加密函数时,它本身运行良好,但在我的程序中使用它时出现错误。错误从这一行开始
在调试来自 https://github.com/haydnw/AirPi/blob/master/outputs/ubidots.py 的 AirPi 代码时,我遇到了输出期间出现异常:“insta
HTML java c network python list_categories = reques
我想做这样的事情: class X: @classmethod def id(cls): return cls.__name__ def id(self):
所以开始我对 Node.js 的所有事物的冒险。我正在尝试学习的工具之一是 Sequelize。所以我将开始我想做的事情: 'use strict'; var crypto = require('cr
我在文件中创建了一个函数并使用 export function foo(params...) { // do something } 在模型的初始化中,我以这种方式导入函数: import { fo
我有一个类 (Bar),它实际上有自己的状态和回调,并被另一个类 (Foo) 使用: class Foo(object): def __init__(self): sel
我是一名优秀的程序员,十分优秀!