Use ActiveRecord#toggle! Instead of defining a new one

[ci skip]
parent 89ca576e
...@@ -44,7 +44,7 @@ class Admin::GeoNodesController < Admin::ApplicationController ...@@ -44,7 +44,7 @@ class Admin::GeoNodesController < Admin::ApplicationController
if @node.primary? if @node.primary?
flash[:alert] = "Primary node can't be disabled." flash[:alert] = "Primary node can't be disabled."
else else
@node.toggle! @node.toggle!(:enabled)
new_status = @node.enabled? ? 'enabled' : 'disabled' new_status = @node.enabled? ? 'enabled' : 'disabled'
flash[:notice] = "Node #{@node.url} was successfully #{new_status}." flash[:notice] = "Node #{@node.url} was successfully #{new_status}."
......
...@@ -39,10 +39,6 @@ class GeoNode < ActiveRecord::Base ...@@ -39,10 +39,6 @@ class GeoNode < ActiveRecord::Base
!primary !primary
end end
def toggle!
update_attribute(:enabled, !enabled)
end
def uri def uri
if relative_url_root if relative_url_root
relative_url = relative_url_root.starts_with?('/') ? relative_url_root : "/#{relative_url_root}" relative_url = relative_url_root.starts_with?('/') ? relative_url_root : "/#{relative_url_root}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment