I often use
respond_to do |format|
...
end
in Rails for my Restful actions, but I don’t know what the ideal solution is for handling various forms of, say, html responses. For instance, view1 that calls action A might expect back html with a list of widgets wrapped in a UL tag, while view2 expects the same list of widgets wrapped in a table. How does one Restfully express that not only do I want back an html formatted response, but I want it wrapped in a table, or in a UL, OL, options, or some other common list-oriented html tag?
This is the basic idea:
Controller
Views
Usage:
You can link to other views “modes” using:
Note: You’ll want to do something to ensure that the user doesn’t attempt to specify an invalid view mode in the URL.