I have a Rails 2.1.2 site that only has html templates e.g. jobs.html.erb, so when I request a restful resource:
www.mysite.com/jobs/1
Ben's solution works.
Consider the responds_to solution, though. It's cleaner since it allows flexibility when you will inevitably need to open up an action for a JavaScript json or xml call. Then you won't have to add
skip_before_filter :allow_only_html_requests, :only => [:show]
I personally like the respond_to block; it's very descriptive.
respond_to do |wants|
wants.html
end
Any format not specified in the block will automatically cause a HTTP 406 Not Acceptable to be returned. That's nice.