# All talk but no code...

## Always use respond_to

We have a controller action which has a error handling state.

However eventhough the js is rendered, the response content-type is still "text/html". (The request Accept is set to  */*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript) This is very puzzling to us, because this always worked for us.

Later we found out that the root cause was because we call render_to_string. If we remove that call, Rails will again be able to guess the content-type as text/javascript. Somewhere in the Rails internal must have set the type when render_to_string is called, eventhough it is not directly used by the response rendering.

Using respond_to would also solve this issue, forcing Rails to return text/javascript as the content type.

I guess we should always specify respond_to, so the content-type can be deterministic.