Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Discover whether XMLHttpRequest or a URL in a browser is requesting an action.
One of the issues with defining simple actions in Ruby on
Rails is that once an action that responds with a fine-grained value
(such as a string or small HTML
chunk) is defined, users can make direct requests for that little value
in their browsers. But chances are, those values were designed only for
XMLHttpRequest objects.
For example, “Periodically
Make a Remote Call” [Hack #61] uses the request object to
periodically get a string
representing the current date. It calls an action named increment, which looks like this in the
controller object: