Notes posted by harmRSS feed
Whenever you want to append custom parameters to a to be generated url it might be necessary to stop url_for from escaping.
url_for(:action => 'some_action', :custom1 => 'some_value', :custom2 => 'some_value', :escape => false)
If the escape => false option is not passed the generated url contains & instead of the correct &-sign.
When building a REST server which should accept YAML there are several things to take into consideration.
First of the client should tell the server what type of data it is going to send. This is done via the Content-Type header (which is NOT only a response header as opposed to what the RESTful Web Services book from O’Reilly made us believe).
Second the server application should know how handle the body of the POST request. Placing the following line in your environment.rb:
ActionController::Base.param_parsers[Mime::YAML] = :yaml
This registers the YAML parser. Smooth sailing from here on!
render :xml, some_object.to_xml
render :json, some_object.to_json
render :text => some_object.to_yaml, :content_type => 'text/yaml'
The content_type is debatable but this seems to be the most standard.