apotonick/roar-rails — Issue #7: Fallback to default responder when there are no representers defined
Author: guiocavalcanti
Created: 2012-02-06 16:52:15+00:00
State: open

I'd like to propose a feature

When defining a controller-wide responder using:

```ruby
def self.responder
Class.new(super).send :include, Roar::Rails::Responder
end
```

I get ``uninitialized constant NilClassRepresenter`` whenever ``respond_with nil`` is called. Wouldn't it be nice if ``Roar::Rails::Responder`` fallback to default rails responder when there aren't representers defined for the resource? With that in mind, any call to ``respond_with nil`` would call ``nil.to_json``.

When a more complex class is passed to ``respond_with``, say Post, and there arent a PostRepresenter defined, the responder would fallback to the default rails responder calling ``post.to_json`` or ``post.to_xml`` on the resource instance.