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
_whitelogger has joined #amber
feepbot has quit [Remote host closed the connection]
feepbot has joined #amber
<FromGitter> <Bherivy> Hi, I am new to Crystal and amber. I am looking forward to using Jennifer with Amber. I have checked the guide on https://docs.amberframework.org/amber/guides/models/jennifer, which says "Setup your database informationm," with not further information. Where should I do these configurations? I have tried to checked all the files under `config` directory, but the only thing I can found that relative to database is
<FromGitter> ... `database_url`, which is contains all the information to connect to a database.
<FromGitter> <Bherivy> I have figured out by myself 😂 It's the configuration file of Jennifer. So just using the same path as the first argument of `Jennifer::Config#read`
_whitelogger has joined #amber
<FromGitter> <sdzyba> there's an example app with amber and jennifer: https://github.com/imdrasil/amber_and_jennifer_sample_app
<FromGitter> <Bherivy> awesome! i will take a look, thanks!
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #amber
<FromGitter> <LilianAvry> Hello ! I am new to Crystal too ! I dont use amber but i am using Granite (with kemal) and i have some problems : I just cant update or delete something in my DB (create & get work). Has anybody got the same problem ?
<FromGitter> <LilianAvry> (im using this doc https://github.com/amberframework/granite/blob/master/docs/crud.md)
<FromGitter> <Bherivy> Hi @LilianAvry, it would be better if you can provide further information. like the error messages when you are tring to update/delete, with the code you are using.
<FromGitter> <LilianAvry> ```var code = "formatted";```
<FromGitter> <LilianAvry> `def patchUser(id, patch_user) ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5c46f4ea1cb70a372a1b0f3d]
<FromGitter> <LilianAvry> `def patchUser(id, patch_user) ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5c46f5071cb70a372a1b106d]
<FromGitter> <LilianAvry> ``
<FromGitter> <LilianAvry> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5c46f52c20b78635b6635ae1]
<FromGitter> <LilianAvry> this is the method i use to update something
<FromGitter> <LilianAvry> in src/controllers/UserController.cr:21: undefined method 'city=' for Nil (compile-time type is (User | Nil)) ⏎ ⏎ ``` user.city = patch_user[:city]``` [https://gitter.im/amberframework/amber?at=5c46f5621cb70a372a1b1392]
<FromGitter> <LilianAvry> and that is the error message i get when i try to compile
<FromGitter> <LilianAvry> (sorry im a noob with markdown)
<FromGitter> <LilianAvry> ```def patchUser(id, patch_user) ⏎ user = User.find id``` [https://gitter.im/amberframework/amber?at=5c46f8f91cb70a372a1b2776]
<FromGitter> <LilianAvry> this is the method i use to update something
<FromGitter> <LilianAvry> `src/controllers/UserController.cr:21: undefined method 'city=' for Nil (compile-time type is (User | Nil))`
<FromGitter> <LilianAvry> and that is the error message i get when i try to compile
<FromGitter> <Bherivy> @LilianAvry did you checked the value of id? ⏎ that error message means that `User.find id` returned `nil`, which means there is no record of `id`
<FromGitter> <LilianAvry> the value of `id` is correct and when i do `puts user.to_json` it returns correct informations from the DB `{"id":2,"name":"Bernard","age":21,"city":"Meylan"}`
<FromGitter> <Bherivy> it says that's a compile-time type, which means you have to make sure that `user` it not `Nil`
<FromGitter> <Bherivy> Crystal checks type when it compiles. It reports such error when the value *could* be `nil`
<FromGitter> <Blacksmoke16> @LilianAvry can do something like this
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5c47044dba355012a47bd30f]
feepbot has quit [Ping timeout: 250 seconds]
<FromGitter> <Blacksmoke16> if you are 100% sure you'll find a user with that id can just do `user = User.find! id` notice with the `!`
<FromGitter> <Blacksmoke16> but most of time better of checking for nil, which would indicate it doesnt exist
feepbot has joined #amber
<FromGitter> <LilianAvry> I tried your code and it works ! Thank you guys !
<FromGitter> <LilianAvry> I guess i still have a lot to learn about crystal
<FromGitter> <Blacksmoke16> 👌 np
<FromGitter> <eliasjpr> I think granite also has a find! Which will find a user or raise exception
<FromGitter> <Blacksmoke16> it does