Rails 3 does not render partial for specific format - resolving issue
Problem
For example you make ajax request with json format to the server. And assume we have to render some partial in the controller or view and return it in json object. In the view you may have code like this:
- Rails3 view
In the Rails 2 you could pass format as option in reder function and it fixed problem:
- Rails2 view
But in Rails 2 this is not working. But there is a fix this issue and it merged to the master. So, in rails 4 it indeed will work and signature for method will be like this:
- Rails4 view
To enable this feature in Rails 3 you can make monkey patch: just create new file config/initializers/renderer.rb in your application and paste there this code:
- Mokeypatch for Rails3