Skip to content

Instantly share code, notes, and snippets.

@benshimmin
Created August 25, 2013 18:19
Show Gist options
  • Save benshimmin/6335400 to your computer and use it in GitHub Desktop.
Save benshimmin/6335400 to your computer and use it in GitHub Desktop.
Structs within a Rails project
# 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