Skip to content

Commit

Permalink
Validate params with help of a instance var to be able to
Browse files Browse the repository at this point in the history
render the show template with the submitted result
  • Loading branch information
Vladimir Moravec committed Dec 20, 2012
1 parent eb6ccdb commit 598e1d9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/mailsetting/app/controllers/mailsetting_controller.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def show
def update def update
authorize! :write, Mailsetting authorize! :write, Mailsetting
mail_params = params['mailsetting'] || params['mail'] #keep mail for backwards compatibility with old REST API mail_params = params['mailsetting'] || params['mail'] #keep mail for backwards compatibility with old REST API
new_settings = Mailsetting.new mail_params @mail = Mailsetting.new mail_params
unless new_settings.valid? unless @mail.valid?
problem _(new_settings.errors.full_messages.join(', ')) problem _(@mail.errors.full_messages.join(', '))
return return
end end


Expand Down Expand Up @@ -117,7 +117,7 @@ def create
def problem message def problem message
if request.format.html? if request.format.html?
flash[:error] = message flash[:error] = message
redirect_to :action => "show" render :action => "show"
else #REST request else #REST request
error = { "error" => { "type" => "ADMINISTRATOR_ERROR", "messsage" => message, "id" => "ADMINISTRATOR" }} error = { "error" => { "type" => "ADMINISTRATOR_ERROR", "messsage" => message, "id" => "ADMINISTRATOR" }}
respond_to do |format| respond_to do |format|
Expand Down

0 comments on commit 598e1d9

Please sign in to comment.