Created
December 13, 2013 22:21
-
-
Save nessamurmur/7952431 to your computer and use it in GitHub Desktop.
It seems to me like it makes more since to just make use of the things rails does automagically...
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 AwesomeTemplate < Template | |
# We don't even care about custom behavior in this template. | |
# We just want to be able to identify it as a different type | |
end |
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 CoolTemplate < Template | |
def some_method | |
# special case for this particular type | |
end | |
def some_custom_method | |
# no other template needs this method | |
end | |
end |
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 Template < ActiveRecord::Base | |
# has some fields and stuff | |
def some_method | |
# handles default behavior | |
end | |
end |
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
With STI you would write a migration that adds a "type" fields to the templates table. Rails automatically sets the type to the subclass's name. BAM. You got types.