#RubyOnRails - 18 March 2019
« Back 1 day
[02:23:39] Hackmeifyoucan: Write a function lucky_sevens?(numbers), which takes in an array of integers and returns true if any three consecutive elements sum to 7
[02:26:41] Hackmeifyoucan: def lucky_sevens?(numbers) index = 0 while index <= numbers.length num = numbers[index] if numbers[index] + numbers[index] + numbers[index]== 7 return true end index += 1 end end puts lucky_sevens?([2,1,5,1,0]) puts lucky_sevens?([0,-2,1,8]) puts lucky_sevens?([7,7,7,7]) puts lucky_sevens?([3,4,3,4])
[07:30:37] DaniG2k: I'd like to add a migration to ensure the `dependent: :restrict_with_error` gets checked at the database level
[07:31:49] sevenseacat: if you have a foreign key restraint, you won't be able to delete a record that has other records with FKs pointing to it
[07:32:30] DaniG2k: so I need to add something like `add_foreign_key :containers, :container_types, on_delete: :restrict` ?
[09:47:59] Spaceman77: Hello. I have an input form for two model objects. Let's call them model A and B. I have a requirement that if model A's attribute "Apple" is some value, then model B's attribute "Banana" should be present, otherwise there should be no validation.
[09:59:21] tbuehlmann: Spaceman77: yes, see https://guides.rubyonrails.org/active_record_validations.html#conditional-validation
[11:25:10] neozor: Hi! this is my first time using an IRC channel, i hope i can collaborate with the community around here. Have a nice day!
[12:05:39] ss942: https://github.com/lapinskik/paginated_documents/blob/master/lib/pagination_documents_patch.rb
[12:05:39] ss942: I'm writing Redmine plugin, and I wonder if when I do pagination in this place[13::], would it change a way things are grouped? I mean would it group all documents, or just all for each page of pagination?
[12:05:39] ss942: If the second answer is closer to true, any tips on how I rewrite this if part "documents.includes(:attachments, :category).to_a" is must have?
[13:38:24] pokalyis: Is there any other solution? Takes over a minute to boot up rails on my 2010 machine
[13:40:36] pokalyis: About to get a new machine as soon as I leave china. Right now I've to use this one
[14:18:12] DWSR: Hey all, I'm wondering if someone has a good pattern for this: I'm trying to create a Docker container for my company's Rails 5.0 app that uses Sprockets. I'm trying to precompile all the assets for a particular rev so that they can be included as part of the image. Unfortunately, this requires that I initialize the entire application which means I need a bunch of external services present, massively increasing the complexity of th
[14:18:48] DWSR: Is there any recommendations on a way to solve this? I fell down a Railties rabbit hole yesterday and found that we could create and declare initializer "groups", but didn't find details on that.