#RubyOnRails - 09 August 2018
« Back 1 day Forward 1 day »
[00:56:58] lemur: The lemurs are now out in the wild: https://medium.com/@baweaver/creating-reducing-enumerable-an-illustrated-adventure-c6adfcc30d5b
[01:19:19] sevenseacat: because it generates a lot of unnecessary junk that I end up having to rewrite anyway
[01:21:53] sevenseacat: the amount of time they would save me would be either negligible or negative
[01:22:50] baweaver: Then again I also write out a quick manifest type file for bootstrapping new apps according to an idea
[01:33:24] Radar: mroutis: fun fact: getting started guide used to use scaffold until I rewrote to not.
[01:34:51] mroutis: (thanks for taking care of the docs, Radar, I've spent a lot of time reading them)
[01:35:54] sevenseacat: yeah. fun for an exercise, but really I spend so little time generating new swathes of code that it really doesnt matter
[01:49:14] gerep: Hi. I am using Devise and I want my admin user to be able to create new users. To achieve that, is it required for me to make my UsersController#new load the Devise view?
[01:49:46] gerep: I want to take advantage of Devise so I don't have to worry about validations, password etc.
[01:52:40] mroutis: gerep, I remember devise's wiki having some good content for that, https://github.com/plataformatec/devise/wiki
[01:54:11] sevenseacat: depending on your requirements, you might want to look at something like devise invitable - because your admins setting new user passwords and the like might be a bit weird
[01:55:57] mroutis: gerep, also, validations occur on the model (the weird line `devise :database_authenticatable, :registable, ...`)
[01:56:47] gerep: mroutis, I did but I could not find any, maybe I am being too specific while looking for it.
[04:27:34] tfitts: Anyone here using the fastjson_api gem from netflix? I'm wondering if there's a way to probably set the model type for records that use single table inheritance? ActiveModelSerializer did it automatically but I don't see anything about it for fastjson_api
[09:29:57] sunya7a: hi all. I'm having trouble with validating a new child record before allowing it and its parent to save. specifically, when using a custom method validator within the child model the newly created record fields are all nil and so I cannot validate any of the fields. Here's the relevant code: https://gist.github.com/sunya7a/6a14ed35cbfca5765688f940d614b33a please let me know if you want to see other parts that would help cleariify this
[09:42:37] sunya7a: dionysus69: i made a toy app to test the behavior, and as I expected, usually at that exact point the child element should have fields filled, except the id, since it is a new object and not saved yet. but in my app, everything is nil, which is confusing me
[09:43:11] sunya7a: if I let it continue though both the child and parent objects save correctly with all the information
[09:43:52] sunya7a: so it seems somehow the validator is run early? not sure why or how to delay it until the fields are filled in with the parameters coming from the form
[09:53:34] sunya7a: Andr3as: it simply creates the child object. somehow it fills in the information after the validator call
[09:53:57] sunya7a: dionysus69: i'm trying to formulate a better explanation...it's a bit complicated
[09:54:42] Andr3as: so you create the child and at your byebug the values are empty, if you move on the values are there?
[09:57:04] sunya7a: the order of events is: i submit the form and I don't see any db insertions before hitting my byebug within the validator. at this point self properties are all nil. then I continue and I see all the insertions into db and child is created including the join records
[09:58:35] sunya7a: I tried putting a byebug statement inside th econtroller and calling the update manually to see what happens...it also stops at the byebug line in the validator with self properties being nil
[10:01:43] sunya7a: dionysus69: hopefully this explains the issue: https://gist.github.com/sunya7a/b3d8377bec8b00684dcf3e3be0f6372a
[10:17:27] Psy-Q: let's say you're building a API following JSON-API, in order to update relationships, would you accept a POST or PATCH to e.g. authors/1/books with the changed relationships as payload?
[10:17:50] Psy-Q: the spec always talks about an explicit relationships URL but that seems cumbersome with rails
[10:37:04] lupine: http://help.rubygems.org/discussions/problems/32656-reporting-abuse-on-active-support ^^
[11:58:02] dionysus69: am I doing this right? initially I know it makes two queries one of them is for generating a cache_key, but I couldn't find a more efficient way to achieve this
[11:58:36] dionysus69: if I just use cache_key, it takes cache_key of all records, which is not efficient
[12:27:50] tbuehlmann: not sure I'd keep the caching in the model. I'd at least think about having it in the controller
[12:47:02] dionysus69: it's normal to have low-level caching in the model, it affects the model directly
[13:48:28] Sylario: Theory question : Why do service object are object and not class? THey have one method most of the time anyway? I don't see how it would be detrimental to have one public class method
[13:55:49] tbuehlmann: sylario: you don't have to use such "service classes/objects", it just settled to be some useful thing
[13:58:14] Sylario: I don't question the utility of service object, it's just that I was reading a post about them, and they insisted against on init+ 1 public method, and I started wondering why it needed to be an object, and it seems there is a consensus on having one action one service