I don't know where to put this, but because the error seems to have stemmed from resque, I'm putting it here.
Background / Problem
For a PoC I'm working on where I need a sinatra app using resque I started with this demo app: https://github.com/arol/sinatra-resque-mongodb-clockwork-bootsrap
After adding sinatra-contrib to my gemfile, creating a new gemset, bundle installing and then starting the app I kept getting the following error:
undefined method `task' for Sinatra::Application:Class
It stemmed from my require 'resque/tasks' line within the Rakefile.
Solution
After a lot of trial and error and failed google searches I ultimately found that the latest version of sinatra-contrib was causing the error. Simply set the version of sinatra-contrib to 1.3.1 in your gemfile, delete your lock file, bundle install, foreman start, and the error will go away.
Does this dig into the actual issue? No. Does it help future people with a Google search for the error? Yup.
TL;DR;
If you are getting this error with your sinatra app that includes sinatra-contrib and resque
undefined method `task' for Sinatra::Application:Class
set your sinatra-contrib version to 1.3.1
Thank you for putting this here! Yep, if you're using Sinatra classic, and you include tasks, you're gonna have a bad time...
A seemingly simple reply has left me with more questions.
Primarily, "sinatra classic". What do you mean?
In the non functioning scenario (not specifying a version), a user would have
resque (1.24.1)
sinatra (1.4.2)
sinatra-contrib (1.4.0)
but in a functioning scenario, the following are installed:
resque (1.24.1)
sinatra (1.3.6)
sinatra-contrib (1.3.1)
Meaning the older, or as I would define "classic" is the ideal scenario for a good time.
I should have probably added a TL;DD; (too long; didn't debug it) asking for clarification as to why this is happening and if there is a better fix than using old versions of a gem.
http://www.sinatrarb.com/intro.html#Sinatra::Base%20-%20Middleware,%20Libraries,%20and%20Modular%20Apps
:)
Adding this to my Gemfile fixed this for me:
gem 'sinatra', require: 'sinatra/base'
@masonforest Thanks. It works for me.
@masonforest you're a hero!
Most helpful comment
Adding this to my Gemfile fixed this for me:
gem 'sinatra', require: 'sinatra/base'