Created
August 25, 2013 18:19
-
-
Save benshimmin/6335400 to your computer and use it in GitHub Desktop.
Structs within a Rails project
This file contains hidden or 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
# If you're using Structs within a Rails project (in particular), | |
# you might run into an error about "superclass mismatch for class". | |
# You can solve this quite simply. Rather than doing this: | |
class SimpleContact < Struct.new(:name, :role, :company) | |
def get_details | |
... | |
end | |
end | |
# You should do this: | |
SimpleContact = Struct.new(:name, :role, :company) | |
class SimpleContact | |
def get_details | |
... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment