RockPaperScissors

LizardSpock

Put Methods Not Working with Classy Sinatra Apps

| Comments

Since moving to Classy Sinatra applications I have not been able to get put and delete methods to work correctly. This is because sinatra/base does not include the rack method override ‘stuff’.

require 'rubygems'
require 'sinatra/base'
module MyModule
  class MyApp < Sinatra::Base
    use Rack::MethodOverride ##<-- Required for put delete

    get '/' do
    '<form method="post" action="/">' + 
    '  <input  type="hidden" name="_method" value="put" />' +
    '  <button type="submit"> Test PUT</button><br  />' +
    '</form>'
    end

    put '/' do
      'PUT works'
    end
  end
end

if $0 == __FILE__
  MyModule::MyApp.run!
end

Comments