Skip to content
This repository has been archived by the owner on Mar 5, 2020. It is now read-only.

Commit

Permalink
Tweaked the error message display [#35]
Browse files Browse the repository at this point in the history
  • Loading branch information
cplotter committed Oct 9, 2008
1 parent 9ac97d0 commit 0b426ee
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/controllers/domains_controller.rb
Expand Up @@ -34,13 +34,13 @@ def create
begin
@domain = @zone_template.build( params[:domain][:name] )
rescue ActiveRecord::RecordInvalid => e
@domain.errors.add(e)
@domain = attach_errors(@domain , e)
end
end
@domain.user = current_user unless current_user.has_role?( 'admin' )

respond_to do |format|
if @domain.save
if @domain.errors.empty? && @domain.save
format.html {
flash[:info] = "Domain created"
redirect_to domain_path( @domain )
Expand Down Expand Up @@ -92,4 +92,11 @@ def change_owner
def restrict_token_movements
redirect_to domain_path( current_token.domain ) if current_token
end

def attach_errors(domain , e)
e.message.split(":")[1].split(",").uniq.each do |m|
domain.errors.add(m , '')
end
domain
end
end

0 comments on commit 0b426ee

Please sign in to comment.