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
<FromGitter> <Brodan> so I'm trying to add additional fields to the generated User model, and I've added the necessary getters/setters to `user.cr`, as well adding the fields to the user in `user_controller.cr`, just like th granite docs say, but when `user.save` gets called its still not saving the new fields. the logs are showing `INSERT INTO "users" ("email", "hashed_password", "created_at", "updated_at")` but there are several other
<FromGitter> ... fields it should be saving. did i miss a spot?
<FromGitter> <Blacksmoke16> did you do `column my_field : String`?
<FromGitter> <Brodan> yep!
<FromGitter> <Blacksmoke16> are you sure?
<FromGitter> <Brodan> e.g. `phone_number : String`. does it need a trailing question mark like the other fields have?
<FromGitter> <Blacksmoke16> if its nillable yea
<FromGitter> <Blacksmoke16> otherwise no
<FromGitter> <Blacksmoke16> wait
<FromGitter> <Brodan> okay, its not nillable so i dont have it. but that column is *definitley* on th emodel
<FromGitter> <Blacksmoke16> can you share the code?
<FromGitter> <Brodan> sure let me push it real quick so as to not clog up this chat
<FromGitter> <Brodan> i just put the few relevant `User` files in it so far, since the repo is a mess and very much a work in progress
<FromGitter> <Blacksmoke16> 404
<FromGitter> <Brodan> ahh its private. just updated
<FromGitter> <Blacksmoke16> you just have `phone_number_confirmed : Bool = false`
<FromGitter> <Blacksmoke16> missing the `column` part
<FromGitter> <Brodan> Oh
<FromGitter> <Brodan> Omg
<FromGitter> <Blacksmoke16> which is a macro that actually registers it as a column and defines the getter/setter
<FromGitter> <Brodan> *facedesks*
<FromGitter> <Brodan> once again, thank you for helping me out with my stupid questions
<FromGitter> <Blacksmoke16> np
<FromGitter> <Brodan> but that getter/setter macro isnt supported by granit yet right?
<FromGitter> <Blacksmoke16> `column` defines one for you
<FromGitter> <Brodan> that was mentioned in the chat above? so like i still need to add `def phone_number=` and `def phone_number` for each column
<FromGitter> <Blacksmoke16> no
<FromGitter> <Brodan> ooooooh oh okay, i thought i needed that but that was just because i was missing the `column` part
<FromGitter> <Brodan> Oh i see, `password` defines them because they have custom logic to get/set
<FromGitter> <Blacksmoke16> right
_whitelogger has joined #amber
<FromGitter> <andrewc910> @Brodan As @Blacksmoke16 said, `column` will make the setters & getters. What I said before was doing `User.new(my params)` will NOT hit those setters. The data is inserted into the model behind the scenes. This doesn't matter if your setter is `@my_field = my_field` because that's exactly what granite does. If you look at the password= method in the Amber auth module, you'll see it's doing some other things. If
<FromGitter> ... you need to hit your actual setter, instantiate the object `User.new` then do `user.password =` or whatever. Make sense?
<FromGitter> <andrewc910> This is actually an issue with granite and will be fixed in the future but no eta right now
<FromGitter> <andrewc910> A good rule is if your setter is `@my_field = my_field` just pass it in during the object instantiation. If your setter does other things, like `password=` for auth, make sure to invoke it directly with `user.password =` so you know your specific setter was invoked.
<FromGitter> <Blacksmoke16> imo all of model instantiation needs refactored
<FromGitter> <andrewc910> Yeah I'm following the issue. You don't seem very happy about the current implementation. I prefer Jennifer.
<FromGitter> <Blacksmoke16> granite is the only one that supports annotations
<FromGitter> <Blacksmoke16> eventually ill prob roll my own ORM, but i cba atm