18
votes

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.

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)

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..)

The file it mentions in the error is 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):

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:

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

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)

2

2 Answers

41
votes

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

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

3
votes

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:

https://github.com/jnunemaker/mongomapper/commit/d2333d944ce6ae59ecab3c45e25bbed261f8180e