respond_to(:html, :xml)
Ok so it may not give you a huge performance boost, but if you’re obsessed with reducing the size of your code, this is a nice way to make a saving!
If you have a simple respond_to block in your controller that looks like this:
respond_to do |format|
format.html
format.xml
end
You can use this alternate syntax and save a few keystrokes..
respond_to(:html, :xml)
Ok so it may not give you a huge performance boost, but if you’re obsessed with reducing the size of your code, this is a nice way to make a saving!
1 comment
Comment on Shorthand alternative for respond_to by Anton Jenkins
April 9th, 2009 @ 10:51 – permalink
Leave a reply
You can use Markdown in your comment as well as plain HTML. You can use
<filter:jscode lang="ruby">and</filter:jscode>tags to surround code blocks (supported languages are css, html, javascript and ruby). Your email address will not be published.If your comment doesn’t appear immediately after posting it could have been marked as spam. Don’t worry: we regularly check for and approve incorrectly filtered comments so you shouldn’t have to wait too long for it to be shown.