Handling HTTP verbs separately - Ramaze/ramaze GitHub Wiki

You can inspect request.env['REQUEST_METHOD']. Here is a (contrived) example that calls different methods depending on HTTP method used :

class Robot < Ramaze::Controller
  def index(method, *args)
     real_method = request.env['REQUEST_METHOD'].downcase
     real_method << "_"  + method.downcase
     send(real_method, args) if self.class.method_defined?(real_method)
  end

  def get_me(*args)
    "Here is #{args.join ' '}"
  end

  def post_me(*args)
    "Sorry, can't post you #{args.join ' '}. Postoffice is closed."
  end
end

This will be used like this :

$ curl http://localhost:7000/robot/me/a/drink
Here is a drink
$ curl -d "" http://localhost:7000/robot/me/a/letter
Sorry, can't post you a letter. Postoffice is closed.