Browse Source

refactor, dry

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
f15550b59c
  1. 6
      app/controllers/aaaas_controller.rb
  2. 4
      app/controllers/application_controller.rb
  3. 6
      app/controllers/as_controller.rb
  4. 6
      app/controllers/cnames_controller.rb
  5. 6
      app/controllers/mxes_controller.rb
  6. 6
      app/controllers/ns_controller.rb
  7. 9
      app/controllers/pages_controller.rb
  8. 3
      app/controllers/soas_controller.rb

6
app/controllers/aaaas_controller.rb

@ -15,11 +15,7 @@ class AaaasController < ApplicationController
# override to use :mx_records instead of :records assoc
def beginning_of_chain
if nested? && nested.association && nested.association.collection? && nested.association.name == :records
nested.parent_scope.aaaa_records
else
super
end
nested_via_records? ? nested.parent_scope.aaaa_records : super
end
# override, we make our own sti logic

4
app/controllers/application_controller.rb

@ -40,4 +40,8 @@ class ApplicationController < ActionController::Base
render :nothing => true if params[Settings.honeypot].present?
end
def nested_via_records?
nested? && nested.association && nested.association.collection? && nested.association.name == :records
end
end

6
app/controllers/as_controller.rb

@ -15,11 +15,7 @@ class AsController < ApplicationController
# override to use :mx_records instead of :records assoc
def beginning_of_chain
if nested? && nested.association && nested.association.collection? && nested.association.name == :records
nested.parent_scope.a_records
else
super
end
nested_via_records? ? nested.parent_scope.a_records : super
end
# override, we make our own sti logic

6
app/controllers/cnames_controller.rb

@ -16,11 +16,7 @@ class CnamesController < ApplicationController
# override to use :mx_records instead of :records assoc
def beginning_of_chain
if nested? && nested.association && nested.association.collection? && nested.association.name == :records
nested.parent_scope.cname_records
else
super
end
nested_via_records? ? nested.parent_scope.cname_records : super
end
# override, we make our own sti logic

6
app/controllers/mxes_controller.rb

@ -23,11 +23,7 @@ class MxesController < ApplicationController
# override to use :mx_records instead of :records assoc
def beginning_of_chain
if nested? && nested.association && nested.association.collection? && nested.association.name == :records
nested.parent_scope.mx_records
else
super
end
nested_via_records? ? nested.parent_scope.mx_records : super
end
# override, we make our own sti logic

6
app/controllers/ns_controller.rb

@ -15,11 +15,7 @@ class NsController < ApplicationController
# override to use :mx_records instead of :records assoc
def beginning_of_chain
if nested? && nested.association && nested.association.collection? && nested.association.name == :records
nested.parent_scope.ns_records
else
super
end
nested_via_records? ? nested.parent_scope.ns_records : super
end
# override, we make our own sti logic

9
app/controllers/pages_controller.rb

@ -1,13 +1,8 @@
class PagesController < ApplicationController
skip_before_filter :authenticate_user!
layout proc{|controller|
if request.xhr?
false
elsif user_signed_in?
'application'
else
'public'
end
return false if request.xhr?
user_signed_in? ? 'application' : 'public'
}
rescue_from ActionView::MissingTemplate do |exception|

3
app/controllers/soas_controller.rb

@ -11,9 +11,8 @@ class SoasController < ApplicationController
protected
# override to use :mx_records instead of :records assoc
def beginning_of_chain
super.readonly(false)
(nested_via_records? ? nested.parent_scope.soa_records : super).readonly(false)
end
# override, we make our own sti logic

Loading…
Cancel
Save