« Back to channel list

#RubyOnRails - 06 November 2017

« Back 1 day Forward 1 day »
[00:03:29] fschuindt: has joined #RubyOnRails
[00:05:02] xaviergmail: has joined #RubyOnRails
[00:05:46] Radar: patches welcome? ;)
[00:09:11] cam27: has left #RubyOnRails: ()
[00:20:51] one_zero: has joined #RubyOnRails
[00:21:51] xaviergmail: has joined #RubyOnRails
[00:29:18] workmad3: has joined #RubyOnRails
[00:48:27] fragamus: has joined #RubyOnRails
[00:53:08] one_zero_l: has joined #RubyOnRails
[00:55:27] ResidentBiscuit: has joined #RubyOnRails
[01:00:16] xaviergmail: has joined #RubyOnRails
[01:09:50] irishfromua: has joined #RubyOnRails
[01:20:52] sevenseacat: has joined #RubyOnRails
[01:44:25] jottr: has joined #RubyOnRails
[01:56:50] danman: has joined #RubyOnRails
[02:06:57] fschuindt: has joined #RubyOnRails
[02:17:17] Technodrome: has joined #RubyOnRails
[02:29:44] workmad3: has joined #RubyOnRails
[02:31:49] quazimodo: has joined #RubyOnRails
[02:48:36] jaegerca: has joined #RubyOnRails
[02:49:13] jaegerca: How do you all separate your "external" from "internal" controllers (authenticated vs public) - and what terminology do you use?
[03:02:57] sevenseacat: there might not be a separation
[03:03:14] sevenseacat: admin-only controllers might be separated by a namespace
[03:05:03] quazimodo: has joined #RubyOnRails
[03:05:26] baweaver: pretty much namespaces like sevenseacat mentioned. Just add before actions / filters on them to user-lock it
[03:07:06] one_zero: has joined #RubyOnRails
[03:45:32] jottr: has joined #RubyOnRails
[03:58:07] fragamus: has joined #RubyOnRails
[04:11:25] mikecmpbll: has joined #RubyOnRails
[04:18:21] srinidhi: has joined #RubyOnRails
[04:26:53] Saukk: has joined #RubyOnRails
[04:28:54] Technodrome: has joined #RubyOnRails
[04:29:04] fragamus: has joined #RubyOnRails
[04:30:17] workmad3: has joined #RubyOnRails
[04:30:47] guacamole: has joined #RubyOnRails
[04:36:52] weaksauce: has joined #RubyOnRails
[04:51:57] dionysus69: has joined #RubyOnRails
[04:54:33] SteenJobs: has joined #RubyOnRails
[04:58:49] Technodrome: has joined #RubyOnRails
[04:58:59] quazimodo: has joined #RubyOnRails
[05:06:41] jrabe: has joined #RubyOnRails
[05:11:13] Technodrome: has joined #RubyOnRails
[05:35:23] fragamus: has joined #RubyOnRails
[05:40:35] ur5us: has joined #RubyOnRails
[05:45:22] smoitra: has joined #RubyOnRails
[05:45:34] smoitra: hello all, I want to know what will be the expected EOL for rail 4.2.x series ?
[05:46:22] jottr: has joined #RubyOnRails
[05:47:35] sevenseacat: it will stop receiving major security patches when rails 6 comes out afaik. its already EOL for minor security patches and bug fixes
[05:47:54] sevenseacat: http://rubyonrails.org/security/
[05:54:17] smoitra: sevenseacat: Thankyou, do we expect any rails 4.3.x series ?
[05:54:44] sevenseacat: upgrade to rails 5 as soon as you can.
[05:59:19] smoitra: sevenseacat: Are we expecting EOL for major security patches support for 4.2.x in 2017 or early 2018 ?
[06:00:24] sevenseacat: when rails 6 comes out.
[06:01:01] sevenseacat: its unlikely to be in that time frame, but no guarantees.
[06:02:54] smoitra: sevenseacat: Thankyou
[06:03:26] sevenseacat: I strongly recommend taking the time out to upgrade your app now.
[06:15:29] tcopeland: has joined #RubyOnRails
[06:22:41] dionysus69: has joined #RubyOnRails
[06:24:20] ur5us: has joined #RubyOnRails
[06:33:46] AntiSpamMeta2: has joined #RubyOnRails
[06:36:29] noodle: has joined #RubyOnRails
[06:37:09] funnel: has joined #RubyOnRails
[06:39:29] ahrs: has joined #RubyOnRails
[06:40:40] clamstar: has joined #RubyOnRails
[06:44:20] ur5us: has joined #RubyOnRails
[06:46:10] rrichardsr3: has joined #RubyOnRails
[06:46:23] bga57: has joined #RubyOnRails
[06:48:59] atrius: has joined #RubyOnRails
[06:51:49] arup_r: has joined #RubyOnRails
[07:07:47] ur5us: has joined #RubyOnRails
[07:11:58] kies: has joined #RubyOnRails
[07:11:58] hfp_work: has joined #RubyOnRails
[07:11:58] fcser_: has joined #RubyOnRails
[07:11:58] cgfbee: has joined #RubyOnRails
[07:11:58] Axsuul: has joined #RubyOnRails
[07:11:58] Fridtjof: has joined #RubyOnRails
[07:11:58] epochwolf: has joined #RubyOnRails
[07:11:58] nickjj: has joined #RubyOnRails
[07:11:58] blackcross: has joined #RubyOnRails
[07:11:58] maryo: has joined #RubyOnRails
[07:11:58] beingjohnm: has joined #RubyOnRails
[07:11:58] jnollette: has joined #RubyOnRails
[07:11:58] Kilo`byte: has joined #RubyOnRails
[07:11:59] dminuoso: has joined #RubyOnRails
[07:11:59] urkle: has joined #RubyOnRails
[07:11:59] sunya7a: has joined #RubyOnRails
[07:14:27] Axsuul: has joined #RubyOnRails
[07:15:26] DrYockel: has joined #RubyOnRails
[07:17:15] rrichard_: has joined #RubyOnRails
[07:18:51] AntiSpamMeta: has joined #RubyOnRails
[07:19:34] cgfbee: has joined #RubyOnRails
[07:23:13] snickers: has joined #RubyOnRails
[07:29:22] ur5us: has joined #RubyOnRails
[07:31:39] ur5us: has joined #RubyOnRails
[07:46:58] mtkd: has joined #RubyOnRails
[07:47:58] jottr: has joined #RubyOnRails
[07:50:06] ^mtkd: has joined #RubyOnRails
[07:56:04] conta: has joined #RubyOnRails
[08:06:06] hammer065: has joined #RubyOnRails
[08:17:14] ephemer0l_: has joined #RubyOnRails
[08:23:19] ur5us: has joined #RubyOnRails
[08:29:39] quazimodo: has joined #RubyOnRails
[08:31:12] workmad3: has joined #RubyOnRails
[08:32:07] mikecmpbll: has joined #RubyOnRails
[08:35:56] drale2k_: has joined #RubyOnRails
[08:36:45] dminuoso: Can someone explain tome why this is mutating my hash? https://gist.github.com/dminuoso/86d1cc63a03af77803d18d14300a1898
[08:37:47] sevenseacat: #ruby might be a better help for that kind of technical stuff
[08:38:06] dminuoso: sevenseacat: Well, I was asking in here because its based on an assumption about #deep_dup
[08:38:30] ur5us: has joined #RubyOnRails
[08:38:51] sevenseacat: oh, is that activesupport fuckery?
[08:39:39] defsdoor: has joined #RubyOnRails
[08:39:57] dminuoso: Mmm, its possible I may have incorrectly copied the implementation.
[08:40:50] matthewd: That possibility would be consistent with the fact I don't get that result
[08:47:34] alfiemax: has joined #RubyOnRails
[08:49:41] dminuoso: matthewd: Oh man. I accidentally dd'ed the wrong line of code. :(
[08:53:27] jottr: has joined #RubyOnRails
[08:59:16] remix2000: Where should I `require` service files?
[09:02:56] mikecmpbll: has joined #RubyOnRails
[09:03:58] remix2000: ↑ https://gist.github.com/remi6397/ed87e4d063e85a95443ddee060acca9f
[09:04:07] matthewd: remix2000: If it's in app/services/ (or app/*/), you don't need to require it. Otherwise, where you use it? ¯\_(ツ)_/¯
[09:04:44] matthewd: Yeah, you don't need to explicitly require that
[09:04:49] sevenseacat: that's... a odd service
[09:05:12] remix2000: so I need to call it like `PastesService.find_pastes`?
[09:05:29] matthewd: That's where you've defined the method, so yes
[09:05:40] remix2000: sevenseacat: Why is it incorrect? What should I change?
[09:05:59] sevenseacat: I didnt say incorrect. i said odd
[09:06:07] matthewd: remix2000: Why are you creating a service? It looks like a perfectly reasonable controller action body to me.
[09:07:05] remix2000: Hmm… dminuoso told me yesterday, that searching logic doesn't belong to controller and I should put it in a service.
[09:07:24] dminuoso: remix2000: I did not say you should. I just said that its my opinion it does not belong there.
[09:08:20] dminuoso: ACTION has some quirky opinions
[09:08:21] remix2000: dminuoso, I think so too, it uses more than one model
[09:08:51] tbuehlmann: looks to me like a pundit scope
[09:09:36] matthewd: Also don't use where!
[09:09:43] matthewd: (that one's not an opinion)
[09:10:01] dminuoso: But Im quite interested in matthewd'd point of view. Don't you think that maybe 10 lines of code on query logic belong outside the controller?
[09:10:03] matthewd: Where did you even see that? :/
[09:10:16] remix2000: matthewd: Why not to user where?
[09:10:31] remix2000: Will it affect performance negatively?
[09:10:31] matthewd: remix2000: `where` is fine; `where!` is absolutely not
[09:10:59] dminuoso: matthewd: So you prefer rel = rel.where(...) ?
[09:11:06] matthewd: dminuoso: Not if that's all that's in there -- otherwise what's the controller there for?
[09:11:44] matthewd: dminuoso: Not prefer; only support. where! is internal, unsupported, and likely to go away (without warning) in a near future version
[09:12:09] dminuoso: Ah interesting, to be fair I was not aware of where!'s existence until yesterday either.
[09:12:58] matthewd: Hence my curiosity of where remix2000 even learned about it -- it's very much undocumented by design
[09:13:14] dminuoso: ACTION guesses SO
[09:13:46] apeiros: has joined #RubyOnRails
[09:14:01] remix2000: matthewd: It seemed to me obvious, that method like this exists.
[09:14:13] matthewd: dminuoso: Specifically it's unsupported because the public API of Relation is supposed to make it immutable
[09:14:43] matthewd: remix2000: Hmm, okay. Well, it doesn't, so please don't use it. :)
[09:15:04] remix2000: So why they exposed it to public?
[09:15:40] matthewd: remix2000: Because public means able to be called from other classes. It's used internally by being called from other classes.
[09:16:32] matthewd: There are a lot of public-access-visibility methods in Rails that are undocumented and considered internal; if it's not documented, it's not part of the supported API and can go away at any time
[09:16:56] remix2000: Anyways, `rel = rel.where(…)` looks weird
[09:20:51] matthewd: To me it's no different from `i = i + 1`
[09:21:21] matthewd: Yes that has a special shorter syntax, but the long form doesn't strike me as weird
[09:21:46] arBmind: has joined #RubyOnRails
[09:25:23] DrYockel: has joined #RubyOnRails
[09:27:44] mikecmpbll: there was a time i didn't realise `where!` was internal and used it quite a lot ☹️
[09:32:19] matthewd: Yeah, I think we should probably rename them
[09:32:57] sevenseacat: people will probably call them anyway. just like arel.
[09:33:32] bga57: has joined #RubyOnRails
[09:34:41] matthewd: Yeah, but if people know they're using something internal / dangerous, I don't mind so much. The worry is people who stumble upon it and think it's a supported API.
[09:35:55] remix2000: sevenseacat: what is arel?
[09:36:04] sevenseacat: shit, now I've done it.
[09:39:15] kapil___: has joined #RubyOnRails
[09:48:11] iamarun: has joined #RubyOnRails
[09:57:44] remix2000: Do I need to explicitly validate presence in model while I specified `null: false` in migration?
[09:59:10] remix2000: (when value is not passed by user, but generated in controller)
[10:01:04] tbuehlmann: null: false does not add a validation, you will need to add that yourself
[10:01:28] tbuehlmann: even if your controller sets a value, I consider having a validation in place a good thing
[10:03:52] dminuoso: At some point you will use that model somewhere else and forget to set it, and instead of getting an accurate exception with a useful message (and validation states), you'd just get a database error instead. Decide for yourself whether validations are worth it.
[10:05:27] remix2000: And when I have devise model with `account_type` that should default to 'user', should I fallback it to `default` in db, or explicitly default it in some way?
[10:07:33] fschuindt: has joined #RubyOnRails
[10:09:23] ur5us: has joined #RubyOnRails
[10:11:28] workmad3: has joined #RubyOnRails
[10:13:08] matthewd: remix2000: Database defaults are fine
[10:14:13] snickers: has joined #RubyOnRails
[10:14:17] remix2000: Or maybe should I associate user one-to-one with account?
[10:14:37] remix2000: And put stuff like that in account model
[10:15:35] ferr: has joined #RubyOnRails
[10:16:22] ferr: has left #RubyOnRails: ()
[10:19:51] fschuindt: has joined #RubyOnRails
[10:20:15] remix2000: If yes, how can I create account for user without touching devise controller?
[10:23:23] ur5us: has joined #RubyOnRails
[10:25:03] quazimodo: has joined #RubyOnRails
[10:38:26] drale2k_: has joined #RubyOnRails
[10:41:54] Ergo: has joined #RubyOnRails
[10:43:26] kristofferR: has joined #RubyOnRails
[11:02:25] ij: has joined #RubyOnRails
[11:03:39] ij: Are there any wiki-like CMSes for rails?
[11:09:12] drale2k_: has joined #RubyOnRails
[11:41:49] drale2k_: has joined #RubyOnRails
[11:47:38] mostlybadfly: has joined #RubyOnRails
[12:05:19] alexday: has joined #RubyOnRails
[12:07:00] quazimodo: has joined #RubyOnRails
[12:09:51] alexday: I am having a little problem. I have a polymorphic association. Tag belongs_to :entity, polymorphic: true; validates :name, :entity_id, :entity_type, presence: true. and Application has_many :tags, as: :entity; accepts_nested_attributes_for :tags, reject_if: :all_blank;. Now in the applications controller I have @application.tags = @application.tags.build . and in the new.html.erb I have a f.fields_for
[12:09:52] alexday: :tags do |t| ... end . Now when I click on submit in the application new form. it says entity can't be blank. which is justified because entity_id has not been created yet. But how to solve this? I tried to add inverse_of in has_many but its say not possible. Presently I have stripped out tag_attributes from the applications_params and then after creating application I have updated with {
[12:09:54] alexday: tags_attributes: application_params }
[12:11:29] alexday: made a small mistake not @application.tags = @application.tags.build. only @application.tags.build
[12:16:34] fschuindt: has joined #RubyOnRails
[12:24:39] fragamus: has joined #RubyOnRails
[12:25:17] AntiSpamMeta: has joined #RubyOnRails
[12:25:47] amincd: has joined #RubyOnRails
[12:28:18] marr: has joined #RubyOnRails
[12:29:16] remix2000: I was thinking on this for a long while. I want to create dependent model `account` [o-t-o] and add empty instances for every `user` after running migrations. default values have been run. However, no accounts are created. https://gist.github.com/remi6397/0bc4ac7d8729dc11ecf7ab3d05e81571
[12:38:04] dminuoso: alexday: tl;dr. Can you make a gist?
[12:38:13] dminuoso: Use multiple files
[12:38:14] helpa: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[12:39:22] dminuoso: matthewd: So regarding the controller topic. I prefer thin actions that are mostly concerned with just params gathering, dispatching query logic to models or services and deciding on the view.
[12:40:19] tcopeland: has joined #RubyOnRails
[12:40:59] dminuoso: Moving complex (I'd argue that 10 lines with multiple conditionals generating some AR relation is complex) into dedicated modules promotes reusability.
[12:41:23] dminuoso: But it might as well be scopes on a model.
[12:42:10] dminuoso: Also it makes testing that logic easier (since you dont have to mess with otherwise uninteresting controller tests)
[12:42:33] matthewd: If it makes sense on a model, then I'd certainly put it on a model as a scope
[12:42:53] hahuang65: has joined #RubyOnRails
[12:43:07] matthewd: But if you're looking for something to coordinate some interaction between models, to me, that's exactly what the controller exists for
[12:44:05] matthewd: If you *need* to reuse that combination, then _maybe_ consider extracting to something you can call directly
[12:44:55] dminuoso: matthewd: What about testability? By pushing this logic into the controller you can't blackbox test the behavior specifically.
[12:45:02] matthewd: I don't think we're very far apart on what's properly a controller's responsibility.. I just don't like it when a controller action looks like ServiceObjectNamedAfterTheAction.new(params[:foo], params[:bar])
[12:45:45] dminuoso: I mean you could also just push it into a private method on the controller, and that would be perfectly fine by me.
[12:47:23] dminuoso: But I do get your point.
[12:47:23] matthewd: I think I'd default to just using integration tests to cover it, personally
[12:47:34] matthewd: Depends how exhaustively you're going to test the query anyway, I suppose
[12:48:19] matthewd: e.g. are you really doing a bunch of different setups + test runs, or are you more likely to construct a single well-represented data set, then assert which records end up in/out?
[12:49:08] matthewd: If the latter, it's no more effort to assert that they're present in the response body, and you cover the whole stack for free
[12:51:58] matthewd: dminuoso: Agree that a private method is a good extraction point before going full-on class too
[12:53:20] dminuoso: matthewd: I think ultimately it might be the best spot (until you extract for reusability). You could do integration tests, or in my case (with view models this is more stable) unit tests based on it. While granted the invocation of a private controller method might be a bit quirky, but I dont think it'd be a problem.
[12:54:00] matthewd: Yeah -- and it's not fundamentally different to if it were a separate class
[12:54:23] matthewd: Either the class is needlessly public, or it's a private constant and you're at the same point with very-friendly tests
[12:54:29] Sylario: has joined #RubyOnRails
[12:55:21] matthewd: I'm not sure why Avdi specifically points toward replacing service objects with "global" methods when controllers provide such a natural place to hang them [again, until a more first-class extraction is called for]
[12:56:11] matthewd: But ultimately, anything that discourages "every method should be a class" design is a positive, IMO
[12:56:16] fschuindt: has joined #RubyOnRails
[12:56:41] sevenseacat: +1 to that. there's SRP and then there's crazy
[12:57:12] blackbaba: has joined #RubyOnRails
[12:59:20] matthewd: It's actually the same doubt I have about containers-everywhere in sysadmin land, I guess -- it's useful to be able to extract [a method into a class / an app into a container], but if you do that with everything, you have exactly the same big flat mess you started with, at a higher level of abstraction & complexity
[12:59:50] matthewd: The power of the abstraction is in your ability to use it to group lower level concepts together
[13:00:27] alexday: dminuoso sure. the internet went off. posting in a moment
[13:00:58] dminuoso: matthewd: In a way you could apply that same criticism to the default rails layout. Im really tempted to try out the trailblazer concepts layout, it follows a design strategy I have successfully used to structure our react apps. :)
[13:01:51] jphase: has joined #RubyOnRails
[13:02:08] dminuoso: The categorization of files into app/controllers, app/models, app/helpers, app/views, app/decorators etc quickly ends up spreading very related files (in particular controller + view/view models) across different places, where grouping is based on shape rather than whether they belong together.
[13:02:35] matthewd: dminuoso: Yeah, perhaps. I haven't really looked, for reasons that aren't entirely technical.
[13:04:33] matthewd: By the same principle, I'd worry again about a tendency to create too-small slices, instead of grouping things into a handful of app-parts (but that's still with little understanding of what it actually looks like in practice)
[13:08:25] alexday: dminuoso: https://gist.github.com/argentum47/43e994f133a3fc47175008ad01a0e0fe
[13:09:14] sevenseacat: why do people keep changing nicks all the time
[13:09:26] dminuoso: sevenseacat: who did?
[13:13:34] cabotto: has joined #RubyOnRails
[13:15:04] alexday: I did. but that was long ago. someone said people dont take the name shortCircuit__ seriously. it makes me look like a kid rather than a professional.
[13:15:50] alfiemax: has joined #RubyOnRails
[13:16:50] DrYockel: has joined #RubyOnRails
[13:21:53] alfiemax: has joined #RubyOnRails
[13:24:03] tycoon177: has joined #RubyOnRails
[13:24:03] dmcc: has joined #RubyOnRails
[13:24:08] vayan: has joined #RubyOnRails
[13:24:08] mmun: has joined #RubyOnRails
[13:24:10] jlpeters: has joined #RubyOnRails
[13:24:11] pfg: has joined #RubyOnRails
[13:24:18] craysiii: has joined #RubyOnRails
[13:24:18] jxf: has joined #RubyOnRails
[13:24:30] alexday: erm any updates on my code problem?
[13:24:45] Meow-J: has joined #RubyOnRails
[13:27:38] drale2k_: has joined #RubyOnRails
[13:29:22] Axsuul: has joined #RubyOnRails
[13:35:39] mikecmpbll: alexday : i don't really understand the issue. you're validating that 'entity_id' exists on a tag, and it doesn't.
[13:35:48] mikecmpbll: what do you expect to happen?
[13:36:10] mikecmpbll: an the entity is the polymorphic bit right, lemme see.
[13:37:01] mikecmpbll: probably use :entity in your presence validation, not :entity_id
[13:37:24] mikecmpbll: http://guides.rubyonrails.org/active_record_validations.html#presence
[13:40:02] alexday: its giving the same error Tags entity can't be blank
[13:40:36] alexday: oh wait. maybe because of validates :key, uniqueness: { scope: [:entity_id, :entity_type] } this ?
[13:43:00] alexday: like in a normal has_many relationship if you have accepts_nested_attributes_for . then one needs to specify inverse_of in the has_many side, so that the parent is saved first I guess before childs are saved
[13:43:38] mikecmpbll: /shrug. could do with some better debugging. i can't remember the precise behaviour.
[13:45:48] alexday: ok https://stackoverflow.com/a/17217629 here it says in the answer to save the parent first
[13:48:39] mikecmpbll: i wouldn't be so sure but meh, cba to test.
[13:48:45] jphase: has joined #RubyOnRails
[13:52:09] dionysus69: I have a problem in its infancy
[13:52:22] dionysus69: how do I handle production log file size
[13:52:53] dionysus69: do I just empty it regularly?
[13:53:29] cabotto: has joined #RubyOnRails
[13:53:38] elomatreb: Set up something like logrotate?
[13:55:34] dionysus69: thanks elomatreb :) will look at it
[14:07:06] jphase: has joined #RubyOnRails
[14:14:32] conta: has joined #RubyOnRails
[14:15:18] jottr: has joined #RubyOnRails
[14:23:00] apparition: has joined #RubyOnRails
[14:54:04] safetypin: has joined #RubyOnRails
[14:55:13] arBmind: has joined #RubyOnRails
[15:10:42] Silox|: has joined #RubyOnRails
[15:30:18] simmerz: has joined #RubyOnRails
[15:40:01] troys: has joined #RubyOnRails
[15:42:05] chouhoulis: has joined #RubyOnRails
[15:46:06] alexday: I cannot understand one thing. while doing @application.update(tags_attributes: application_params["tags_attributes"]) why is the validates :key, uniqueness: { scope: [:entity_id, :entity_type] } validation not triggered. I mean it should be triggered atleast on the database level, where I have said ` add_index :tags, [:key, :value, :entity_id, :entity_type], unique: true`
[15:47:44] alexday: where as while updating as in PATCH @application.update(application_params) the validation gets triggered when I have a duplicate key
[15:49:09] alexday: I do have validates_associated
[15:53:53] lacour: has joined #RubyOnRails
[15:54:42] irishfromua: has joined #RubyOnRails
[16:03:07] chouhoulis: has joined #RubyOnRails
[16:21:56] rfoust: has joined #RubyOnRails
[16:23:15] conta: has joined #RubyOnRails
[16:26:54] dionysus69: has joined #RubyOnRails
[16:37:57] cagomez: has joined #RubyOnRails
[16:48:25] marr: has joined #RubyOnRails
[16:51:10] gheegh: has joined #RubyOnRails
[16:53:19] jottr_: has joined #RubyOnRails
[16:55:09] jottr__: has joined #RubyOnRails
[16:57:25] TinkerTyper: has joined #RubyOnRails
[17:00:48] _mkw: has joined #RubyOnRails
[17:04:10] _mkw: Hello #rubyonrails, I was wondering if there is a way to suppress warnings from gems? When running rspec, I am getting an "already initialized constant" for Mime Type, but it is coming from a gem, not my code. All answers seem to deal with checking mime types first, but this does not affect the gem, only my code.
[17:04:27] stevednd: has joined #RubyOnRails
[17:04:31] _mkw: Error: `/Users/<retracted>/.rvm/gems/ruby-2.3.3/gems/actionpack-4.2.10/lib/action_dispatch/http/mime_type.rb:163: warning: already initialized constant Mime::PDF`
[17:04:38] stevednd: does anyone know why DateTime.iso8601('2017-10-02T12:32:42.123-05:00').to_time.utc.iso8601(9) returns "2017-10-02T17:32:42.123000000Z" in rails 4, and "2017-10-02T17:32:42.123000000+00:00" in rails 3?
[17:05:59] stevednd: more importantly how to get them to both return the same value?
[17:06:34] dminuoso: stevednd: Technically they are equivalent.
[17:07:01] dminuoso: If this has any side-effect, then you have a non-iso8601 conforming implementation.
[17:07:40] stevednd: dminuoso: I am aware that technically they are. we have two separate apis, and I would just prefer that they both return the exact same value
[17:08:26] dminuoso: stevednd: What ruby versions do you use on both installations? And what locale are you using?
[17:08:53] dminuoso: From my point of view it "is" the exact same value, just not the same representation.
[17:09:56] stevednd: dminuoso: both are currently on 2.2.8 locale is en_US
[17:14:12] one_zero: has joined #RubyOnRails
[17:18:14] conta1: has joined #RubyOnRails
[17:20:27] dminuoso: stevednd: Do you get `DateTime.iso8601('2017-10-02T12:32:42.123-05:00').to_time.utc.utc? #=> true` on both?
[17:21:33] dminuoso: Oh wait a moment, the 2.2.8 implementation is different.
[17:24:03] stevednd: dminuoso: I was just going to say that depending if the value comes from Time, or a DateTime affects whether it gets a Z or a +00:00 in rails 3
[17:24:24] dminuoso: stevednd: Well, actually just try it please.
[17:25:24] stevednd: yes, true on both 3/4
[17:31:08] dminuoso: stevednd: Yeah looking at the ruby source that would be the case.
[17:31:54] dminuoso: stevednd: DateTime is rigged to only produce an hour offset, while Time can do both (but for utc it defaults to 'Z')
[17:33:42] dminuoso: stevednd: Im not sure why one produces a DateTime, and the other produces a Time object. Im guessing you're obtaining this time object from rails somehow>?
[17:33:57] dminuoso: If you want a uniform behavior, it appears as if you have to just use strftime yourself (but please do adhere to iso8601)
[17:34:28] orbyt_: has joined #RubyOnRails
[17:35:00] stevednd: yeah, that's what I figured I would have to end up doing.
[17:35:53] stevednd: now I have to figure out parsing issues for taking in values,as there is issue there(though not between rails versions I don't think)
[17:40:04] stevednd: dminuoso: thanks for the help. you wouldn't happen to know if there is a way to tell Time.iso8601 to parse a time that comes in without a zone ending as UTC rather than local time, would you?
[17:45:04] chouhoulis: has joined #RubyOnRails
[17:58:09] mikecmpbll: has joined #RubyOnRails
[17:58:41] dminuoso: stevednd: Ruby's Time seems to just use a simple regex to make that determination
[17:59:17] dminuoso: stevednd: https://github.com/ruby/ruby/blob/trunk/lib/time.rb#L578
[17:59:56] dminuoso: So Im guessing you can do the same trick yourself and cover the case if no timezone is passed. Im not sure what the ISO standard says here though.
[18:01:09] stevednd: I'll take a look, thanks
[18:06:40] kies: has joined #RubyOnRails
[18:15:57] dviola: has joined #RubyOnRails
[18:22:25] chouhoulis: has joined #RubyOnRails
[18:23:02] crova: has joined #RubyOnRails
[18:23:27] ur5us: has joined #RubyOnRails
[18:24:43] LateralO1: has joined #RubyOnRails
[18:24:59] workmad3: has joined #RubyOnRails
[18:25:12] conta2: has joined #RubyOnRails
[18:27:34] jonash: has joined #RubyOnRails
[18:29:22] jonash: Hello! Just a quick question. I'm learning RoR. Coming from other Web frameworks, I wonder why ActiveRecord has so many potential SQL injections, even in basic stuff like exists? and order. Are there any sites where I can read more about the philosophy/history of that? Are there any plans to make all the methods SQL injection free?
[18:31:48] dminuoso: jonash: What makes you think there are any potential SQL injections?
[18:32:04] dminuoso: jonash: If you follow the official guides, they will only teach you styles that make it extremely hard to get SQL injections.
[18:32:05] jonash: https://rails-sqli.org/
[18:32:34] srinidhi: has joined #RubyOnRails
[18:33:45] dminuoso: jonash: I'd have to look through it for a complete answer, but generally the rule is: If you pass a string directly, then you take responsibility.
[18:33:48] LateralO1: has joined #RubyOnRails
[18:34:13] dgsan: Anyone know how to compute the average character count of non-empty lines of code for a Git repository?
[18:34:15] dminuoso: jonash: The .order() example is rather poor, since the canonical way is to do .order(foo: :asc) for example.
[18:34:53] dminuoso: jonash: And the `User.where("name = '#{params[:name]}' AND password = '#{params[:password]}'")` is completely silly too, since that's not even close to being standard rails code.
[18:35:02] dminuoso: jonash: And the article seems to be filled with this.
[18:36:25] dminuoso: jonash: Then all those usages of passing params to AR is silly dangerous. The rails guides teach you to use StrongParameters, which blocks these and many other attack vectors.
[18:37:46] workmad3: has joined #RubyOnRails
[18:38:11] jonash: dminuoso: Concrete example from GitHub codebase: https://githubengineering.com/like-injection/ is the Rails recommendation to always to sanitization for LIKE queries? Aren't there builtin LIKE queries (like "starts with", "ends with") that do it for you?
[18:38:36] orbyt_: has joined #RubyOnRails
[18:38:43] jonash: *to always do manual sanitization
[18:39:28] weaksauce: has joined #RubyOnRails
[18:39:53] dminuoso: jonash: That example is just normal. A much more common thread is to somehow give users indirect access to regular expressions. A situation called catastrophic backtracing can sometimes produce unfeasible computations.
[18:40:22] dminuoso: jonash: If you give users direct access to things like regex or like patterns, you need to carefully filter input in length and characters to not cause this.
[18:40:26] dminuoso: There's nothing AR can do.
[18:41:03] uksio: has joined #RubyOnRails
[18:41:50] jonash: dminuoso: I'm just wondering why there's no builtin safe "starts with" etc. filters
[18:42:20] jonash: Thb this feels like a giant minefield (though I haven't really used Rails for a real project yet, so I'm entirely clueless)
[18:42:24] dminuoso: Im not equipped to answer that
[18:42:37] dminuoso: jonash: That is web development, it has nothing to do with Rails.
[18:42:53] jonash: not sure what you mean
[18:43:51] dminuoso: jonash: Well in web development you expose a server to every attacker in the world. And by design web applications must accept input from users. The fact that you are aware about this and asking about it, means you're in a good spot.
[18:43:59] dminuoso: Not too many people pop in here talking about SQL injections.
[18:44:46] dminuoso: jonash: We have a thorough security guide though, that covers that topic amongst others: http://guides.rubyonrails.org/security.html
[18:46:09] orbyt_: has joined #RubyOnRails
[18:49:22] blackmesa: has joined #RubyOnRails
[18:49:34] jonash: dminuoso: IIUC AR sometimes does escaping/sanitization for you and it other cases you're responsible for doing that. From a practical point of view, doesn't that mean you always have to be concerned with potential SQL injections? Not suggesting that's true, just asking because I'm wondering.
[18:50:17] jonash: Like, doesn't that mean you'll have a list of safe and unsafe methods/syntaxes in your head for every code review?
[18:50:22] Maletor: has joined #RubyOnRails
[18:50:27] Maletor: with sidekiq, if i run model.save!; Worker.perform_async(model.id); is it possible to get race condition errors? because i am and i would have thought save! doesn't go to the next line unless COMMIT is run
[18:51:11] chouhoulis: has joined #RubyOnRails
[18:53:28] blackmesa1: has joined #RubyOnRails
[18:54:57] cr3: has joined #RubyOnRails
[18:56:33] cr3: hi folks, I'm trying to run upstream rails 4.2 tests under the activejob component but when I run "bundle exec rake test" I get "File does not exist: test/cases/adapter_test.rb" for each adapter. Any ideas what might be wrong with my setup?
[18:56:46] dminuoso: cr3: !rule3
[18:56:46] helpa: cr3: Clearly explain what is happening and create a Gist (http://gist.github.com), (formatted neatly please: http://bit.ly/1q75oia) of the code that is causing the problem you are encountering, as well as any useful output like stacktraces.
[19:00:20] cr3: dminuoso: this is the output I get but let me know if I should provide anything else: https://gist.github.com/cr3/78ae18b9c6cb16ab9de8c97b9cd2323a
[19:00:46] dviola: has joined #RubyOnRails
[19:00:57] cr3: dminuoso: it's upstream rails, revno 6b9a1ac which is under the 4.2 branch
[19:01:34] dminuoso: cr3: Im sorry. What exactly are you testing?
[19:01:40] dminuoso: Are you trying to run the rails testsuite itself?
[19:02:08] cr3: yes, sorry, that's what I meant by upstream rails 4.2 tests
[19:02:18] cr3: also, for reference, this is the commit I'm testing: https://github.com/rails/rails/commit/6b9a1ac484a4eda1b43aba7ed864952aac743ab9
[19:05:17] cr3: actually, /usr/local/bundle/gems/rake-12.2.1/lib/rake/rake_test_loader.rb outputs "File does not exist: backburner" and so forth for each adapter so I modified it to output the test it was running at the time.
[19:06:15] cr3: either rake_test_loader.rb is misleading or the exception raised is misleading because "File does not exist: backburner" doesn't seem right at all :(
[19:07:04] dminuoso: cr3: Just for completeness sake, how exactly do you invoke the test suite?
[19:07:16] dminuoso: cr3: And can you produce the output without your modifications?
[19:07:22] cr3: dminuoso: cd activejob; bundle exec rake test
[19:07:23] dminuoso: (Also you have pristine gems, right?)
[19:09:46] cr3: dminuoso: I did bundle install earlier today, so the gems should be pristine as far as I can tell. could it make a difference if I have another Gemfile in a parent directory (I don't know enough about rake to know if it tries to "help" by recursing up directories)?
[19:11:33] dminuoso: cr3: Can you gist your Gemfile.lock?
[19:11:48] alfiemax: has joined #RubyOnRails
[19:11:56] dminuoso: Oh wait, its commited, nevermind.
[19:15:41] cr3: dminuoso: good point, I deleted the commited one and when I ran bundle install, it created this lock in a parent directory of the rails root directory hence my question in parentheses. I'll double check the generated one with the commited one, thanks for the hint! https://gist.github.com/cr3/0863a5fc6dd778f4c805d43396022a15
[19:15:55] dminuoso: You naughty.
[19:16:22] cr3: yeah, when things don't work, all hell breaks loose :(
[19:20:19] alaing: has joined #RubyOnRails
[19:21:56] planigan: has joined #RubyOnRails
[19:34:51] dionysus69: has joined #RubyOnRails
[19:37:02] rfoust: has joined #RubyOnRails
[19:38:11] xaviergmail: has joined #RubyOnRails
[19:55:09] mtkd: has joined #RubyOnRails
[19:55:49] fschuindt: Hi there, folks. I'm trying to create a stats page in my app, a page which admins will access to see things like "how many accounts", "how many pospoted processes", blah blah, goes on grabbing data from different models. What is the recommended approach? Services? I don't want to have a 20+ line variable declarations in my controller action.
[19:56:09] fschuindt: postponed processes*
[20:03:25] dminuoso: fschuindt: You could create kind of view-models
[20:03:50] dminuoso: fschuindt: Do you need live data, or do you want something statsd-like?
[20:04:59] fschuindt: dminuoso: Hmm, never heard of. I think it's kinda optional, being live or not. We don't scale, but would be kinda nice. But I'm not sure if the other guys agree.
[20:05:10] NoGodDamnIdea: has joined #RubyOnRails
[20:05:35] gambl0re: has joined #RubyOnRails
[20:06:08] zacts: has joined #RubyOnRails
[20:08:55] dminuoso: fschuindt: One option would be to set up a view object that knows how to collect all these things, and exposes the collected information through methods. Your controller just passes it to the views, which then probe for various state.
[20:09:27] dminuoso: fschuindt: Another would be to set up a separate controller, and split those stats into small chunks that are provided by separate actions, and then load them asynchronously.
[20:10:23] fschuindt: dminuoso: Both great options, I'm reading more about view-objects to decide. Thank you very much, mate. You rock! :)
[20:13:58] mr-spoon: has joined #RubyOnRails
[20:14:16] cagomez: has joined #RubyOnRails
[20:21:42] alfiemax: has joined #RubyOnRails
[20:23:46] conta1: has joined #RubyOnRails
[20:26:02] lacour: has joined #RubyOnRails
[20:30:24] cagomez: has joined #RubyOnRails
[20:32:45] orbyt_: has joined #RubyOnRails
[20:32:53] Technodrome: has joined #RubyOnRails
[20:38:49] simmerz: has joined #RubyOnRails
[20:44:14] weaksauce: has joined #RubyOnRails
[20:46:11] cagomez: has joined #RubyOnRails
[20:59:12] fmcgeough: has joined #RubyOnRails
[20:59:27] alexday: I have a question. when there is accepts_nested_attributes_for :tags. and I override tags_attributes=(attrs) method. and I do a uniqueness check inside. how do I raise an error?
[21:00:57] alexday: as in not like raise error. like errors[:base] << :taken
[21:06:06] alexday: https://github.com/rails/rails/issues/4568 has this issue been resolved in rails 4?
[21:07:03] alexday: or this https://github.com/rails/rails/issues/1572
[21:08:52] orbyt_: has joined #RubyOnRails
[21:22:54] cagomez: has joined #RubyOnRails
[21:24:55] ^mtkd: has joined #RubyOnRails
[21:25:49] cagomez: has joined #RubyOnRails
[22:05:36] orbyt_: has joined #RubyOnRails
[22:08:34] arBmind: has joined #RubyOnRails
[22:17:28] brent__: has joined #RubyOnRails
[22:18:55] brent__: I have a controller that querys and returns different type of objects(User, Articles, etc.), I have serializers for the different type of objects that utilize ActiveModel::Serializer, how can I serialize each of those objects with the corresponding serializer?
[22:19:32] brent__: When I have results of the same Type, i was doing, ActiveModel::ArraySerializer.new(@contents, each_serializer: ArticleSerializer)
[22:27:00] nikivi: has left #RubyOnRails: ("Textual IRC Client: www.textualapp.com")
[22:33:10] Technodrome: has joined #RubyOnRails
[22:51:12] wethu: has joined #RubyOnRails
[22:53:13] mr-spoon: has joined #RubyOnRails
[22:53:47] troys: has joined #RubyOnRails
[22:55:24] zave: has joined #RubyOnRails
[23:04:01] blackmesa1: has joined #RubyOnRails
[23:05:14] mr-spoon: has joined #RubyOnRails
[23:12:29] jottr__: has joined #RubyOnRails
[23:21:03] apeiros_: has joined #RubyOnRails
[23:35:24] orbyt_: has joined #RubyOnRails
[23:39:59] tcopeland: has joined #RubyOnRails
[23:48:36] jphase: has joined #RubyOnRails
[23:54:36] jphase: has joined #RubyOnRails
[23:59:19] mtkd: has joined #RubyOnRails
[23:59:26] mikecmpbll: has joined #RubyOnRails