Skip to content

Instantly share code, notes, and snippets.

@quolpr
Created July 25, 2015 20:55
Show Gist options
  • Save quolpr/4cd08436297308bcbe9a to your computer and use it in GitHub Desktop.
Save quolpr/4cd08436297308bcbe9a to your computer and use it in GitHub Desktop.
class Likeable
validate :check_voteable
def check_voteable
has_assoc = model_type.constantize.reflect_on_all_associations(:belongs_to)
unless has_assoc.select{|name| name=='likeable'}
errors.add(:model_type, "This model is not voteable")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment