Created
July 22, 2013 17:20
-
-
Save chrisbloom7/6055738 to your computer and use it in GitHub Desktop.
Override acts_as_list instance methods to save but skip validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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