0

I have a rails application in development that is taking a submitted form, sending it via a SOAP call using the SAVON gem, and is then receiving back an error message.

My question is: how do I pass that returned error message received in the model back to the controller where I can flash it?

Stephen Sprinkle
  • 1,015
  • 11
  • 14

1 Answers1

0

After hours of work, incredible frustration, and questioning the very foundations of what I know, it ended up being a typo.

For those who find their way here, this is one way to pass an error from your model to your controller, which is subsequently displayed in your view:

# In your model
self.errors.add(:base, "#{error.to_s}")

# In your controller
flash.now[:error] = "#{@user.errors.full_messages.to_sentence}"

# In your view
<%= content_tag(:div, flash[:error], :id => "flash_error") if flash[:error] %>
Stephen Sprinkle
  • 1,015
  • 11
  • 14