Skip to content

Instantly share code, notes, and snippets.

@chrisbloom7
Created July 22, 2013 17:20
Show Gist options
  • Save chrisbloom7/6055738 to your computer and use it in GitHub Desktop.
Save chrisbloom7/6055738 to your computer and use it in GitHub Desktop.
Override acts_as_list instance methods to save but skip validation
# config/initializers/acts_as_list_skip_validation.rb
module ActiveRecord
module Acts
module List
module InstanceMethods
# Move the item within scope, but skips validation
def move_within_scope(scope_id)
send("#{scope_name}=", scope_id)
save(false)
end
# Sets the new position and saves it, but skips validation
def set_list_position(new_position)
send("#{position_column}=", new_position)
save(false)
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment