Skip to content

Instantly share code, notes, and snippets.

@edwardloveall
Created January 21, 2019 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwardloveall/f53b9227f47a77c9997f13870bc63804 to your computer and use it in GitHub Desktop.
Save edwardloveall/f53b9227f47a77c9997f13870bc63804 to your computer and use it in GitHub Desktop.
abstract class Form(T)
def go(object : T)
end
end
class Thing
end
class ThingForm < Form(Thing)
end
ThingForm.new.go("foo")
# no overload matches 'ThingForm#go' with type String
class GenerateUsernamesForUsers::V20190120141952 < LuckyRecord::Migrator::Migration::V1
class User < BaseModel
table :users do
column username : String?
end
end
def migrate
UserQuery.all.each do |user|
new_username = user.email.split("@").first
User::BaseForm.update!(user, username: new_username)
puts "Generated username #{new_username} for #{user.email}"
end
end
def rollback
end
end
# no overload matches 'GenerateUsernamesForUsers::V20190120141952::User::BaseForm.update!', record: User, username: String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment