#RubyOnRails - 30 August 2018
« Back 1 day Forward 1 day »
[00:00:29] pipework: I used active admin earlier this year with latent rails. I'll check on rails_admin
[00:01:10] massover: and in an attempt to teach, what does 'modifying frozen values' mean to me, in the scope of ruby or rails
[00:01:50] pipework: massover: When you mark an object as frozen, the values the object points to cannot be changed, the references can't be updated to new objects.
[00:03:04] massover: when would you do that? and could you perhaps link to an example line of code in an open source github repo?
[00:03:10] pipework: Ruby is pass by reference, so if you try to take an array `%w|hello my|.freeze` and modify the array object itself by modifying it rather than the string objects inside it, you will get an error. The strings won't be frozen but the object inside is.
[00:03:50] pipework: massover: Something that never changes is known not to change which means not only runtime protections but also optimizations.
[00:04:23] pipework: Here's a few concrete reasons, http://blog.honeybadger.io/when-to-use-freeze-and-frozen-in-ruby/
[00:05:59] pipework: the second inside was meant to be an outside, I'm a little delerious atm but if I've fudged I'm sure someone will tell you how it really do
[04:06:59] pipework: syndikate: Both are usable, however you only namespace within a class when the class is more appropriate in the first place.
[04:07:51] syndikate: Oh okay, yeah here its' just purely namespacing purpose with not much functionality of it's own, rather than define a self.table_name_prefix
[04:08:12] pipework: syndikate: For example, I may namespace within a class object (assigned to a constant or not) using private constants.
[04:38:33] syndikate: baweaver, pipework another thing though - I have a table_name_prefix for the intended tables (obviously), so as per Rails 5 convention is it okay to create a module and declare a self.table_name_prefix method in it?
[04:39:27] syndikate: I tried, it works. I wanted to know if it's a preferred approach to have such a method in module
[04:41:32] pipework: syndikate: Huh, I would actually imagine it wants a class to call .new on, TIL. That's amusing. I don't know that I'd do it unless there was some compelling reason to. You might confuse some people.
[04:48:04] nashant: https://gist.github.com/nashant/8a7e4e1dfc290561f9c6f04923ed24d1 Hey all. I'm pulling my hair out over how to get this working. I've got a guest_events table with id, guest_id, event_id and response. I have a multiple select in a form which I want to take response as the selected value. Currently if I deselect events then they get deleted, I want it to set response false instead. The gist is a very much simplified version of wh
[04:51:07] syndikate: baweaver, pipework This is the kind of simplified setup I have now - https://hastebin.com/osixisafuk.rb
[04:57:22] syndikate: Sorry if any confusions were caused, I thank you guys' help. Just wanted to understand if I have any convention to follow
[05:09:17] nashant: pipework: I'm looking but I'm not sure how that helps. I think what I need is to either pass through ALL the select options with the selected/not value, or override the method that is used to update the guest_events to set response=false rather than delete
[06:36:26] Andr3as: anyone ever had this issue with rails and js? https://stackoverflow.com/questions/52000505/rails-render-as-js-toggle-modal-unrecognized-expression
[06:39:51] Andr3as: well, at the end of the day it sends this $('#mainModal').modal('toggle'); in the update.js.erb and chrome argues Uncaught Error: Syntax error, unrecognized expression:
[06:40:18] Andr3as: and i dont know why.. i can execute the same thing from the console and it does work just fine
[06:44:00] sevenseacat: its hard to diagnose when you've posted a syntax error but you say other code in the file (which you've left out?) works
[06:44:51] Andr3as: no, i say the exact same code which does not work from within update.js.erb work when i post it into the console
[06:45:03] sevenseacat: > however - it does actually do what its supposed to do, it closes the modal and does the other stuff (updating the row, showing the flash message) which isnt included in the js.erb file for clearity's sake...
[06:45:37] Andr3as: i wanted to make it easier to read.. and omited the rest of the code which also works
[06:46:04] sevenseacat: where is this other code that works located? in the update.js.erb file? before/after that modal line?
[06:46:40] Andr3as: and it also works from within the update.js.erb but it still throws that error and after the error, chrome wont deal with js anymore (as expected, unfortunately)..
[06:50:35] Andr3as: well, when it doesnt work with the toggle alone..(?) how could it matter how my final js.erb looks like?
[06:53:21] Andr3as: what shall i say to this... i just want to clearify that the whole thing does not work with the toggle alone.. to keep things simple.. you guys argue its too much code but ask for more.. anyway.. its ok.. i look somewhere else
[06:56:45] sevenseacat: what does the update.js.erb file that gets sent to the browser look like? after ERB processing
[07:00:50] Andr3as: dev tools network tab looking like this https://www.screencast.com/t/Mf79ZSiiKuAX
[07:02:11] sevenseacat: sounds like you've found a massive bug in rails, if all the other code in your update.js.erb file just disappears.
[07:05:47] Andr3as: i did that a thousand times... after that i took it out of the js.erb file, pasted it into the chrome console and it closes the modal without an issue
[07:12:22] Andr3as: fwiw, the error in the rubymine server console is an old one.. i scrolled up earlier and it doesnt scroll down automatically
[14:27:10] blindMoe: Has anyone ran into issues with rspec not using fallback translations with locales and complaining of missing translations even though they exist in the default locale?
[14:33:24] blindMoe: @sylario I saw an article on manually setting the locale with faker and it having issues but did not see anything about it causing the fallbacks to stop working
[15:40:04] blindMoe: @sylario I think we might have the same issue. My spec tests are running code that switches the current locale and also uses Faker.
[15:41:51] blindMoe: I already have 'config.i18n.default_locale = :en' in my environment/test.rb but that doesn't seem to help
[19:36:22] mrbubbles: I have 3 has_many relationships on a model, I'm just trying to wrap them in a key but it's not working :(
[20:09:43] beingjohnm: running brakeman on my app and getting the warning about mass assignment (https://brakemanscanner.org/docs/warning_types/mass_assignment/index.html). It is catching because I permit :account_id as a parameter for submission of some of my forms. I can't really think of a work around for that though. e.g. when creating a "transaction" I need to pass the account that the transaction is being created
[20:49:43] gthank: Anybody have some experience with backburner as an async job system? I'm having a bit of a problem (under certain circumstances, a worker can't reach the database, at which point it starts reserving oodles of jobs and they all eventually time out, because once it loses DB connectivity, it can't recover)
[20:50:31] gthank: To me, it seems like this is a case where I could just have the error handler do a Kernel.exit (or exit!) to kill the worker process, since they're all under process supervision and a new one will be spawned silently
[20:51:18] gthank: Except putting exit, abort, or exit! in the error handler doesn't actually seem to kill the process
[20:53:40] tycoon177: beingjohnm: you could have the forms submit to a nested route under the account, but i wouldn't worry too much about that as long as you run verifications that the user should be able to make those changes
[20:58:54] beingjohnm: tycoon177: good point. I should double check that it is looking up only the accounts the user has access to but I'm pretty sure it is.
[21:04:39] beingjohnm: tycoon177: definitely. I feel like I'm adhering to the framework will and not doing anything crazy but I like the additional data point.
[22:48:21] srruby: Question about rates: For remote RoR work, what might the $ range be ? I am in need of some consulting hours so I thought I might come in on the low end.
[23:00:15] baweaver: 40k/yr approximates to $20 an hour. $50 would be about 100k, though remember to double that number in context of companies that pay that much.
[23:01:07] baweaver: A Junior in the SF Bay Area would be around 100 to 120k with maybe 10 to 30k in options or bonus.
[23:02:02] baweaver: Then again by the time you get to Senior that goes up to characteristically a base of 150-200k and options that dwarf that amount if you're good.