00:22
<
FromGitter >
<silentworks> I think Link might be a protected word in Crystal, i changed it to Post and the issue is now gone
01:11
<
FromGitter >
<drujensen> @silentworks interesting problem. Can you namespace your models `Blog::Link` to avoid the conflict?
01:20
<
FromGitter >
<silentworks> @drujensen I will try that tomorrow, I have gone with `Post` for now
01:20
<
FromGitter >
<drujensen> k
01:21
<
FromGitter >
<silentworks> Interesting are there any examples getting the current user logged in user to pass to another model in Amber?
01:22
<
FromGitter >
<silentworks> I am trying `post.user = current_user`, but this seem to yield nothing
01:22
<
FromGitter >
<drujensen> do you mean a 1 to many relationship?
01:22
<
FromGitter >
<drujensen> that should work
01:23
<
FromGitter >
<silentworks> Should this not work?
01:23
<
FromGitter >
<drujensen> it should. is the user logged in?
01:23
<
FromGitter >
<silentworks> yep
01:23
<
FromGitter >
<drujensen> checking...
01:25
<
FromGitter >
<silentworks> Ok restarting my dev server with that line in it and I am getting an error, which I am pretty sure is trying to tell me something, I just can't work out what
01:27
<
FromGitter >
<drujensen> this may be the standard union type
01:27
<
FromGitter >
<drujensen> question that new Crystal dev’s always run into
01:28
<
FromGitter >
<drujensen> let me check and verify and then I will explain
01:31
<
FromGitter >
<drujensen> Ok, I confirmed that this is the issue
01:32
<
FromGitter >
<drujensen> Heree is the deal. Crystal supports Union Types. current_user is of type `(User | Nil)`
01:32
<
FromGitter >
<drujensen> when it tries to assign the `id`, it will fail because the `Nil` type doen’t have a method or property of `id`
01:33
<
FromGitter >
<drujensen> so the fix it to check to see if `current_user` exists before assigning it
01:34
<
FromGitter >
<drujensen> you can use `current_user.not_nil!` to say “I know for sure this is not nil, go ahead and change the type to just `User`"
01:34
<
FromGitter >
<drujensen> but the better way is to check and see if it’s nil and then handle it appropriately
01:34
<
FromGitter >
<drujensen> something like this:
01:35
<
FromGitter >
<drujensen> hope this helps
01:35
<
FromGitter >
<silentworks> Ah thank you, that makes sense
01:36
<
FromGitter >
<silentworks> I am wondering how and where this could be made clear in the Amber docs
01:37
<
FromGitter >
<drujensen> If you ever do any Swift programming, you may be familiar with this idea
01:37
<
FromGitter >
<drujensen> This is more of a crystal language thing
01:37
<
FromGitter >
<drujensen> I think everyone new to Crystal will run into it
01:37
<
FromGitter >
<silentworks> Ah ok
01:37
<
FromGitter >
<drujensen> It took me some time to wrap my head around the Union Type concept
01:38
<
FromGitter >
<drujensen> but once you get it, you will be like, “what a f’ing great idea!"
01:38
<
FromGitter >
<drujensen> lol
01:38
<
FromGitter >
<silentworks> Btw `user` is not available in this controller, so is it ok for me to do `if current_user.not_nil`?
01:38
<
FromGitter >
<drujensen> you are creating a new local variable with `user = current_user`
01:39
<
FromGitter >
<drujensen> this code worked for me
01:39
<
FromGitter >
<silentworks> oh sorry I didn't read the code correctly
01:39
<
FromGitter >
<drujensen> its unwrapping the Union type and assigning it to `user`
01:39
<
FromGitter >
<drujensen> so then the local variable `user` is of type `User`
01:40
<
FromGitter >
<drujensen> you have removed the `Nil` type so now it will allow you to use it
01:40
<
FromGitter >
<silentworks> Yes that make sense, because if its nil it won't get assigned
01:40
<
FromGitter >
<drujensen> right
01:41
<
FromGitter >
<silentworks> Once again, thank you very much
01:41
<
FromGitter >
<drujensen> np
01:51
<
FromGitter >
<silentworks> Are there any full example amber app with auth available online?
01:55
<
FromGitter >
<drujensen> hhmm, not sure. Anyone have a good example for @silentworks ?
01:56
<
FromGitter >
<drujensen> If not, maybe you could help us write or build one?
02:00
<
FromGitter >
<drujensen> cool!
02:00
<
FromGitter >
<drujensen> that would be an awesome 12 week training program for Amber
02:01
<
FromGitter >
<drujensen> I need to drop off. heading to a bbq
02:01
<
FromGitter >
<silentworks> Have fun
02:02
<
FromGitter >
<drujensen> thanks. Hopefully someone else jumps on to answer questions.
02:04
<
FromGitter >
<silentworks> Hopefully I can work out the answers before asking questions. :-)
04:17
_whitelogger has joined #amber
10:23
feepbot has quit [Ping timeout: 245 seconds]
10:25
feepbot has joined #amber
11:20
_whitelogger has joined #amber
12:39
marenz has joined #amber
15:55
<
FromGitter >
... odes%2F2018%2F08%2F29%2Fa-quick-recap-and-plans-for-the-future%2F) is very true. We need to remember to balance our lives and keep priorities straight or things could go south.
18:14
marenz has quit [Ping timeout: 240 seconds]
18:17
marenz has joined #amber
20:02
marenz has quit [Ping timeout: 245 seconds]
21:49
vivus has joined #amber