#RubyOnRails - 30 April 2018
« Back 1 day Forward 1 day »
[01:37:31] lordpdd: I'm running a few (million) AR queries on irb/console and I notice that every iteration takes longer than the previous one, any idea how to check what's slowing down the process?
[02:02:15] fryguy: your loop might be holding onto records such that ruby can't garbage collect them
[09:41:32] Torrone: Hello, not sure if it's the right place to ask: I have a script in ruby that's supposed to run on an ubuntu server. I've made a bash script that launches the ruby script, very basic, and I've put an execution call in /etc/crontab. Whenever I run the bash script from the terminal, everything works fine. When I let crontab run it, however, I get an error (it seems to be missing a gem). What's going on? I've put the ruby version explicitly
[10:14:14] skroon: I'm running Rails 5.0.2 and I would like to upgrade to Rails 5.0.7 can I just update the Gemfile, and that's it? or is there additional steps to be taken?
[10:16:26] Radar: skroon: there's no API changes between those two versions. You will be fine to just bump the version.
[10:18:37] skroon: Radar: awesome, thanks for that info... where could I figure out if there were a api change?
[10:39:15] Radar: Rails has been pretty good recently with not breaking API compatibility in bugfix releases.
[11:03:08] i4: How can I get the index number of hash key? HASH.each_with_index ? Or maybe there some another option?
[11:16:58] i4: Radar, I want to compare which key with value in the Hash or Array == indexed number?
[14:31:51] drale2k_: @kapil___ : any decent db GUI client will show you the layout. I am using https://eggerapps.at/postico/
[14:33:34] drale2k_: I want to use ActiveStorage via REST API but i can't find anything about what kind of file type to send to the API
[14:37:35] havenwood: amperry: Considering using Trailblazer or have a question or just generally wanting to talk patterns?
[14:40:15] amperry: havenwood: tried implementing a service with tb, could not understand what was going wrong.
[14:41:22] amperry: now rewriting it as a "vanilla" service object, because at least I understand the calling semantics.
[14:46:16] bryanculver: I'm having an issue with dependent: :destroy not being acted on when updating a collection via assignment
[14:46:19] bryanculver: Example: https://gist.github.com/bryanculver/35e97d56988a00ac47560268e1e0e18e
[14:47:12] bryanculver: When I update the event's users (which is an has_many through), deleted associations aren't calling the has_many's has_one's destroy
[14:49:10] drale2k_: bryanculver: i think "dependent: :destroy" only kicks in when you call .destroy / .destroy_all on the record or collection
[14:50:01] bryanculver: Ok, so I'll have to cycle through the collection instead of the simple assignment operator
[14:54:32] nzst: bryanculver: http://guides.rubyonrails.org/association_basics.html#options-for-belongs-to-dependent
[15:00:43] nzst: idk, just poking around the docs http://guides.rubyonrails.org/association_basics.html#has-many-association-reference
[15:05:17] drale2k_: If i want to send files using ActiveStorage via a REST API endpoint from let's say an iOS app, do i need to mimic a html form? Or does ActiveStorage require something else? i am quite confused by this and all the tutorials i can find are using html forms to upload files
[15:16:28] nzst: bryanculver: So it seems like the assignment operator uses delete() not destroy() , so callbacks aren't called. http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-delete . What I can't find is the source for when deletes are called using the 'updating via assignment' method you were using. Sometimes there is a comment or commit trail that explains why, in this case why updating via assignment uses delete and not
[15:17:31] bryanculver: I'll have to see if switching everything to delete would work but I still doubt it would chain
[15:18:31] nzst: yea, i was poking around here https://github.com/rails/rails/tree/master/activerecord/lib/active_record/associations
[15:18:43] bryanculver: I don't use any X_destroy hooks so I could conceivably switch but that isn't how you'd expect it to work
[15:19:42] bryanculver: Gonna throw up a ticket in Github to see if I can get some reasoning answers (and maybe suggest a documentation update to showcase if it is expected)
[15:20:31] cjohnson: Does anybody know if in rails 4, background jobs have activerecord query cache enabled by default?
[15:21:05] cjohnson: sidekiq's docs make mention that "as of rails 5, its on by defualt" so that implies to me that before 5, it was not
[18:31:50] FrostCandy: is there a way to add an or to a .exist() ? Thing.exists(id: 10, action: nil || action: 0)
[19:33:34] Cache_Money: I have a column (string) with unique values and I'd like to select those records if that column value is within an array of strings. Is there an easy way to do this within my controller?
[20:45:44] cagomez: I have many Users and a User controller. I'd like to make a POST request to create an Item for each user. Is it RESTful to define a route such as `users/items` so I can post a list of User ID's to create Items for?