put this in your controllers/application.rb
def initialize *args
ajax_actions = self.public_methods(false).grep(/^ajax/i)
unless ajax_actions.empty?
self.class.send :eval, <<-RUBY
verify :xhr => true,
:only => [#{ajax_actions.map(&:to_sym).join(', ')}],
:render => {:text => '405 XHR only', :status => 405 }
RUBY
end
super *args
end

Leave a Reply