Created
February 21, 2014 15:49
-
-
Save vierarb/9136686 to your computer and use it in GitHub Desktop.
method_missing
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
class Speciality < ActiveRecord::Base | |
validates :code, presence: true | |
private | |
def method_missing(method, *args, &block) | |
if method.to_s =~ /^(.+)[?]$/ | |
run_code_comparation_method($1, *args, &block) | |
else | |
super | |
end | |
end | |
def run_code_comparation_method(attrs, *args, &block) | |
attributes['code'] == attrs | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment