Last active
January 1, 2019 22:16
-
-
Save edwardloveall/58b4121e4a44345d41ce075299ab5a34 to your computer and use it in GitHub Desktop.
follow form create! error
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
require "lucky_record" | |
class User < LuckyRecord::Model | |
table :users do | |
end | |
end | |
class UserQuery < User::BaseQuery | |
end | |
class Follow < LuckyRecord::Model | |
table :follows do | |
belongs_to from : User | |
belongs_to to : User | |
column accepted_at : Time? | |
end | |
end | |
class FollowForm < Follow::BaseForm | |
needs from_user : User | |
needs to_user : User | |
def prepare | |
from_id = from_user.id | |
to_id = to_user.id | |
end | |
end | |
class CreateFollow | |
def run | |
existing_user = UserQuery.new.id(2) | |
current_user = UserQuery.new.id(1) | |
FollowForm.create!(from_user: current_user, to_user: existing_user) | |
end | |
end | |
CreateFollow.new.run |
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
Error in lucky_scratch.cr:38: instantiating 'CreateFollow#run()' | |
CreateFollow.new.run | |
^~~ | |
in lucky_scratch.cr:34: no argument named 'from_user' | |
Matches are: | |
- FollowForm.create!(params, from_user : User, to_user : User) | |
- FollowForm.create!(from_user : User, to_user : User) | |
- Follow::BaseForm.create!(params, id : Int32 | Nothing = Nothing.new, created_at : Time | Nothing = Nothing.new, updated_at : Time | Nothing = Nothing.new, from_id : Int32 | Nothing = Nothing.new, to_id : Int32 | Nothing = Nothing.new, accepted_at : Time | Nothing | Nil = Nothing.new) | |
- Follow::BaseForm.create!(id : Int32 | Nothing = Nothing.new, created_at : Time | Nothing = Nothing.new, updated_at : Time | Nothing = Nothing.new, from_id : Int32 | Nothing = Nothing.new, to_id : Int32 | Nothing = Nothing.new, accepted_at : Time | Nothing | Nil = Nothing.new) (trying this one) | |
FollowForm.create!(from_user: current_user, to_user: existing_user) | |
^~~~~~~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment