#RubyOnRails - 13 September 2018
« Back 1 day Forward 1 day »
[00:30:49] onecaesar: I'm looking to return an array of hashes from a form. Here is my example https://www.pastiebin.com/5b99aec2d8214
[00:31:22] onecaesar: The form has 2 hashes, each returning gender either male or female, I'm not sure how to get rails strong params to work with this as I'd like to keep adding more people to the group
[00:31:45] onecaesar: and to clarify, the form hash could should be able to go up to say 20 + members
[00:46:57] onecaesar: I just came across this where they suggest to use multiple forms - https://stackoverflow.com/questions/44513382/how-can-i-make-multiple-radio-button-groups-with-same-name
[00:47:40] onecaesar: Ideally I could get the POST request in one submit without having to use js / jquery to create a data object and then submit that
[01:36:20] frewsxcv: any suggestions for how to write an open source rails extension that relies on a cache?
[08:46:12] lessless_: Maybe something like Foo.includes(:sti_superclass).where("sti_table.type in ('type1', 'type2')").references(:sti_table).find(1) ?
[10:30:04] NL3limin4t0r: titon_: If you're running a development environment you're good to go with just puma. In production it's recommended to use a CDN or file server (like apache or nginx) to serve the assets.
[10:30:34] NL3limin4t0r: For detailed info have a look at: https://guides.rubyonrails.org/asset_pipeline.html#in-production
[10:34:05] NL3limin4t0r: titon_: If you have an API-only application you probably don't have any assets, thus no need to use a CDN or file server.
[11:26:36] titon_: NL3limin4t0r: that is what i'm wondering if nginx provides anything extra when you don't serve any static data and only a api
[11:47:48] Psy-Q: can i use the ActiveRecord validations standalone? like validate_numericality_of(this_var)?
[11:48:46] tbuehlmann: no, you'll need to include ActiveModel::Validations into your class in order to use them
[11:50:18] Psy-Q: ah, hrm. that's a bit inconvenient since what needs validation comes from a free-form JSON hash and depending on what's further up in the hash, different types of validations further down would need to trigger
[11:58:50] Psy-Q: hm, it's not even finding its is_hosting? method right inside the same class when i use if: is_hosting? as in the example. NoMethodError. weird.
[12:01:32] Psy-Q: yes, this could work. i do the branching up top in validates_with: MyFooValidator, if: is_giraffe?
[12:01:54] Psy-Q: and then i have many MyFooValidators that include just ActiveModel validations they need depending on the shape of the hash
[12:19:00] Psy-Q: ah, damn. that won't work. since it's nested and i can't do validates_numericality_of :my_hash['something_deep']['inside_of_me']
[12:23:02] Psy-Q: not quite sure, since the shape of the array is arbitrary and i only need to validate some elements that are guaranteed to be there
[12:23:55] Psy-Q: like configuration['mysql_database'] = true, that can only be true or false and not nil. and if it's true then there can also be configuration['mysql_database_name'] = 'foobar' which must be a string and unique
[12:24:33] Psy-Q: i just saw a gem called dry-validation that allows you to write a validation schema and then applies that to any data structure (ruby hash, whatever). maybe that's a better option
[12:26:05] Psy-Q: i thought the built-in validations might be best because.. they're built in :) but maybe they are simply wrong if you're not validating things that are actual fields on your model
[13:22:43] Psy-Q: i got it to validate nested things. now i just need to propagate the error messages properly upwards