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

Commit

Permalink
Added debugger for development environment. Moved custom error attach…
Browse files Browse the repository at this point in the history
…ment code to Domain model [#35]
  • Loading branch information
cplotter committed Oct 9, 2008
1 parent 0b426ee commit cc0c50d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
10 changes: 2 additions & 8 deletions app/controllers/domains_controller.rb
Expand Up @@ -34,7 +34,7 @@ def create
begin
@domain = @zone_template.build( params[:domain][:name] )
rescue ActiveRecord::RecordInvalid => e
@domain = attach_errors(@domain , e)
@domain.attach_errors(e)
end
end
@domain.user = current_user unless current_user.has_role?( 'admin' )
Expand Down Expand Up @@ -92,11 +92,5 @@ 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
6 changes: 6 additions & 0 deletions app/models/domain.rb 100644 → 100755
Expand Up @@ -119,4 +119,10 @@ def after_create #:nodoc:
soa.serial = serial unless serial.nil? # Optional
soa.save
end

def attach_errors(e)
e.message.split(":")[1].split(",").uniq.each do |m|
self.errors.add(m , '')
end
end
end
8 changes: 8 additions & 0 deletions config/environments/development.rb 100644 → 100755
Expand Up @@ -16,3 +16,11 @@

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

begin
require "ruby-debug"
rescue LoadError
puts "+---------------------------------------------------+"
puts "| ruby-debug gem not installed, #debugger will fail |"
puts "+---------------------------------------------------+"
end

0 comments on commit cc0c50d

Please sign in to comment.