-
-
Save edwardloveall/f53b9227f47a77c9997f13870bc63804 to your computer and use it in GitHub Desktop.
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
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 |
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 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