faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
<FromGitter> <silentworks> I think Link might be a protected word in Crystal, i changed it to Post and the issue is now gone
<FromGitter> <drujensen> @silentworks interesting problem. Can you namespace your models `Blog::Link` to avoid the conflict?
<FromGitter> <silentworks> @drujensen I will try that tomorrow, I have gone with `Post` for now
<FromGitter> <drujensen> k
<FromGitter> <silentworks> Interesting are there any examples getting the current user logged in user to pass to another model in Amber?
<FromGitter> <silentworks> I am trying `post.user = current_user`, but this seem to yield nothing
<FromGitter> <drujensen> do you mean a 1 to many relationship?
<FromGitter> <drujensen> that should work
<FromGitter> <silentworks> ```post = Post.new post_params.validate! ⏎ post.user = current_user ⏎ if post.save``` [https://gitter.im/amberframework/amber?at=5b8b3b6df5402f32aac4f2c0]
<FromGitter> <silentworks> Should this not work?
<FromGitter> <drujensen> it should. is the user logged in?
<FromGitter> <silentworks> yep
<FromGitter> <drujensen> checking...
<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
<FromGitter> <drujensen> this may be the standard union type
<FromGitter> <drujensen> question that new Crystal dev’s always run into
<FromGitter> <drujensen> let me check and verify and then I will explain
<FromGitter> <drujensen> Ok, I confirmed that this is the issue
<FromGitter> <drujensen> Heree is the deal. Crystal supports Union Types. current_user is of type `(User | Nil)`
<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`
<FromGitter> <drujensen> so the fix it to check to see if `current_user` exists before assigning it
<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`"
<FromGitter> <drujensen> but the better way is to check and see if it’s nil and then handle it appropriately
<FromGitter> <drujensen> something like this:
<FromGitter> <drujensen> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b8b3e40f86b741b05f720e4]
<FromGitter> <drujensen> hope this helps
<FromGitter> <silentworks> Ah thank you, that makes sense
<FromGitter> <silentworks> I am wondering how and where this could be made clear in the Amber docs
<FromGitter> <drujensen> If you ever do any Swift programming, you may be familiar with this idea
<FromGitter> <drujensen> This is more of a crystal language thing
<FromGitter> <drujensen> I think everyone new to Crystal will run into it
<FromGitter> <silentworks> Ah ok
<FromGitter> <drujensen> It took me some time to wrap my head around the Union Type concept
<FromGitter> <drujensen> but once you get it, you will be like, “what a f’ing great idea!"
<FromGitter> <drujensen> lol
<FromGitter> <silentworks> Btw `user` is not available in this controller, so is it ok for me to do `if current_user.not_nil`?
<FromGitter> <drujensen> you are creating a new local variable with `user = current_user`
<FromGitter> <drujensen> this code worked for me
<FromGitter> <silentworks> oh sorry I didn't read the code correctly
<FromGitter> <drujensen> its unwrapping the Union type and assigning it to `user`
<FromGitter> <drujensen> so then the local variable `user` is of type `User`
<FromGitter> <drujensen> you have removed the `Nil` type so now it will allow you to use it
<FromGitter> <silentworks> Yes that make sense, because if its nil it won't get assigned
<FromGitter> <drujensen> right
<FromGitter> <silentworks> Once again, thank you very much
<FromGitter> <drujensen> np
<FromGitter> <silentworks> Are there any full example amber app with auth available online?
<FromGitter> <drujensen> hhmm, not sure. Anyone have a good example for @silentworks ?
<FromGitter> <drujensen> If not, maybe you could help us write or build one?
<FromGitter> <silentworks> This is currently what I am attempting to redo in Amber https://www.youtube.com/watch?v=7-1HCWbu7iU&list=PL23ZvcdS3XPLNdRYB_QyomQsShx59tpc-
<FromGitter> <drujensen> cool!
<FromGitter> <drujensen> that would be an awesome 12 week training program for Amber
<FromGitter> <drujensen> I need to drop off. heading to a bbq
<FromGitter> <silentworks> Have fun
<FromGitter> <drujensen> thanks. Hopefully someone else jumps on to answer questions.
<FromGitter> <silentworks> Hopefully I can work out the answers before asking questions. :-)
_whitelogger has joined #amber
feepbot has quit [Ping timeout: 245 seconds]
feepbot has joined #amber
_whitelogger has joined #amber
marenz has joined #amber
<FromGitter> <drujensen> > this an interesting write up about oss and collaboration, community building, etc https://solnic.codes/2018/08/29/a-quick-recap-and-plans-for-the-future/ ⏎ ⏎ @robacarp Finally had a chance to read this. This tweet (https://twitter.com/_solnic_/status/953578620617920513?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E953578620617920513&ref_url=https%3A%2F%2Fsolnic.c
<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.
marenz has quit [Ping timeout: 240 seconds]
marenz has joined #amber
<FromGitter> <silentworks> I am trying to install this shard into an Amber project https://github.com/mamantoha/humanize_time, but It seems it doesn't like something about the I18n Yaml parser
marenz has quit [Ping timeout: 245 seconds]
vivus has joined #amber