Do I have to care about other methods than GET and POST?

Sometimes I check in a controller if the method is GET or POST. But afaik there are other methods - do I have to care about them?

Is the following enough?

if request.get? ... elsif request.post? ... end

Or do I have to add also an else block?

if request.get? ... elsif request.post? ... else   raise "Boah!" end

IMO, defensive programming says there should almost always be an else in these type of constructs unless they're being used to prepare special cases for the code that follows (code which doesn't care if there's neither a GET nor POST).

So, what will your program do if neither of the first two are satisfied? If the code must have one or the other, then yes, you need an else. If the code modifies something in the cases of GET/POST and otherwise runs just fine if there is no GET/POST, then you do not need the else (because it would halt processing you're expecting to happen).

-- gw

Just to add to the last reply, there are now other very commonly used methods. Namely PUT, DELETE and sometimes HEAD. Rails 1.2 started this and Rails 2.0 will go beyond even what's being done in 1.2. Not adding more methods, but "scaffold_resource" is now simply "scaffold." When generating scaffolding you will get RESTful controllers by default using the full set of HTTP methods.

However, keep in mind that if the request is being generated from a web form it will use GET or POST (at least until browsers get smart enough to handle the other methods). That being said in a modern Rails application you can't count of the request coming from a HTML form. It just might be coming from another client that does understand the full REST method set, or even from a command line on the terminal.