« Back to channel list

#RubyOnRails - 27 April 2017

« Back 1 day Forward 1 day »
[00:00:42] rakm_: has joined #RubyOnRails
[00:01:31] rakm_: has joined #RubyOnRails
[00:01:50] dblessing: has joined #RubyOnRails
[00:03:42] postmodern: has joined #RubyOnRails
[00:04:17] postmodern: where in gitub.com/rails/ are the db:* rake tasks defined?
[00:10:21] beingjohnm: has joined #RubyOnRails
[00:10:49] Radar: postmodern: activerecord.
[00:11:12] Radar: postmodern: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/railties/databases.rake
[00:12:55] postmodern: thank you, was looking in railties mistakenly
[00:14:30] brent__: has joined #RubyOnRails
[00:25:34] dblessing: has joined #RubyOnRails
[00:26:03] Rodya_: has joined #RubyOnRails
[00:41:43] harfangk: has joined #RubyOnRails
[00:44:03] Rodya_: has joined #RubyOnRails
[00:47:33] quirkycoders: has joined #RubyOnRails
[00:54:14] sevenseacat: has joined #RubyOnRails
[00:59:03] dblessing: has joined #RubyOnRails
[01:01:38] sunrunner20: has joined #RubyOnRails
[01:02:03] HoierM: has joined #RubyOnRails
[01:19:15] craysiii: is there a general consensus on the quality and usefulness of RubyMine?
[01:29:22] romeoh: has joined #RubyOnRails
[01:29:36] sevenseacat: don't think so. if it works for you, use it.
[01:30:29] jeffaustin81: has joined #RubyOnRails
[01:38:00] r3vDev: has joined #RubyOnRails
[01:38:31] sunrunner20: has joined #RubyOnRails
[01:50:16] duderonomy: has joined #RubyOnRails
[02:00:41] Jameser: has joined #RubyOnRails
[02:05:51] libastral: has joined #RubyOnRails
[02:26:29] Technodrome: has joined #RubyOnRails
[02:31:43] romeoh: has joined #RubyOnRails
[02:33:38] sunrunner20: has joined #RubyOnRails
[02:38:07] r3vDev: has joined #RubyOnRails
[02:40:39] uks: has joined #RubyOnRails
[02:43:15] Rodya_: has joined #RubyOnRails
[02:58:41] armando: has joined #RubyOnRails
[03:00:23] sandstrom: has joined #RubyOnRails
[03:12:41] sunrunner20: has joined #RubyOnRails
[03:18:21] cam27: has joined #RubyOnRails
[03:21:58] quazimodo: has joined #RubyOnRails
[03:23:28] gusrub: has joined #RubyOnRails
[03:37:36] bronson: has joined #RubyOnRails
[03:39:33] sunrunner20: has joined #RubyOnRails
[04:00:11] hndk: has joined #RubyOnRails
[04:02:02] romeoh: has joined #RubyOnRails
[04:22:41] sunrunner20: has joined #RubyOnRails
[04:23:44] morfin: has joined #RubyOnRails
[04:23:52] rgr_: has joined #RubyOnRails
[04:24:25] morfin: hello how caqn i write standalone daemon which use RoR application stuff (models etc)?
[04:36:29] Radar: morfin: what does this daemon do?
[04:48:19] sunrunner20: has joined #RubyOnRails
[04:55:40] srinidhi: has joined #RubyOnRails
[05:11:43] ferr: has joined #RubyOnRails
[05:13:24] patarr: has joined #RubyOnRails
[05:18:02] morfin: basically it checks emails using IMAP and if sender is one from list in Setting model it insert into messages table and put into Sidekiq queue to further processing
[05:18:44] morfin: I am not sure what's wrong with logger and signals. Seems like logger could not be used in trap context
[05:20:23] morfin: right now i do require_relative '../config/environment' in bin/mail_parser is that right thing to do?
[05:28:50] libastral: has joined #RubyOnRails
[05:29:55] sunrunner20: has joined #RubyOnRails
[05:32:51] dminuoso: !goodmorning
[05:32:51] helpa: おはよう ございます
[05:33:06] dminuoso: morfin: So which part of this needs anything from RoR again?
[05:34:37] dminuoso: morfin: At any rate, just use a Rails runner to run Ruby code from within the context of Rails. You can also simply manually load Rails if you want (this can make sense if you want to use your own daemon mechanism)
[05:34:52] romeoh: has joined #RubyOnRails
[05:35:37] morfin: which part?
[05:36:19] morfin: i use AR, configurations from Rails, also autoload workers to interact with Sidekiq
[05:37:16] ryakh: has joined #RubyOnRails
[05:39:29] dminuoso: morfin: You can use rails runners to get started without any overhead.
[05:39:41] ryakh: Hi, after upgrading to rails 5 I've encountered following weird behavior (it was working on rails 4) — Fundamental.joins(:company) now returns ArgumentError: wrong number of arguments (given 1, expected 2). But Fundamental.joins('INNER JOIN companies ON fundamentals.....) works. Does anyone know what might be the problem?
[05:40:36] sevenseacat: ryakh: can you gist the code and the full error
[05:40:46] dminuoso: morfin: and loading the rails app is as simple as just require'ing your environment.rb
[05:40:49] sevenseacat: because both of those snippets only give 1 argument, not 2
[05:46:55] sevenseacat: ryakh: please share code in the channel, not in private message. if the code cant be made public, you'll need to ask somewhere else for help.
[05:47:19] ryakh: sevencat: sorry I am sloppy with irc :-D https://pastebin.com/3LWj6XYR
[05:49:38] sevenseacat: whats postgres_ext ?
[05:51:02] sevenseacat: seems its not compatible with Rails 5
[05:51:46] ryakh: Oh; I'll try to remove it
[05:52:08] sevenseacat: well if you're using it, that will cause more problems
[05:52:27] ryakh: Well at least I'll know that it is causing problems
[05:52:32] ryakh: And could start from there
[05:54:12] ryakh: Yup thats it! Thanks a lot; will try to find a way around it now!
[05:55:54] dminuoso: postmodern: Just out of curiosity. When you chruby to another version, shouldn't it attempt to rehash?
[05:56:53] jeffaustin81: has joined #RubyOnRails
[05:57:24] sevenseacat: rehash? chruby just sets your path right afaik
[06:04:43] sunrunner20: has joined #RubyOnRails
[06:08:56] Technodrome: has joined #RubyOnRails
[06:12:19] cgfbee: has joined #RubyOnRails
[06:24:14] srinidhi: has joined #RubyOnRails
[06:33:40] alfiemax: has joined #RubyOnRails
[06:33:58] sunrunner20: has joined #RubyOnRails
[06:41:33] conta: has joined #RubyOnRails
[06:57:50] alfiemax: has joined #RubyOnRails
[07:03:12] romeoh: has joined #RubyOnRails
[07:09:14] r3vDev: has joined #RubyOnRails
[07:11:24] sunrunner20: has joined #RubyOnRails
[07:13:50] arBmind: has joined #RubyOnRails
[07:14:18] patarr: has joined #RubyOnRails
[07:17:11] pLaTo0n: has joined #RubyOnRails
[07:19:50] morfin: i think i broke ActionMailer
[07:21:37] morfin: i have mailer which has method parser_error(response, error: nil) ... end and when i call it i get error that there is only one argument but i call function with 2
[07:21:57] morfin: named arguments aren't supported?
[07:22:28] sevenseacat: morfin: show us your code and the full error? :)
[07:27:27] brent__: has joined #RubyOnRails
[07:29:15] morfin: https://gist.github.com/morfin60/0e83a7047a77e7853c5d53a3b4441194
[07:30:25] sevenseacat: morfin: you've defined a keyword argument but you're not calling it as one
[07:30:55] cgfbee: has joined #RubyOnRails
[07:31:26] morfin: so i always should write response:response
[07:31:28] sevenseacat: I think you want parser_error(error, response: response) or just remove the keyword part entirely
[07:31:36] morfin: nevermind
[07:32:45] sandstrom: has joined #RubyOnRails
[07:33:08] Arkentias: has joined #RubyOnRails
[07:33:26] sevenseacat: you're welcome.
[07:39:55] dminuoso: sevenseacat | rehash? chruby just sets your path right afaik
[07:40:11] dminuoso: Precisely that is the problem. :P
[07:40:23] sevenseacat: so there's nothing to rehash... what exactly is your problem?
[07:41:21] dminuoso: Let's say you use the rails binstub from your system ruby, chruby to another ruby and start using the rails binstub you will get an awkward scenario where it uses both rubies.
[07:42:20] cgfbee: has joined #RubyOnRails
[07:42:23] dminuoso: (It will invoke the binstub from your system ruby but use the chruby libraries)
[07:42:27] sevenseacat: you'll get a buggy situation, yes
[07:42:37] sevenseacat: this is why global binstubs are bad
[07:42:46] DoubleMalt: has joined #RubyOnRails
[07:43:16] dminuoso: If chruby triggered a rehash it would certainly avoid such scenarios transparently for the user.
[07:43:29] sevenseacat: maybe I'm misunderstanding what you mean by 'rehash'
[07:45:03] dminuoso: sevenseacat: bash caches binaries in PATH, they call resetting that cache 'rehashing'
[07:46:29] sevenseacat: even though the path can change? that sounds dangerous
[07:52:14] dminuoso: sevenseacat: Perhaps purposefully overloading PATH to force a "default" version was not considered or endorsed by the responsible bash developers?
[07:52:43] dminuoso: I'm really not sure. It's not a big deal if you are aware of this cache, but to the unexpecting user that kind of bug can be extremely frustrating.
[07:53:32] mdw: has joined #RubyOnRails
[07:55:51] tbuehlmann: I'm unaware of this cache and never had such a problem using chruby
[07:56:19] sevenseacat: i dont use bash, or global binstubs, so that would be why i havent seen it :P
[07:56:26] koneko: has joined #RubyOnRails
[07:56:27] mjora7: has joined #RubyOnRails
[07:56:53] arBmind: has joined #RubyOnRails
[07:57:23] blackmesa: has joined #RubyOnRails
[07:59:20] sunrunner20: has joined #RubyOnRails
[08:01:13] drale2k_: has joined #RubyOnRails
[08:01:33] Jameser: has joined #RubyOnRails
[08:02:14] postmodern: dminuoso, it rehashes after resetting or using. https://github.com/postmodern/chruby/blob/master/share/chruby/chruby.sh#L30-L60
[08:03:58] romeoh: has joined #RubyOnRails
[08:10:02] mikecmpbll: has joined #RubyOnRails
[08:11:36] drale2k_: has joined #RubyOnRails
[08:21:19] mikecmpbll: has joined #RubyOnRails
[08:32:40] sunrunner20: has joined #RubyOnRails
[08:33:29] Cork: is there a way to get the path of the current partial file?
[08:37:22] dionysus69: has joined #RubyOnRails
[08:37:37] marr: has joined #RubyOnRails
[08:41:58] Qchmqs: has joined #RubyOnRails
[08:46:00] r3vDev: has joined #RubyOnRails
[08:46:12] dangerousdave: has joined #RubyOnRails
[08:46:29] pLaTo0n: has joined #RubyOnRails
[08:48:38] sevenseacat: Cork: why do you need it? whats the end goal?
[08:49:03] Cork: sevenseacat: i want to load files relative to the partials location
[08:49:13] Cork: and the partial is rendered from several different controllers
[08:49:27] sevenseacat: typically you would rely on the defined view paths to handle that kind of stuff
[08:49:31] sevenseacat: got an example?
[08:49:33] Cork: (or more specifically several different views from several different controllers)
[08:50:02] Cork: not that would help more then what i just said
[08:50:28] Cork: i'm currently looking at using caller, but its a bit messy
[08:53:42] mdw: has joined #RubyOnRails
[08:58:33] mjora7: has joined #RubyOnRails
[09:01:18] mjora7: has joined #RubyOnRails
[09:04:03] sunrunner20: has joined #RubyOnRails
[09:14:50] patarr: has joined #RubyOnRails
[09:24:05] User458764: has joined #RubyOnRails
[09:27:42] beauby: has joined #RubyOnRails
[09:28:24] workmad3: has joined #RubyOnRails
[09:29:07] naftilos76: has joined #RubyOnRails
[09:32:35] adac: has joined #RubyOnRails
[09:33:00] adac: is it possible with sidekiq to write to both, a log file and STDOUT/STDERR?
[09:33:06] adac: If yes, how?
[09:33:44] naftilos76: has joined #RubyOnRails
[09:34:41] romeoh: has joined #RubyOnRails
[09:35:28] adac: http://stackoverflow.com/questions/26047790/sidekiq-logging-to-both-terminal-and-log-file
[09:35:33] adac: seems to work like that
[09:39:52] naftilos76: Hi, everyone. I am debugging a rails 4.2 app and playing with FF debugging tools. When something goes wrong in a controller i do "render "common/error", status: 422" . Now, error.js.erb is one tiny js view that simply contains a js alert("An error occured, pls see the log for more info..."); That works fine until i use the debugging tools to manually change the query string or the request body params. When i re-submit that request that i change
[09:39:53] naftilos76: its' params then the erro.js.erb view is still rendered but i get no js alert message. Does anybody have any idea why this happens?
[09:41:03] sunrunner20: has joined #RubyOnRails
[09:43:02] brent__: has joined #RubyOnRails
[09:45:37] soahccc: I think I'm getting screwed by timezone magic, I'm completely lost with this. I'm trying to use this method: https://github.com/mdp/rotp/blob/master/lib/rotp/totp.rb#L58
[09:46:36] soahccc: When I pass Time.now as 3rd argument it doesn't work, if I don't pass it at all it does but the default IS Time.now, no? what am I missing? results: https://gist.github.com/2called-chaos/2dff173f26887d57a64d32659d5afa11
[09:47:19] soahccc: Oh nvm, I'm stupid
[09:51:46] marahin: has joined #RubyOnRails
[09:52:49] marahin: Hello! What is the best option to add one more key to unique index in Rails5? I've seen both remove_index & then add_index again with new option, but I also have seen add_index_option. The migration that added the index looked like this add_index :model, [:field1, :field2], unique: true, and I'd like to add field3 to it.
[09:53:39] sevenseacat: can you guarantee all of your existing data is unique?
[09:54:22] marahin: sevenseacat I want it to be unique in pairs.
[09:54:35] marahin: I am not sure what do you mean
[09:54:54] marahin: Well, for now - it is unique, but I want it to be uniqe also in scope of field3
[09:55:03] marahin: I don't know if it's answering your question or not :(
[09:55:22] sevenseacat: atm you have a unique index over two fields, meaning every row has a unique pair of fields. you add another field, it means every row has to have a unique set of three fields
[09:55:35] sevenseacat: if you can't guarantee your existing datamatches that, you can't add the index
[09:55:57] sevenseacat: and if you can, your data set is so small it doesnt really matter how you do it
[09:56:13] marahin: sevenseacat I see, well, the third field is a relationship column (so parent_object_id)
[09:56:28] marahin: so as far as I see it it should not break, only expand the uniqueness in scope of the parent_object
[09:56:49] marahin: if field1 and field2 are unique then adding field3 shouldn't break anything, should it?
[09:56:56] sevenseacat: depends on the data in the table
[09:57:03] universa1: and it changes the semantics
[09:57:36] marahin: well the data is not very valuable, so even if something breaks - I can just reset it.
[09:57:40] sevenseacat: oh I see what you're doing now
[09:57:46] sevenseacat: this is why i dont like fake examples
[09:57:59] universa1: now you can have a: foo, b: bar only once, but if you add c to the unique index, you can now have a: foo, b: bar, c: 1; a: foo, b: bar, c: 2, .... (a,b,c being the columns)
[09:58:23] marahin: universa1 correct.
[09:59:37] marahin: undefined method `add_index_option`
[09:59:45] marahin: ah, it's plural
[10:00:48] ravster: has joined #RubyOnRails
[10:01:30] marahin: universa1 sevenseacat thank you for your answers and pointing it out :)
[10:12:06] mdw: has joined #RubyOnRails
[10:12:34] marahin: Hmm... Even though the migration went through OK it did not rebuild the index. It still contains only :field1, :field2
[10:17:18] sunrunner20: has joined #RubyOnRails
[10:17:40] mdw: has joined #RubyOnRails
[10:22:23] mjora7: has joined #RubyOnRails
[10:48:26] v|sh: has joined #RubyOnRails
[10:48:29] HoierM: has joined #RubyOnRails
[10:53:10] sunrunner20: has joined #RubyOnRails
[11:02:53] quazimodo: has joined #RubyOnRails
[11:04:43] patarr: has joined #RubyOnRails
[11:04:58] romeoh: has joined #RubyOnRails
[11:12:23] justAllgood: has joined #RubyOnRails
[11:24:29] justAllgood1: has joined #RubyOnRails
[11:28:04] sunrunner20: has joined #RubyOnRails
[11:47:09] sunrunner20: has joined #RubyOnRails
[11:57:50] hndk: has joined #RubyOnRails
[11:58:50] cam27: has joined #RubyOnRails
[12:02:35] bahamas: has joined #RubyOnRails
[12:03:12] lord4163: has joined #RubyOnRails
[12:05:07] bahamas: hello. I have a form that a user fills in to create their profile. on this form I have two fields of the type terms of service. that means the user needs to tick them, so they can create the profile. on the Profile model, I put validates :field, acceptance: true , on: :create for both fields. however, even if I leave the boxes unticked, I can still create the profile. what could I be doing wrong?
[12:05:40] quirkycoders: has joined #RubyOnRails
[12:06:59] r3vDev: has joined #RubyOnRails
[12:09:46] srinidhi: has joined #RubyOnRails
[12:10:59] blackmesa: has joined #RubyOnRails
[12:12:01] morfin: and i have other question - initializers works not as i expect with Sidekiq
[12:21:47] quirkycoders: has joined #RubyOnRails
[12:27:14] sunrunner20: has joined #RubyOnRails
[12:31:49] sheepman: has joined #RubyOnRails
[12:32:19] morfin: is there way to reload initializer after code reload?
[12:35:23] dangerousdave: has joined #RubyOnRails
[12:35:25] romeoh: has joined #RubyOnRails
[12:39:33] pupsicle: has joined #RubyOnRails
[12:41:26] Ergo: has joined #RubyOnRails
[12:46:10] bahamas: is there a way to check in a form that it's rendered in the /new path?
[12:51:26] rkellermeyer: has joined #RubyOnRails
[12:57:07] hashrocket: has joined #RubyOnRails
[12:59:04] tbuehlmann: bahamas: most of the time you rather want to check if the form object is a new_record? or persisted?
[12:59:16] tbuehlmann: but what's your actual usecase? why do you need to know?
[13:02:03] dangerousdave: has joined #RubyOnRails
[13:04:00] koneko: has joined #RubyOnRails
[13:06:02] sheepman: hi all, I'm trying to think of the best way to allow a kinda multi-way search if that makes sense? So for instance I think a DB table (or maybe key value store?) which has things like "SD Padres" which has an assiociation with "San Diego Padres" so if i do a lookup for "SD Padres" it returns "San Diego Padres" and vice versa... make sense?
[13:06:23] sheepman: key value seems silly as i'll have lots of keys that don't feel necessary
[13:08:05] bahamas: tbuehlmann: I want to display two checkboxes in the style of terms of service. since I'm putting them in _form, I only want to show them when a profile is created
[13:09:11] tbuehlmann: bahamas: right, I'd check like this then: if form.object.new_record? …
[13:09:24] tbuehlmann: (or @profile.new_record?, whatever you prefer)
[13:09:36] tbuehlmann: new_record? returns true if the record is new and not yet persisted in the database
[13:10:27] bahamas: tbuehlmann: @profile.new_record? works, thanks!
[13:11:00] bahamas: I have one other issue. the form doesn't display errors when I don't check the boxes. if I leave out other fields, it displays errors for them
[13:12:11] rfoust: has joined #RubyOnRails
[13:13:12] sunrunner20: has joined #RubyOnRails
[13:15:01] bahamas: are form errors displayed automatically by Rails or do I need to do anything?
[13:17:05] bahamas: tbuehlmann: ?
[13:18:59] Technodrome: has joined #RubyOnRails
[13:19:33] mdw: has joined #RubyOnRails
[13:21:42] tbuehlmann: that depends. if you use a scaffolded view, errors are displayed automagically. but as you can create the profile, the validation might just not work
[13:25:08] tbuehlmann: bahamas: can you provide a gist with the server log that shows the creating request/response?
[13:26:02] sandstrom: has joined #RubyOnRails
[13:27:44] bahamas: tbuehlmann: in my case, I have a _form.html.erb. this has all the fields of the form. it uses bootstrap_form_for(profile, config) do |f| then f.check_box and so on. I will paste the log
[13:28:53] bahamas: tbuehlmann: https://gist.github.com/LucianU/16c84cdb6031f1b6c6138c66042acf63
[13:29:07] bahamas: is that what you asked for?
[13:29:25] mikecmpbll: how do i make a method available to fixture files?
[13:30:17] tbuehlmann: bahamas: yep. so, what are the names of those two acceptance fields?
[13:31:14] mordof: has joined #RubyOnRails
[13:31:27] pupsicle: has joined #RubyOnRails
[13:31:35] bahamas: tbuehlmann: :political_affiliation and :read_code_of_conduct
[13:32:02] tbuehlmann: they are both "0", so I assume unchecked?
[13:32:53] bahamas: so I should see in the form some error about them needing to be checked. that's what I expect, at least
[13:33:17] tbuehlmann: can you gist your profile model?
[13:35:05] bahamas: tbuehlmann: https://gist.github.com/LucianU/4c7278715da1b6c782cf27bb0395fa71
[13:37:13] tbuehlmann: looks good to me. in a rails console, what happens when you do the following? Profile.create(political_affiliation: "0").errors
[13:37:59] blackmesa: has joined #RubyOnRails
[13:38:11] mordof: https://github.com/mordof-work/test_environment trying to resolve a "stack level too deep" issue - this comes from just running Agency.create name: "agency" (the name part is important, because of the update_node callback in agency.rb)
[13:38:32] DLSteve: has joined #RubyOnRails
[13:39:02] mordof: in node.rb - if i comment out the has_one relationships, everything works. I'd lose the relationship back to the owner though.. so I want to resolve the issue, not just take away the relationships
[13:39:12] mordof: does anyone have any idea why this would be happening? this doesn't make sense to me
[13:39:22] bahamas: tbuehlmann: #<ActiveModel::Errors:0x00000004c574f8 @base=#<Profile id: nil, full_name: nil, nick_name: nil, email: nil, contacts: nil, location: nil, photo: nil, curriculum: nil, description: nil, urls: nil, title: nil, workplace: nil, tags: nil, skills: nil, status: 0, flags: 0, created_at: nil, updated_at: nil, hidden_tags: nil, skill_wish_list: nil, notes: nil>, @messages={:full_name=>["can't be
[13:39:28] bahamas: blank"], :nick_name=>["can't be blank"], :email=>["can't be blank", "is invalid"], :political_affiliation=>["must be accepted"]}, @details={:full_name=>[{:error=>:blank}], :nick_name=>[{:error=>:blank}], :email=>[{:error=>:blank}, {:error=>:invalid}], :political_affiliation=>[{:error=>:accepted}]}>
[13:41:22] tbuehlmann: looks good! so the profile shouldn't save, right?
[13:42:07] tbuehlmann: now, what's the problem? is the profile being created even when the checkboxes are not checked? or are there simply no errors displayed and the profile is not created?
[13:43:27] Leonardo_0112: has joined #RubyOnRails
[13:44:40] bahamas: tbuehlmann: the latter
[13:45:53] patarr: has joined #RubyOnRails
[13:46:05] bahamas: tbuehlmann: here's the form. maybe it holds any clues https://gist.github.com/LucianU/dc6f48a2794f3d8ea9516ca89acedeab
[13:47:03] bachmann: has joined #RubyOnRails
[13:47:40] sunrunner20: has joined #RubyOnRails
[13:48:00] tbuehlmann: oh, okay, got the question wrong then. when you submit the form and it is rerendered, can you check if the source code for the checkboxes have changed somehow?
[13:48:22] tbuehlmann: also, where do you expect to see the error? at the top of the form or near the checkbox?
[13:49:43] bahamas: tbuehlmann: what do you mean by the source code of the checkboxes changing? I expect to see the error around the fields, like it happens with the other fields
[13:50:33] tbuehlmann: does it work with other checkboxes?
[13:51:04] bahamas: on this form there are no other checkboxes, if that's what you're asking
[13:52:27] bahamas: btw, I wrote <%= f.error_summary %> and it's showing me the errors for the two fields "X must be accepted". so I assume this form treats checkboxes differently and doesn't display errors near them
[13:53:13] tbuehlmann: right, possible that the form doesn't show errors for checkboxes
[13:53:22] tbuehlmann: what gem do you use for this bootstrap_form_for?
[13:54:35] bahamas: tbuehlmann: https://github.com/bootstrap-ruby/rails-bootstrap-forms
[13:55:53] quirkycoders: has joined #RubyOnRails
[13:57:10] Jameser: has joined #RubyOnRails
[13:58:43] tbuehlmann: can you check if the form group surrounding the checkboxes has a has-error class?
[13:58:54] |RicharD|: has joined #RubyOnRails
[13:59:28] |RicharD|: guys something really weird happens...I've created a new rails project with postgresql like db driver
[13:59:41] |RicharD|: and when I run db:create
[14:00:22] |RicharD|: it create the databases but already with some tables of a old project and with data in it too!!! (the project have completely different names)
[14:00:39] fryguy: what's the contents of your database.yml file
[14:00:53] bahamas: tbuehlmann: I don't understand how it should look like. should I declare it? btw, I realized something about errors of the other fields. there's no error displayed. it's just that the label, help and input border become red
[14:01:21] romeoh: has joined #RubyOnRails
[14:02:19] |RicharD|: fryguy: is the normal database.yml, I've added only username and password(of the new user create specifically for this project) under default section
[14:02:43] fryguy: |RicharD|: and what is the database name used in database.yml
[14:02:59] bahamas: tbuehlmann: actually, I was wrong. the error replaces the help message
[14:03:46] |RicharD|: fryguy: mylog is the name
[14:04:03] |RicharD|: the older project was something like: superlist
[14:04:20] fryguy: |RicharD|: and how are you connecting to the database to observe this overlap
[14:05:03] |RicharD|: phppgadmin but i see it also in the scheme
[14:05:10] |RicharD|: generated by rails when I run the migrations
[14:05:26] fryguy: in what scheme
[14:05:32] LyndsySimon: I'm working on a project where we're using ActsAsTenant for multitenancy. Each tenant is representative of a corporate customer for the application. Each tenant also has departments underneath it. I've created a config framework to handle the fact that there are feature flags and configurable settings and such that need to differ between the global default,
[14:05:32] LyndsySimon: the value for a tenant, and somethings a different value for a single department within a tenant.
[14:06:45] LyndsySimon: I've written a helper method that works similarly to Rails' native I18n `t()` - I called mine `c()`. I can easily grab the current tenant by calling `ActsAsTenant .current_tenant`, but I'm trying to figure out a way to consistently determine the current department.
[14:07:41] LyndsySimon: The vast majority of the actions serve only a single department. In those cases, it's easy enough to set an instance variable (`@department`) and use that. The problem I'm running into is that I'd like to make this functionality more transparent to the developer.
[14:07:51] sandstrom: has joined #RubyOnRails
[14:07:52] |RicharD|: fryguy: here you go: https://gist.github.com/inchr/e704c43894bea32da36cdf710ca22564
[14:08:08] |RicharD|: (keep in mind t hat is a project created like 10min ago)
[14:08:27] Technodrome: has joined #RubyOnRails
[14:08:32] tbuehlmann: bahamas: ah, great
[14:08:34] fryguy: |RicharD|: that doesn't show us what's wrong
[14:09:05] bahamas: tbuehlmann: I found the answer. I had to wrap each checkbox in its own form group. now that I've done that, errors are displayed around each checkbox
[14:09:05] |RicharD|: I know but is just for says: it's impossibile that I've created these tables
[14:09:11] bahamas: tbuehlmann: thank you for your help!
[14:09:14] |RicharD|: I've tried also to start a new project, same problem
[14:10:02] tbuehlmann: bahamas: you're welcome!
[14:10:16] LyndsySimon: My ideal use case is to override `render`, so that a call to `<%= render 'my_partial' %>` would first check to see if `_my_partial.<tenant_id>.<department_id>.html.erb` exists, then `_my_partial.<tenant_id>.html.erb`, then `_my_partial.<department_id>.html.erb`, then finally default to rendering `_my_partial.html.erb` iff the more specific partials don't
[14:10:18] fryguy: |RicharD|: how are you starting a new project
[14:10:26] LyndsySimon: %s/exit/exist
[14:10:43] |RicharD|: rails new NAME -d=postgresql
[14:11:05] fryguy: what's the contents of your template0 and template1 databases
[14:11:32] LyndsySimon: One thought I had in this process is that I'm not aware of a way to specify the "primary object" for a view, be it a query or a model instance. In rspec, there is the concept of `subject`. Is there any analogue for `subject` in a view
[14:12:41] |RicharD|: how can i see that ?
[14:12:51] |RicharD|: (sounds like could be the problem)
[14:14:22] hotpancakes: has joined #RubyOnRails
[14:14:57] fryguy: use your database tool to connect to those databases and inspect
[14:15:09] ResidentBiscuit: has joined #RubyOnRails
[14:15:34] ResidentBiscuit: has joined #RubyOnRails
[14:26:23] urkle: has joined #RubyOnRails
[14:31:08] ravster: has joined #RubyOnRails
[14:31:45] mordof: turns out nulldb adapter does *not* have the same problem activerecord does
[14:40:20] armando: has joined #RubyOnRails
[14:41:14] romeoh_: has joined #RubyOnRails
[14:41:25] LyndsySimon: Restating my question from above: Is there something like `subject` in Rspec, but for views? Some sort of convention where the primary object is refernced?
[14:42:29] mordof: LyndsySimon: rendered?
[14:42:42] theunraveler: has joined #RubyOnRails
[14:43:06] LyndsySimon: mordof: Not sure. BRB, reading docs.
[14:43:17] mordof: LyndsySimon: https://www.relishapp.com/rspec/rspec-rails/v/2-0/docs/view-specs/view-spec based on that
[14:43:25] mordof: oh it's v 2.0
[14:43:29] mordof: might not exist anymore, heh
[14:43:50] mordof: it's still there as of 3.5 - should be ok
[14:43:56] LyndsySimon: mordof: Ah, no. I'm talking about an object accessible within a view normally, not when under test.
[14:44:20] LyndsySimon: I'm referring to Rspec only because `subject` works in examples the way I'd like this to work within a view.
[14:44:33] mordof: subject is an instance of something created in the spec though
[14:44:44] LyndsySimon: Yeah, the "object under test"
[14:45:16] mordof: right... but how would that work with a view when you have to trigger it to be rendered, AND you have to pass it variables?
[14:45:25] mordof: are you defining variables inside your view that you want access to?
[14:45:44] LyndsySimon: mordof: It's both more and less complicated than that :) Let me explain a bit more.
[14:45:44] |RicharD|: fryguy: ok I've fixed
[14:46:15] |RicharD|: was a mega mess (templates corrupted + 2 postgresql installed)
[14:46:31] LyndsySimon: Pretend I've got a magical concern that tells me if the current model instance is "good", or "evil". I include that concern in my `ApplicationRecord`, so it's by extension included in all my models.
[14:47:27] srinidhi: has joined #RubyOnRails
[14:47:43] LyndsySimon: In my controller, let's say I've assigned the instance variable `@foo` to an instance of a model. In my view, I can use `<%= @foo.alignment =>` and it'll return either 'good' or 'evil'.
[14:49:00] srinidhi: has joined #RubyOnRails
[14:49:37] LyndsySimon: Now imagine that I want to create a view partial that is included on every page of my application that has the object's alignment as an overlay on the page. I can still call `@foo.alignment` of course, but on some pages there is no `@foo`. `FooController#show` sets `@foo`, but `BarController#show` sets `@bar`.
[14:50:25] LyndsySimon: Make sense? I'm looking for a generic way to reference the primary object for the page, be it an instance of a model or a queryset.
[14:55:20] quirkycoders: has joined #RubyOnRails
[14:55:27] Technodrome: has joined #RubyOnRails
[14:57:57] jphase: has joined #RubyOnRails
[14:58:23] dblessing: has joined #RubyOnRails
[14:58:35] LyndsySimon: Clear as mud, I guess :)
[15:02:00] mordof: sorry - scrum meeting started
[15:03:41] mordof: LyndsySimon: that sounds like a responsibility of your controllers, not your views, to provide a generic object
[15:03:55] mordof: doing testing inside your views for which object is available sounds strange
[15:09:31] LyndsySimon: No testing is being done, lol.
[15:09:56] LyndsySimon: I'm asking if there is a Rails convention for naming the generic object. It's looking like there isn't.
[15:10:43] mordof: LyndsySimon: ah, i guess i was confused by your original question about if rspec had a 'subject' for views
[15:10:52] LyndsySimon: Yeah, I know. It's cool.
[15:11:01] LyndsySimon: 90% of why I'm asking about it is because I want to talk it out some.
[15:11:31] mordof: ACTION is now officially a rubber duck
[15:15:02] LyndsySimon: ACTION points out that mordof is needed by someone, and that's more than many people can ever say about themselves :)
[15:17:44] conta: has joined #RubyOnRails
[15:18:03] mordof: LyndsySimon: https://en.wikipedia.org/wiki/Rubber_duck_debugging
[15:18:21] LyndsySimon: Yep, I'm well aware of the concept :)
[15:18:29] mordof: wasn't entirely sure by your response
[15:20:28] mordof: now that it's settled down a bit.. i'm gonna ask a question
[15:21:41] mordof: https://github.com/mordof-work/test_environment Trying to resolve a stack-level too deep issue. (there's a README describing more). init.rb shows the code being tested in a begin/rescue.. the problem being when Agency.create name: 'name' happens, it does after_create :link_node (which creates a Node, and updates the agency with the id), then on Age
[15:21:41] mordof: ncy around_save, updates the node with details of the agency
[15:21:54] mordof: stack-level too deep occurs when I keep the has_one :agency on Node
[15:22:08] mordof: if i comment that out, everything works (i need that reference though for other code to function)
[15:22:14] mordof: the example works without it though
[15:23:48] polishdub: has joined #RubyOnRails
[15:24:06] mordof: my question is - why is this even happening?
[15:24:18] hotpancakes: has joined #RubyOnRails
[15:24:30] mordof: and how do i stop it from happening... I've got NullDB adapter in there, and there's no issue with NullDB (i imagine it replaces some active record calls)
[15:24:55] mordof: so there's a difference between NullDB, and either PG adapter, or ActiveRecord calls themselves that's prompting this issue
[15:25:21] mordof: at least, that's what i've got so far that i understand. i could be missing something
[15:27:07] mordof: I encountered this while upgrading from Rails 4 to Rails 5.0.2 (relevant code was using active(support|model|record) 4.1.5, hence the OLD env flag to choose between one or the other. The actual project in Rails 4 does not exhibit this issue either - but my test code does... which baffles me even further
[15:27:19] mordof: i'm not sure what to dig into at the moment to keep trying to resolve this
[15:29:34] justAllgood1: is there a popular gem for ruby 5 for DAC based permissioning? I found https://github.com/mdarby/restful_acl but it seems abandoned
[15:31:29] mordof: justAllgood1: if there is, we wrote our own system from scratch for nothing..
[15:31:46] justAllgood1: sounds promising
[15:32:10] mordof: i'm not sure if any of my team actually checked that much though, and even if there is - it might not have met certain requirements
[15:32:23] mordof: it'd just be unfortunate to find out afterwards that there was a gem for it, lol
[15:32:33] justAllgood1: yeah we're searching now, but I'm brand new to rails, so I don't know the gem landscape
[15:33:11] mordof: justAllgood1: https://rubygems.org/search?utf8=%E2%9C%93&query=permission maybe look through these?
[15:34:07] justAllgood1: yeah just a bunch
[15:34:18] justAllgood1: that's exactly what I'm doing, just was hoping to weed out my results
[15:34:21] justAllgood1: there are a LOT
[15:34:28] dblessing: has joined #RubyOnRails
[15:34:35] mordof: yuck. sorry i can't be more help
[15:35:04] knight33: has joined #RubyOnRails
[15:36:02] justAllgood1: ahh not a problem and you ahve been helpful
[15:36:19] justAllgood1: at least I know I'm not dumb and missing an ovb library
[15:36:23] justAllgood1: which can be found with a simple google
[15:36:37] mordof: true - since i did try a few times for that
[15:36:42] mordof: nothing came up that i could tell
[15:36:56] justAllgood1: sometimes I feel quite dumb, change a term just a tad and 1000 hits pop up
[15:37:01] justAllgood1: everyone like, lmgtfy.com
[15:37:04] Slogger: Mordof, I verified that your stack too deep is because the node tries to update the other object's foreign key form its has one, which seems to create infinite recursion because for some reason the _changed? methods in update node on the other model are always true
[15:38:32] hotpancakes: has joined #RubyOnRails
[15:38:42] mordof: Slogger: yeah. i figured that was the case. the part i'm still fuzzy on is why it's even bothering to try... it has no business attempting that
[15:39:05] mordof: as well as why the changed? methods are always true. both of those seem like situations that shouldn't be happening
[15:39:49] mordof: Slogger: i put in NullDB Adapter - and that works just fine
[15:40:08] mordof: i'm curious as to what nulldb adapter actually changes - if it overwrites anything active record
[15:40:15] mordof: i should dig through the source code of that to find out
[15:40:33] mordof: if it doesn't tough ActiveRecord at all, then the PG adapter is an important part of it
[15:41:15] beauby: Any way to locally modify the parser for a given MIME type from within a controller, for some actions?
[15:41:18] chouhoulis: has joined #RubyOnRails
[15:41:20] mordof: justAllgood1: https://github.com/matiasgagliano/action_access i don't know if it fits the DAC way of doing things
[15:41:33] Slogger: mordof: I get essentially the same behavior in mysql
[15:41:49] mordof: Slogger: ok - so it's likely nulldb does something to active record
[15:41:56] mordof: i'll confirm that though just so it's a definitive
[15:43:09] akshat: has joined #RubyOnRails
[15:43:10] Slogger: My theory is that because update_node is around_save, it never reaches whatever code in active record resets the "changed" or "previous" attribute values.
[15:43:34] Slogger: So every time it tries to save original values are still nil
[15:43:36] mordof: Slogger: shouldn't save do that?
[15:43:41] mordof: which happens in the yield
[15:44:36] Slogger: My guess is that there's some point in the save process where it happens, but I don't think it's necessarily happens in the part of save yielded to.
[15:48:34] mordof: you are correct
[15:48:42] mordof: after the yield - changes still lists everything going from nil to values
[15:48:44] mordof: each time
[15:49:18] mordof: sure - that explains how the node.save keeps getting called
[15:49:47] mordof: i'm pretty sure i read somewhere that it's intentional to have that
[15:50:03] mordof: someone updated from an around_save to a different hook, and the changes is no longer there
[15:50:08] mordof: ACTION checks a callback later on in the sequence
[15:50:17] mordof: .... nevermind.. it won't make it there..
[15:52:08] mordof: Slogger: right - it was the difference between after_save, and after_commit
[15:52:21] choke: has joined #RubyOnRails
[15:52:38] mordof: in between those two, rails updates all of the knowledge of what has changed
[15:52:45] chouhoulis: has joined #RubyOnRails
[15:56:18] justAllgood1: mordof: ++ thanks, I'll read now
[15:56:49] cagomez: has joined #RubyOnRails
[15:58:34] mordof: Slogger: NullDB adds in methods for interacting with tables, rows, cols, doing updates, inserts, queries, etc.. but those are the low level calls. it doesn't modify any of the callbacks, or going after #save or #save! or anything like that
[15:58:38] mordof: at least as far as i can tell
[16:00:15] mostlybadfly: has joined #RubyOnRails
[16:00:35] mordof: that removes my suspicion that node.save has been taken over by nulldb.
[16:02:24] [Butch]: has joined #RubyOnRails
[16:07:28] hotpancakes: has joined #RubyOnRails
[16:13:22] gusrub: has joined #RubyOnRails
[16:14:09] cagomez: has joined #RubyOnRails
[16:15:04] quirkycoders: has joined #RubyOnRails
[16:16:48] AzaToth: has joined #RubyOnRails
[16:23:43] gusrub: has joined #RubyOnRails
[16:27:51] hotpancakes: has joined #RubyOnRails
[16:29:56] JesseH: has joined #RubyOnRails
[16:33:22] JesseH: has left #RubyOnRails: ()
[16:49:01] duderonomy: has joined #RubyOnRails
[16:57:16] elsurudo: has joined #RubyOnRails
[16:57:52] elsurudo: Hi, so it appears that belongs_to associations are now the default in Rails. The default message is “must exist”. How can I change this message to something like “must be selected”?
[16:58:15] elsurudo: I tried something like this in my locale file with no luck:
[16:59:03] elsurudo: `en: activemodel: errors: models: order: attributes: branch: blank: "must be selected”` (with the proper indentation) where `order` is my model and `branch` is my association
[17:01:17] theunraveler: has joined #RubyOnRails
[17:02:07] Slogger: you can add optional: true to your belongs_to to make it not "must exist"
[17:02:14] elsurudo: I also tried with `activerecord` instead of `activemodel`
[17:02:27] hobodave: has joined #RubyOnRails
[17:02:29] Slogger: I guess you just mean changing the message, not the behavior?
[17:02:32] elsurudo: But I don’t want to make it optional, just change the error message
[17:02:36] elsurudo: Yeah exactly
[17:03:10] elsurudo: According to the i18n docs, I am doing the right thing
[17:04:02] Slogger: I think it's not blank, it's a different trigger
[17:04:44] Slogger: I'm wrong.
[17:07:50] pupsicle: has joined #RubyOnRails
[17:08:00] elsurudo: Found a workaround
[17:08:02] quirkycoders: has joined #RubyOnRails
[17:08:29] elsurudo: I added `optional: true` to the association, and simple added a presence validation myself, with the message I want
[17:08:42] elsurudo: making belongs_to required by default wasn’t a good idea, IMO
[17:09:29] mordof: elsurudo: i think it makes sense, but they should add the capability to make the message
[17:09:44] mordof: if something belongs to something else - the thing it belongs to should probably exist.. otherwise it's just orphaned
[17:10:03] mordof: change the message**
[17:10:15] mordof: elsurudo: might be worth making a ticket about that
[17:11:07] elsurudo: @mordof Generally I agree, but often `belongs_to` is more of a `has_one` (semantically-speaking), except that you want the FK in that particular model
[17:11:44] elsurudo: Perhaps you are right though, I probably just got used to writing the validation
[17:11:46] mordof: you can make it a has_one and change the keys
[17:11:51] mordof: if you want to do it the other way around
[17:11:51] gambl0re: has joined #RubyOnRails
[17:12:05] elsurudo: has_one means the FK has to be in the other model, i think
[17:13:05] mordof: treating a belongs_to like a has_one because the keys are the other way around though is, like this example demonstrates, dangerous. they aren't intended to be used interchangeably
[17:13:26] mordof: rails kinda decides how the flow should go on this one i think, even if in certain scenarios it doesn't make sense for the application
[17:13:48] mordof: double edge sword in that sense
[17:15:40] elsurudo: “even if in certain scenarios it doesn't make sense for the application” <— therein lies the rub. what if the thing I want “one of“ needs to be shared between multiple objects?
[17:16:24] mordof: shared how?
[17:16:39] mordof: what's the current situation you're seeing that doesn't fit?
[17:16:47] justAllgood: has joined #RubyOnRails
[17:17:02] mordof: wondering if maybe there's another way to set it up that would also make sense
[17:17:59] patarr: has joined #RubyOnRails
[17:18:11] elsurudo: by shared, I mean that the associated object is something like a “preset”
[17:18:37] elsurudo: so all orders have 0 or 1 colors, for example
[17:18:58] elsurudo: not possible to do this with a has_one on the Order side
[17:19:46] elsurudo: I think Rails simply treats belongs_to as meaning “this is the model where the FK” is. which is okay, i guess. but a bit of misleading terminology
[17:19:50] elsurudo: I’m used to it though
[17:20:16] mordof: why couldn't you put has_one :color inside Order?
[17:20:54] mordof: also referring to the fk, of course
[17:21:26] mordof: if you put has_one :color, does Color need to contain the order_id?
[17:21:33] elsurudo: that’s right
[17:21:37] elsurudo: that’s the issue
[17:21:42] Dreamer3: has joined #RubyOnRails
[17:21:44] elsurudo: which means it can only have one order
[17:21:48] elsurudo: which doesn’t work for my model
[17:22:16] mordof: you could technically use a join table for that
[17:22:19] mordof: has_one through
[17:23:02] elsurudo: yeah, but join table just complicates things. this is just a one-many. shouldn’t need a join table for that
[17:23:16] elsurudo: then I need t add a table, and there are performance implications too
[17:24:20] gusrub: has joined #RubyOnRails
[17:26:00] hotpancakes: has joined #RubyOnRails
[17:27:14] mordof: pretty sure has_one primary_key: :color_id, foreign_key: :id or something along those lines would still work
[17:28:20] elsurudo: i could be wrong, but i don’t think has_one supports those options
[17:28:27] mordof: oh.. *checks*
[17:28:27] elsurudo: otherwise it’s the same thing as belongs_to
[17:28:49] ResidentBiscuit: has joined #RubyOnRails
[17:28:57] mordof: without the requirement in this case though, and it'd be more semantically correct
[17:29:16] mordof: looks like it has those options
[17:29:17] ResidentBiscuit: has joined #RubyOnRails
[17:29:42] ResidentBiscuit: has joined #RubyOnRails
[17:30:34] elsurudo: is that right
[17:31:31] elsurudo: Docs of has_one say the FK is in the other table
[17:31:57] mordof: swap whichever key you need to make it point to them accordingly in your example
[17:32:00] mordof: i always get them mixed up
[17:32:16] mordof: but if i'm not mistaken - your order has a color_id does it not?
[17:32:25] mordof: which would be the primary key (looking at its own table)
[17:32:28] elsurudo: it does, which is why it’s the one with the belongs_to
[17:32:51] mordof: has_one :color, primary_key: :color_id, foreign_key: :id changes that
[17:33:06] mordof: swaps which fields it looks at so it connects the two the same way belongs_to natively does
[17:33:16] elsurudo: if it works like that, then you are right
[17:33:23] elsurudo: maybe i will try it sometime
[17:33:49] mordof: http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-has_one it lists as having them both, as well as a :required capable option
[17:33:55] mordof: which is what you want to make sure the message is custom
[17:34:10] elsurudo: but then what goes on the other, side?
[17:34:12] patarr: has joined #RubyOnRails
[17:34:18] mordof: it points to the record id
[17:34:30] mordof: so, no special column
[17:34:43] mordof: it matches color_id in order, with the id field in Color
[17:34:57] elsurudo: no column, but it should have a matching belongs_to
[17:35:06] elsurudo: with the FK and PK options reversed
[17:35:21] elsurudo: honestly seems a lot of confusion for not much benefit :P but good to know nonetheless
[17:35:42] mordof: technically it'd need to be something like a belongs_to_many, but i don't think that exists, lol
[17:36:06] mordof: or it could just be a has_many
[17:38:24] elsurudo: it would be gymnastics, is what it would be :P
[17:38:54] mordof: yup.. heh
[17:39:05] mordof: i guess i've never really liked the way rails made that distinction
[17:39:14] elsurudo: yeah same here
[17:39:17] mordof: i've always had issue with it, and done weird things to make it work the way i want
[17:39:35] elsurudo: but that’s rails. you learn the way it does things, and generally it works ok… most of the time
[17:39:37] mordof: like - we have a Presence model, with a belongs_to :report_label ..... but that report label does not own Presence
[17:39:56] elsurudo: yeah, semantically it doesn’t make sense
[17:39:58] mordof: it's the same situation you're in. it should be a has_one
[17:39:59] gusrub: has joined #RubyOnRails
[17:40:48] Criten: has joined #RubyOnRails
[17:41:02] mordof: elsurudo: i think this just means there's a helper missing in there that should be made
[17:41:20] mordof: but i can't think of what it would be called, because it's basically the same as a has_one but with different options
[17:41:37] Criten: How do i stop rails development server from printing parameters
[17:42:47] mordof: elsurudo: like #depends_on or something
[17:43:10] elsurudo: @mordof I agree, but I think it may complicate things, especially for beginners
[17:43:39] mordof: i don't know - i personally had a *really* hard time getting over the confusion of belongs_to and has_many not semantically being correct for some of the scenarios
[17:44:00] mordof: if there were other, more appropriate options, i think it could actually clear some of that confusion up
[17:44:33] elsurudo: Fair enough. I have basically reconfigured my mind (when working in Rails, anyway) to think: ok, this is where I want the FK to be, so this is a belongs_to. It works for me because I think of DB schema design before model design
[17:44:47] arBmind: has joined #RubyOnRails
[17:44:51] jphase: has joined #RubyOnRails
[17:44:57] mordof: it's essentially "don't think about what makes sense.. just focus on the fk"
[17:45:11] elsurudo: the helpers are poorly named, then
[17:45:38] mordof: they're aptly named; the main problem is that there's more than one scenario they're trying to cover. 2 big groups of situations. the first, they're perfectly named
[17:45:44] mordof: the second, they just don't work semantically
[17:45:57] mordof: and the fact they made belongs_to required first the first situation perfectly as well, but not the second
[17:46:03] mordof: so they're taking that enforcement beyond just semantics
[17:46:18] mordof: s/first/fits
[17:46:28] elsurudo: yeah. that’s a good characterization. this is why making the required default felt wrong to me somehow
[17:46:40] mordof: ACTION nods
[17:46:43] mordof: back to my Presence example
[17:46:47] mordof: it belongs_to :client
[17:46:51] mordof: which it *actually* does
[17:47:00] mordof: and if my Presence doesn't have a Client, my application is in trouble
[17:47:08] mordof: in that scenario, 100% belongs_to being required is valid
[17:48:04] mordof: the big question is - what does it get called... i may make a PR for this if i can come up with accurate names that help clear everything up
[17:48:07] [Butch]: has joined #RubyOnRails
[17:48:42] mordof: if it's #depends_on, then the other side is #is_depended_on_by.... lol
[17:49:18] mordof: and that other side is a many relationship.. so the name needs to match
[17:50:01] elsurudo: I don’t think depends_on really makes sense in a DB context
[17:50:11] elsurudo: it really is a has_one, with the FK positioning reversed
[17:50:26] elsurudo: maybe just an option to flip the FKs between has_one and belongs_to
[17:50:42] elsurudo: so Rails would still do its name-guessing magic
[17:50:52] mordof: in that scenario though, there's no relationship on the other side that fits
[17:51:00] mordof: because it'd have to be a belongs_to_many, which doesn't exist
[17:51:26] elsurudo: belongs_to already is the opposite end of a has_many though
[17:51:36] elsurudo: it’s already overloaded for that
[17:51:48] mordof: that's a singular relationship though
[17:51:58] mordof: has_many -> belongs_to is a many to one
[17:52:03] mordof: this is a one to many
[17:52:18] mordof: one to many*** this is a many to one
[17:52:45] mordof: it's a flipped situation that rails doesn't actually handle
[17:52:52] mordof: as far as i can tell
[17:53:18] elsurudo: it handles it ok practically speaking, it’s just the naming that doesn’t make much sense
[17:53:36] mordof: and the requirement. which i guess they've got covered with optional: true
[17:53:45] mordof: ACTION sighs
[17:54:20] cagomez: has joined #RubyOnRails
[17:54:28] mordof: w/e - i'll come up with names and then add the aliases for it in my own application, lol
[17:56:50] elsurudo: heh, yeah was thinking of that solution as well
[17:57:00] elsurudo: but too lazy, and complacent with how it works now, heh
[17:57:34] arBmind: has joined #RubyOnRails
[17:58:02] mordof: I've got two new guys coming onto my team at work, so i may put that in just so they don't have to suffer
[17:58:25] mordof: otherwise yeah.. it's a small detail
[17:59:22] hotpancakes: has joined #RubyOnRails
[17:59:38] elsurudo: if they already know Rails, putting it in will add to the suffering IMO
[18:04:46] mwlang: has joined #RubyOnRails
[18:06:45] Shalmezad: has joined #RubyOnRails
[18:07:40] mwlang: I just got a few error notices from the production server: Mysql2::Error: Server shutdown in progress — however, no shutdown occurred or was even indicative of occurring. In the MySQL logs: “2017-04-27T18:05:03.462744Z 44 [Note] Aborted connection 44 to db: 'rails_production' user: 'rails' host: 'localhost' (Got an error reading communication packets)”
[18:08:15] mwlang: any ideas what this could be? Its a localhost connection (unix sockets), so should be any communication packet drops.
[18:08:25] Shalmezad: mwlang: By any chance is it a long query?
[18:08:30] mwlang: *should not be* ...
[18:08:35] arBmind: has joined #RubyOnRails
[18:08:46] cagomez: has joined #RubyOnRails
[18:08:52] mordof: i take it you asked that in the mysql channel?
[18:08:54] mwlang: shalmezad: nope. Very simple straight up query of a single table.
[18:09:20] mwlang: mordof: good idea!
[18:09:21] mordof: or just crazy coincidence that you both joined at the same time with shalmezad responding..
[18:09:41] mwlang: mordof: I’m not in the mysql channel.
[18:09:50] mordof: i don't think that'll help much
[18:09:54] mordof: but i guess you could try
[18:10:14] Shalmezad: Crazy coincidence. Was actually coming on to ask about activejob
[18:10:41] mwlang: I’ve got about 20 of these in about 15 minute timespan.
[18:10:53] mwlang: I’m thinking it’s a hypervisor hardware issue.
[18:12:18] mwlang: the VM is hosted at Digital Ocean and they’ve been having a number of “outages” lately — definitely more so than I ever see at Rackspace and AWS.
[18:13:01] mwlang: my problem is, I can’t ever seem to pinpoint anything on their VM’s.
[18:14:59] mikecmpbll: has joined #RubyOnRails
[18:18:34] Shalmezad: So, with ActiveJob, let's say I have job A that starts 3 instances of job B. Is there any good built in way to have a callback when all 3 job B's are finished?
[18:24:14] mordof: mwlang: but what about that time aws us-east went down for a day, taking all of their other services and half the internet with it? lol
[18:24:43] mordof: that was a fun day..
[18:25:40] duderonomy: has joined #RubyOnRails
[18:26:02] mordof: In case any of the rails maintainers or contributors/or people curious are watching this topic, i made a ticket: https://github.com/rails/rails/issues/28908 I'm leaning more and more towards this being a bug with has_one relationships triggering a save when they shouldn't, but i have yet to confirm this
[18:28:08] mwlang: has joined #RubyOnRails
[18:28:44] mwlang: mordof: yeah, indeed! But at least that one was clearly attributed to their snaffu.
[18:29:00] mwlang: DO, by contrast seems not to take ownership of any “issues”
[18:29:18] hotpancakes: has joined #RubyOnRails
[18:33:11] ahrs: has joined #RubyOnRails
[18:36:30] alfie: has joined #RubyOnRails
[18:37:58] mordof: mwlang: oh, that sucks
[18:38:10] mordof: "server burned down. not our fault. no big deal"
[18:39:08] FastJack: has joined #RubyOnRails
[18:40:04] sonOfRa: has joined #RubyOnRails
[18:40:27] mwlang: or even admitting the server burned down. Only time I get a “confession” is when the VM spontaneously reboots. I’m like, what happened? “nothing, you must’ve rebooted” me: “B.S. there have been no logins to initiate such a reboot and my external monitoring tool definitely showed it went down and uptime is mere hours. what happened?” them: “oh, sorry for the incovenience, the hypervisor was experiencing hardware issues and we ha
[18:40:27] mwlang: reboot it.
[18:41:15] mwlang: anyway, I’m just sayin’. ‘nuff bitch’in here. :-) Back to your regular RoR channel
[18:41:27] tris: has joined #RubyOnRails
[18:44:08] xco: has joined #RubyOnRails
[18:48:31] Fire-Dragon-DoL: opinion: would you run validations every time you save a record (even outside of a controller) or only within the controller?
[18:49:00] Scient: does _any_ exception raised inside an AR transaction block trigger a rollback?
[18:50:14] Scient: seems so, its rescuing on Exception, rolling back and then re-raising it..
[18:50:35] rfoust: has joined #RubyOnRails
[18:50:57] arBmind: has joined #RubyOnRails
[18:52:00] mordof: Fire-Dragon-DoL: depends on the situation i guess. If there's going to be problems letting unvalidated data into a record, then yeah - validations go in the model
[18:52:06] mordof: and that's usually the case
[18:52:12] mordof: in my experience, anyway
[18:55:01] romeoh: has joined #RubyOnRails
[19:01:02] patarr: has joined #RubyOnRails
[19:01:35] lxsameer: has joined #RubyOnRails
[19:03:03] beauby: has joined #RubyOnRails
[19:05:26] Technodrome: has joined #RubyOnRails
[19:07:25] Fire-Dragon-DoL: mordof: I'm more concerned about the fact that we faced a bug because a record wasn't saved due to a rollback due to a validation error for something completely unrelated to the code
[19:07:35] Fire-Dragon-DoL: (and rails swallowed the error to make things easier :P )
[19:09:03] mordof: why did a bug occur due to that?
[19:09:22] mordof: if you've got multiple things being updated, and one entity gets rolled back - everything should be in a transaction so the other items get rolled back also
[19:10:25] Dreamer3: has joined #RubyOnRails
[19:12:13] mordof: ACTION wonders what "completely unrelated to the code" means
[19:14:56] Shalmezad: So no suggestions on the active job batch thing? =(
[19:15:31] mordof: shalmezad: sorry, i've never used ActiveJob - we use a different setup
[19:15:48] mikecmpbll: shalmezad: why not do the 3 job B's inline?
[19:16:02] mikecmpbll: it's already running in the background, does it really need to run as a different unit?
[19:16:45] Shalmezad: There's only a small handful of job A's (one every minute or so), and a bunch of job B's (used 3 in the example, but could be anywhere from 3 to 300)
[19:17:05] mikecmpbll: what relevance has that?
[19:17:27] Shalmezad: Because if I have 5 workers, and 2 job A's running B's inline, 3 workers are sitting idle when they could be running B's
[19:17:47] mikecmpbll: oh, you want concurrency.
[19:18:11] mordof: ACTION goes to fetch a giant box of pain
[19:18:37] dblessing: has joined #RubyOnRails
[19:19:06] mikecmpbll: there's nothing in activejob to help you with that
[19:20:09] Shalmezad: Alright, figured as much. Thanks for the helps anyways.
[19:20:31] mordof: shalmezad: when job A spins up X amount of job B - stick an integer into redis of how many job B it needs to do, relative to job A's run. then at the end of each job B - decrement it. once it reaches 0, either trigger another job, or run it there
[19:20:35] dionysus69: has joined #RubyOnRails
[19:20:49] mikecmpbll: one possible solution, aye.
[19:20:58] mikecmpbll: if you're using redis/sidekiq, anyway. did you state that?
[19:21:09] mordof: i use redis, so i mentioned it, lol
[19:21:37] Shalmezad: Using redis, still haven't decided on what's going to run active job yet (probably going with resque since that's what I was using before hearing of activejob)
[19:22:56] Shalmezad: But yeah, since there's nothing built in, leaning towards taking the active_job_status gem and doing a little bit of tweaking (pass batch_id to the jobs, in the jobs after_perform check batch.completed and call appropriate callback)
[19:25:10] mikecmpbll: i'd probably just do job Bs in parallel from job A.
[19:25:20] mikecmpbll: simplest usually best :'D
[19:26:35] blackmesa: has joined #RubyOnRails
[19:28:36] blackmesa: has joined #RubyOnRails
[19:28:42] Shalmezad: Yeah, it normally is ( <3 parallel gem), but trying to see if I can make this scale up (use multiple machines as workers), especially since I have a bunch of computers lying around (so long as they have the code, the gems, and point to the right host...). >:)
[19:29:14] quirkycoders: has joined #RubyOnRails
[19:29:37] quirkycoders: I have a binding.pry in a helper method but it's not firing...any ideas?
[19:30:04] lxsameer: has joined #RubyOnRails
[19:30:58] Shalmezad: quirkycoders: 100% sure the helper method is being fired? (ran into that more times than I can count)
[19:31:54] quirkycoders: yeah it seems like it wasn't but I purposely added a syntax error to make sure and it failed where I added the error
[19:32:11] arup_r: has joined #RubyOnRails
[19:32:27] mordof: quirkycoders: syntax errors are evaluated on load-up, not when it gets called
[19:32:53] quirkycoders: The funny part is that I added this error after my binding.pry line so it passed the binding.pry before hitting the error without stopping
[19:33:28] quirkycoders: well I added the line and did a refresh and it stopped on the syntax error
[19:34:37] sandstrom: has joined #RubyOnRails
[19:36:00] quirkycoders: That's ok...I was able to get it to work in the view so that'll have to do
[19:41:47] romeoh: has joined #RubyOnRails
[19:42:31] ekinmur: has joined #RubyOnRails
[19:45:01] sunrunner20: has joined #RubyOnRails
[19:55:27] mjora7: has joined #RubyOnRails
[19:56:34] mustmodify: has joined #RubyOnRails
[19:57:07] omgitsme: has joined #RubyOnRails
[19:57:30] mustmodify: I'm attempting to get bootstraped with react-on-rails. It wants mini-racer, which I guess replaces therubyracer. But less-rails is now complaining that "cannot load such file -- v8". Any help?
[19:57:35] omgitsme: hey guys, does it make sense to generate the secret token every time i restart my rails 4.2 app?
[19:58:15] mustmodify: your uses would quickly become frustrated because users who were about to submit a form would find that their submissions were no longer valid.
[19:58:18] omgitsme: is it a one time thing, mustmodify ? i want to just add a rake secret piece to the unicorn init script
[19:58:20] mustmodify: between deploys.
[19:58:45] omgitsme: ah - yeah this is an internal user base, i negotiate downtimes before deployments
[19:59:33] omgitsme: ok i think i got this. thank you mustmodify.
[19:59:56] mustmodify: Well, you are GOING to have a user who has the login screen (or whatever) up, and then waits for the deploy to be done, submits the form, and gets logged out or whatever. But it won't actually 500.
[20:00:10] jsrn_: has joined #RubyOnRails
[20:02:21] omgitsme: yeah this makes sense. i am generating this file once during deploy, and if it exists im not re-generating it.
[20:02:47] omgitsme: if i need to regenerate it, i will remove it and ansible will regenerate it then.
[20:02:58] DrYockel: has joined #RubyOnRails
[20:04:06] mostlybadfly: has joined #RubyOnRails
[20:10:40] beauby: has joined #RubyOnRails
[20:11:14] Ratler: has joined #RubyOnRails
[20:15:27] LightStalker: has joined #RubyOnRails
[20:19:15] marr: has joined #RubyOnRails
[20:19:30] Leonardo_0112: I'm reading a rails ebook and in the tutorial the author create the database throught migration files. What about create the database from phpmyadmin or even mysql workbench? Is it a bad idea?
[20:24:33] pupsicle: has joined #RubyOnRails
[20:24:59] Ratler: has joined #RubyOnRails
[20:26:03] ResidentBiscuit: has joined #RubyOnRails
[20:30:39] mordof: Leonardo_0112: the main reason migrations are used, is because it's not a manual process after the fact
[20:30:48] mustmodify: I'm attempting to get bootstraped with react-on-rails. It wants mini-racer, which I guess replaces therubyracer. But less-rails is now complaining that "cannot load such file -- v8". Any help?
[20:30:49] mordof: you set it up using code - those migrations go in your version control, and they're done
[20:30:53] mustmodify: has left #RubyOnRails: ()
[20:31:05] mordof: Leonardo_0112: anyone who comes after can just do a db:create, and it'll set everything up for them
[20:31:31] mordof: Leonardo_0112: zero knowledge of your database must be known to get your application running on a new machine/fresh database
[20:31:56] fryguy: it's rarely correct to rely on migrations for that
[20:32:10] mordof: for which?
[20:32:18] pupsicle: has joined #RubyOnRails
[20:32:22] fryguy: running database on new machine
[20:32:24] fryguy: rails generates a schema.rb or schema.sql file for that purpose
[20:32:35] mordof: which it uses if it's available
[20:32:49] mordof: but you need to have done something to generate that first off
[20:33:38] cam27: has joined #RubyOnRails
[20:40:56] Leonardo_0112: mordof, so thjis approach is widely used for programmers is it?
[20:41:48] mordof: Leonardo_0112: i think the biggest thing for migrations - is if you're working in a team. and you make modification X on your database. if it's code in a migration file - you check it in, others on your team can grab that code and say "run migrations!" and the code tells rails what to do to modify the database
[20:41:57] mordof: Leonardo_0112: yeah - migrations are super helpful
[20:42:37] mordof: Leonardo_0112: like fryguy pointed out, every time a migration is run (i'm pretty sure that's the case), a schema.rb file gets created that shows the full state of your database. if you needed to rebuild a database, it would look at that file to make it
[20:42:46] arBmind: has joined #RubyOnRails
[20:43:04] mordof: i don't know if you can generate a schema.rb from an already made database, i imagine there are ways to do it
[20:43:06] mordof: i haven't done it though
[20:43:55] mordof: if there are, and if they're reliable, then you can feel free to create your database initially however you want, and then generate a schema.rb file to work from moving forward
[20:44:25] mordof: since you're learning rails though, might be better to stick to migrations initially anyway.
[20:44:38] Leonardo_0112: mordof, right! I'm asking because many times I caught myself doing some thinks in the hard way
[20:45:34] Leonardo_0112: actually i'm comming from php
[20:46:03] mordof: congrats on the switch :)
[20:46:43] Leonardo_0112: And I'm very excited for develop some project with rail, but I'm reading to to the thinks "the right way"
[20:46:55] brwr_: has joined #RubyOnRails
[20:48:17] knight33: has joined #RubyOnRails
[20:50:12] Technodrome: has joined #RubyOnRails
[20:51:19] Leonardo_0112: mordof, I'm reading this book: https://pragprog.com/book/rails5/agile-web-development-with-rails-5. Do you sugest another one to learn rails? I like the ones that has a step by step project build
[20:51:54] mordof: i'm not really familiar with books in general
[20:52:05] mordof: i tend to read articles/blog posts as i need info
[20:53:23] mordof: Leonardo_0112: It's probably still good to read through that book; at the very least it will get you a lot of the information you need. if there are odd points in it, you'll likely resolve that information at a later date
[20:54:08] mordof: it may seem like bad advice to a degree, but especially when diving into something new, it's unlikely you'll get all of the information exactly as it's needed for each scenario you're presented with. worrying too much about that can hinder the learning process :)
[20:54:14] Leonardo_0112: mordof, well, I'll keep reading it and very often I'm coming here ;)
[20:54:19] Leonardo_0112: mordof, thanks
[20:54:23] mordof: sounds good
[20:58:18] gusrub: has joined #RubyOnRails
[21:00:28] omgitsme: has left #RubyOnRails: ()
[21:00:33] Ratler: has joined #RubyOnRails
[21:02:03] KSloth: has joined #RubyOnRails
[21:08:34] choke: has joined #RubyOnRails
[21:14:08] mordof: Slogger: turns out it's the if node.present? that's preventing the circular save in ActiveRecord 4.1.2
[21:14:23] futilegames: has joined #RubyOnRails
[21:14:29] mordof: Slogger: in 4.1.2, the referenced node *does not exist* yet at that point. the after_create must be called later on in the callback chain
[21:15:11] mordof: Slogger: my suspicion is they bumped the after_create to earlier in the callback chain - probably just after the yield takes place, before the rest of the code.... or something like that
[21:16:30] mordof: Slogger: both 4.1.2 and 5.0.2 have autosave_association hooks, so when a node with a has_one agency gets saved, the agency *always* gets saved.. in both versions. but it's the check about the node that changes things.
[21:16:33] mordof: anyway.. heading out for the night.
[21:16:37] hotpancakes: has joined #RubyOnRails
[21:16:40] mordof: i think i'll be able to fully understand/resolve this tomorrow
[21:18:32] lxsameer: has joined #RubyOnRails
[21:20:48] KSloth: Wondering if anyone could give me some advice on where to go after the Hartl Tutorial
[21:22:58] beauby: has joined #RubyOnRails
[21:26:12] Ratler: has joined #RubyOnRails
[21:26:30] quirkycoders: has joined #RubyOnRails
[21:28:58] defsdoor: has joined #RubyOnRails
[21:29:51] brent__: has joined #RubyOnRails
[21:30:24] adambecker: has joined #RubyOnRails
[21:37:56] havenwood: Grats on Rails 5.1!
[21:38:08] havenwood: http://weblog.rubyonrails.org/
[21:40:56] ChanServ: +o baweaver
[21:40:56] ChanServ: +o baweaver
[21:41:06] baweaver: mine mine mine mine mine mine mine
[21:41:32] ChanServ: -o baweaver
[21:41:38] baweaver: yessssssssss
[21:42:20] Slogger: I wish I'd known RailsConf was in Phoenix. I'm so used to it being in far away places I kind of ignore it and this time I maybe could have gone...
[21:59:23] gusrub: has joined #RubyOnRails
[22:05:13] blackmesa: has joined #RubyOnRails
[22:06:25] Ratler: has joined #RubyOnRails
[22:06:52] arBmind: has joined #RubyOnRails
[22:11:11] LBRapid: has joined #RubyOnRails
[22:11:13] Emily: has joined #RubyOnRails
[22:12:50] lxkm_: has joined #RubyOnRails
[22:15:54] knight33: has joined #RubyOnRails
[22:17:08] [spoiler]: has joined #RubyOnRails
[22:17:20] Junaos: has joined #RubyOnRails
[22:18:23] iamdevnul: has joined #RubyOnRails
[22:18:32] cgfbee: has joined #RubyOnRails
[22:19:16] wsmoak: has joined #RubyOnRails
[22:20:17] russt: has joined #RubyOnRails
[22:20:22] xybr_: has joined #RubyOnRails
[22:20:32] leslie: has joined #RubyOnRails
[22:21:12] arthurnn: has joined #RubyOnRails
[22:21:43] Lloyd: has joined #RubyOnRails
[22:23:22] Takumo: has joined #RubyOnRails
[22:25:20] LyndsySimon: has joined #RubyOnRails
[22:26:05] barttenbrinke: has joined #RubyOnRails
[22:26:07] digitalfiz: has joined #RubyOnRails
[22:27:37] CornishPasty: has joined #RubyOnRails
[22:32:49] hotpancakes: has joined #RubyOnRails
[22:37:47] hotpancakes: has joined #RubyOnRails
[22:42:21] hotpancakes: has joined #RubyOnRails
[22:45:21] Ropeney: has joined #RubyOnRails
[22:49:28] duderono_: has joined #RubyOnRails
[22:59:00] Ropeney: has joined #RubyOnRails
[23:10:18] hotpancakes: has joined #RubyOnRails
[23:11:13] gs: has joined #RubyOnRails
[23:13:16] mjora7: has joined #RubyOnRails
[23:17:18] FastJack: has joined #RubyOnRails
[23:18:46] GodFather: has joined #RubyOnRails
[23:23:57] hotpancakes: has joined #RubyOnRails
[23:24:22] gusrub: has joined #RubyOnRails
[23:24:52] beauby: has joined #RubyOnRails
[23:26:21] hotpancakes: has joined #RubyOnRails
[23:36:11] hotpancakes: has joined #RubyOnRails
[23:37:03] arBmind: has joined #RubyOnRails
[23:37:18] lxsameer: has joined #RubyOnRails
[23:42:42] cagomez: has joined #RubyOnRails
[23:47:53] hotpancakes: has joined #RubyOnRails
[23:54:32] cerulean: has joined #RubyOnRails
[23:54:42] cerulean: does anyone know how to defeat opera OS X CSP (content security policy)
[23:54:52] cerulean: i tried setting a CSP in a <meta> tag
[23:55:06] cerulean: it sees it, but doesnt use it. claims i have script-src 'none' set somewhere and i don't
[23:56:38] DLSteve: has joined #RubyOnRails
[23:57:17] uksio: has joined #RubyOnRails
[23:57:32] cagomez: has joined #RubyOnRails
[23:57:55] cerulean: i cant seem to get rid of the script-src none
[23:58:07] hotpancakes: has joined #RubyOnRails