<FromGitter>
<hfjallemark> Any ideas what I am doing wrong here, can't seem to get JSON serialisation to work with my Granite model: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ It still includes the `updated_at` field and uses `created_at` instead of `posted` [https://gitter.im/amberframework/amber?at=5bd30f866e5a401c2dd30bf7]
<FromGitter>
<hfjallemark> It actually works on the other fields
<FromGitter>
<hfjallemark> Just not the created_at/updated_at
Jenz has joined #amber
<Jenz>
Anyone here?
<Jenz>
I ask, because Im on IRC, hence I won't get notified if anyone tags me with an anwer on gitter when Im not on
<Jenz>
Though when I see how well this chan is set up, I doubt you guys wouldn't know that :D
<Jenz>
As the channel is doubly logged, I'll just ask and check the logs later
<FromGitter>
<Blacksmoke16> o/
<Jenz>
Oh, well hello someone :D
<Jenz>
Question is: why are there so many node modules? Is there really any need for that?
<FromGitter>
<c910335> @hfjallemark What version of Granite?
<FromGitter>
<Blacksmoke16> sadly im not the best to ask about Amber, more of a Granite guy :p
* Jenz
:)
<FromGitter>
<Blacksmoke16> uh oh, did i break something
<FromGitter>
<Blacksmoke16> @hfjallemark i'll check it out when i get home tonight, i have hunch the annotations aren't getting applied....
<FromGitter>
<Blacksmoke16> however if you're on version `0.14.1` then it could be something else
<FromGitter>
<Blacksmoke16> should add some specs for the json/yaml option stuff....
Jenz has left #amber ["brb"]
<FromGitter>
<hfjallemark> I’m on 0.14.2.
<FromGitter>
<hfjallemark> And it seems I can’t add json options to relationships either, maybe related
<FromGitter>
<Blacksmoke16> try dropping down to `0.14.1`, to confirm my suspicions
<FromGitter>
<Blacksmoke16> and there isnt support for json_options on relationships, assuming you mean like `has_one :coach, json_options: xxx`
<FromGitter>
<Blacksmoke16> @hfjallemark specs pass fine on granite master, might be something else going on in your case
<FromGitter>
<Blacksmoke16> @hfjallemark As far as i can tell what you have should work
<FromGitter>
<Blacksmoke16> `TodoJsonOptions.order(id: :asc).select.to_json` (with same setup as before) => `[{"id":1,"task_name":"last todo"},{"id":2,"task_name":"first todo"},{"id":3,"task_name":"middle todo"}]`
<FromGitter>
<hfjallemark> I tried `Post.all` and `Post.find` too
<FromGitter>
<Blacksmoke16> let me try adding timestamp fields
<FromGitter>
<Blacksmoke16> like you have
<FromGitter>
<hfjallemark> But it seems it’s only the created and updated fields
<FromGitter>
<hfjallemark> The others work
<FromGitter>
<Blacksmoke16> that would have been nice to know :p
<FromGitter>
<hfjallemark> @hfjallemark ⏎ It actually works on the other fields ⏎ Just not the created_at/updated_at
<FromGitter>
<hfjallemark> :)
<FromGitter>
<Blacksmoke16> welp, guess i missed that ha
<FromGitter>
<hfjallemark> Hehe -- but re: relationships, is there a reason there is not support for it? Because right now there is no way to ignore the "user_id" field coming out in the json
<FromGitter>
<Blacksmoke16> did you try adding the option on the `User` model?
<FromGitter>
<hfjallemark> On the class or a specific field?
<FromGitter>
<Blacksmoke16> like on the field in the User class
<FromGitter>
<hfjallemark> Which field? Because it's the `user_id` field from the `Post` class that is coming, not actually something from the User class
<FromGitter>
<hfjallemark> And I haven't even declared a `user_id` field, it must be something created by Granite for the `belongs_to user : User` macro
<FromGitter>
<Blacksmoke16> its prob the FK to User table
<FromGitter>
<hfjallemark> So they get redeclared?
<FromGitter>
<hfjallemark> Yeah, was looking at that now
<FromGitter>
<Blacksmoke16> yea
<FromGitter>
<Blacksmoke16> hm
<FromGitter>
<Blacksmoke16> i have a fix, will write some specs and add it to the pr
<FromGitter>
<Blacksmoke16> basic im just not setting/updating the times if there isnt a corresponding `field` or `timestamps`
<FromGitter>
<hfjallemark> Ah, because they are not used for anything else?
<FromGitter>
<Blacksmoke16> yea
<FromGitter>
<Blacksmoke16> afaik at least
<FromGitter>
<Blacksmoke16> but up till now they were being set/updated even if you didnt declare them
<FromGitter>
<Blacksmoke16> which *might* break some people's apps if they were using them without declaring it as an actual field or using the timestamps macro
<FromGitter>
<Blacksmoke16> would give you more control over stuff, like consume a value in from_json but not include it when doing to_json
<FromGitter>
<Blacksmoke16> also looking for feedback :)
<FromGitter>
<Blacksmoke16> am 100% sure it works with granite, will have to read the custom annotation section in granite docs to apply the annotations tho