All/Anyone,
Curious what the prevalent Rails idiom is for indicating the success/failure of a particular action to the end user?
For example, let's say you have a restful User resource and update is invoked on said User resource; once the update has completed and I've routed the user back to edit.html.erb - I'd like to indicate whether or not the action was successful (which one would say == the absence of errors).
That said, three approaches come quickly to mind:
if @user.errors.blank? then show 'success'. This doesn't work on the inital display of edit.html.erb
Update flash to indicate success/failure based on the results of @user.save/update_attributes. if flash[:status] == :success then show 'success'.
set an instance variable in the update action - much like flash - @success == true. if @success then show 'success'
Am I missing something? Perhaps there's a method on AR that I'm just not seeing? If @user.updated?
Thanks! Cory Wilkerson