Permalink
Browse files

Validate params with help of a instance var to be able to

render the show template with the submitted result
  • Loading branch information...
1 parent eb6ccdb commit 598e1d99f4c8c8efd1ec81547dcfc1c844e97bca @vmoravec committed Dec 20, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 plugins/mailsetting/app/controllers/mailsetting_controller.rb
@@ -57,9 +57,9 @@ def show
def update
authorize! :write, Mailsetting
mail_params = params['mailsetting'] || params['mail'] #keep mail for backwards compatibility with old REST API
- new_settings = Mailsetting.new mail_params
- unless new_settings.valid?
- problem _(new_settings.errors.full_messages.join(', '))
+ @mail = Mailsetting.new mail_params
+ unless @mail.valid?
+ problem _(@mail.errors.full_messages.join(', '))
return
end
@@ -117,7 +117,7 @@ def create
def problem message
if request.format.html?
flash[:error] = message
- redirect_to :action => "show"
+ render :action => "show"
else #REST request
error = { "error" => { "type" => "ADMINISTRATOR_ERROR", "messsage" => message, "id" => "ADMINISTRATOR" }}
respond_to do |format|

0 comments on commit 598e1d9

Please sign in to comment.