automatic 'verify :xhr => true' for methods ending with _xhr

A before_filter is all you really need as that’s kinda what verify is anyway - a DSL for creating before_filters.

before_filter :protect_xhr_methods

def protect_xhr_methods

redirect_to :action=>“index” unless self.action_name.include?(“_xhr”) && request.xhr?


(I did not test this, and there’s a better way to test for _xhr in the action name, but I am really lazy right now :slight_smile: )

Is that something close?


While this is currently true, things have changed in Rails 2.0, and that’s where I’ve been working a lot lately. Thank you for reminding of this.

In Rails 2.0 you’ll no longer need to worry about that, as redirecting or explicitly rendering will stop the filter execution. (Yay!)

/me watches his Rails books depreciate even faster than last time


Just be glad you aren’t trying to follow the Agile book NOW, when Rails 2.0 is installed when you do a fresh installation :slight_smile: I feel really sorry for any newbies right now.