Skip to content

Instantly share code, notes, and snippets.

@nessamurmur
Last active December 31, 2015 07:09
Show Gist options
  • Save nessamurmur/7952204 to your computer and use it in GitHub Desktop.
Save nessamurmur/7952204 to your computer and use it in GitHub Desktop.
This seems _bad_. But I've seen it ALOT.
class Template < ActiveRecord::Base
belongs_to :template_type
def some_method
if template_type == :type_1
# do type one things
elsif template_type == :type_2
# do type two things
else
# something else
end
end
end
class TemplateType < ActiveRecord::Base
has_many :templates
TYPES = [:type_1, :type_2, :type_3]
end
@nessamurmur
Copy link
Author

I'm going to flesh out both these examples more later...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment