Permalink
Browse files

Add flash messages to failed update and create actions

  • Loading branch information...
iain committed Jul 31, 2011
1 parent eeb33dc commit b1456045c9fa666a4e32ed06ea951dcaf25c5820
Showing with 25 additions and 0 deletions.
  1. +5 −0 app/controllers/application_controller.rb
  2. +12 −0 config/locales/responders.en.yml
  3. +8 −0 lib/application_responder.rb
@@ -1,3 +1,8 @@
+require "application_responder"
+
class ApplicationController < ActionController::Base
+ self.responder = ApplicationResponder
+ respond_to :html
+
protect_from_forgery
end
@@ -0,0 +1,12 @@
+en:
+ flash:
+ actions:
+ create:
+ notice: '%{resource_name} was successfully created.'
+ alert: '%{resource_name} could not be created.'
+ update:
+ notice: '%{resource_name} was successfully updated.'
+ alert: '%{resource_name} could not be updated.'
+ destroy:
+ notice: '%{resource_name} was successfully destroyed.'
+ alert: '%{resource_name} could not be destroyed.'
@@ -0,0 +1,8 @@
+class ApplicationResponder < ActionController::Responder
+ include Responders::FlashResponder
+ include Responders::HttpCacheResponder
+
+ # Uncomment this responder if you want your resources to redirect to the collection
+ # path (index action) instead of the resource path for POST/PUT/DELETE requests.
+ # include Responders::CollectionResponder
+end

0 comments on commit b145604

Please sign in to comment.