« Back to channel list

#RubyOnRails - 24 September 2017

« Back 1 day Forward 1 day »
[00:00:25] orbyt_: has joined #RubyOnRails
[00:28:45] timdotrb: has joined #RubyOnRails
[00:33:43] havenwood: has joined #RubyOnRails
[00:34:43] FastJack: has joined #RubyOnRails
[00:35:52] gr33nw00d: has joined #RubyOnRails
[00:36:24] gr33nw00d: In rails 5 if I'm using rspec `rails new myapp -T`, is it possible to change the `rails test` command so it executes `bundle exec rspec` ?
[00:44:00] xco: has joined #RubyOnRails
[00:53:09] bronson: has joined #RubyOnRails
[01:01:26] xco: has left #RubyOnRails: ()
[01:16:29] s2013: has joined #RubyOnRails
[01:18:03] beilabs: has joined #RubyOnRails
[01:40:44] beilabs: has joined #RubyOnRails
[01:57:37] orbyt_: has joined #RubyOnRails
[02:48:03] irishfromua: has joined #RubyOnRails
[02:51:37] one_zero: has joined #RubyOnRails
[02:54:03] bronson: has joined #RubyOnRails
[02:57:55] gr33nw00d: has joined #RubyOnRails
[03:29:16] timdotrb: has joined #RubyOnRails
[03:31:34] irishfromua: has joined #RubyOnRails
[03:33:52] timdotrb: has joined #RubyOnRails
[03:35:14] jgpawletko: has joined #RubyOnRails
[03:35:27] timdotrb: has joined #RubyOnRails
[03:36:15] timdotrb: has joined #RubyOnRails
[03:36:55] timdotrb: has joined #RubyOnRails
[03:45:51] irishfromua: has left #RubyOnRails: ()
[03:53:54] irishfromua: has joined #RubyOnRails
[03:55:49] jphase: has joined #RubyOnRails
[03:55:59] wethu: has joined #RubyOnRails
[03:58:11] irishfromua: has left #RubyOnRails: ()
[04:00:09] irishfromua: has joined #RubyOnRails
[04:17:55] ayonkhan: has joined #RubyOnRails
[04:25:12] irishfromua: has joined #RubyOnRails
[04:38:12] irishfromua: has joined #RubyOnRails
[04:49:01] irishfromua: has joined #RubyOnRails
[04:54:39] dogweather: has joined #RubyOnRails
[04:55:23] bronson: has joined #RubyOnRails
[04:58:33] kapil___: has joined #RubyOnRails
[05:04:26] tamouse__: has joined #RubyOnRails
[05:05:16] irishfromua: has joined #RubyOnRails
[05:14:58] irishfromua: has joined #RubyOnRails
[05:26:46] Saukk: has joined #RubyOnRails
[05:28:24] srinidhi: has joined #RubyOnRails
[05:34:06] timdotrb: has joined #RubyOnRails
[05:39:20] rh10: has joined #RubyOnRails
[05:40:05] rh10: guys, which way better to deploy ruby (rails) app to 2 servers? app use mysql server and app server passenger
[05:40:58] rh10: which one will be more truly and handy :)
[05:41:18] tamouse__: rh10: are saying one database server and one application server?
[05:41:54] rh10: tamouse__, yep
[05:42:28] tamouse__: that is generally better for production deploys, at least to start with
[05:43:34] rh10: tamouse__, but what tools i have to use to this?
[05:49:43] tamouse__: rh10: there are a few different tools: chef, puppet, ansible, and also the old fashioned do it by hand way
[05:49:58] rh10: tamouse__, got it
[05:50:10] tamouse__: capistrano can be used to deploy new versions of your app when you have the server provisioned
[05:51:41] tamouse__: at one point, i worked on this thing: https://github.com/ackmann-dickenson/rails_template which is a tool to generate an ansible-based rails app that will work for dev and prod. it might be instructive, idk
[06:03:00] s2013: has joined #RubyOnRails
[06:04:53] apparition: has joined #RubyOnRails
[06:09:21] dminuoso_: has joined #RubyOnRails
[06:25:36] rh10: tamouse__, thanks! i'll take a look
[06:32:02] srinidhi: has joined #RubyOnRails
[06:43:43] xibalba: has joined #RubyOnRails
[06:45:48] psychoslave: has joined #RubyOnRails
[06:46:20] DTZUZO: has joined #RubyOnRails
[06:56:16] bronson: has joined #RubyOnRails
[06:56:53] DTZUZO: has joined #RubyOnRails
[07:11:24] srinidhi: has joined #RubyOnRails
[07:11:51] dionysus69: has joined #RubyOnRails
[07:11:54] fugee: has joined #RubyOnRails
[07:28:37] arathald: has joined #RubyOnRails
[07:37:49] irishfromua: has joined #RubyOnRails
[08:05:18] irishfromua: has joined #RubyOnRails
[08:05:50] wethu: has joined #RubyOnRails
[08:13:15] marr: has joined #RubyOnRails
[08:16:02] hervie: has joined #RubyOnRails
[08:18:44] srinidhi: has joined #RubyOnRails
[08:21:44] gambl0re: has joined #RubyOnRails
[08:47:37] aphel: has joined #RubyOnRails
[08:51:18] ur5us: has joined #RubyOnRails
[08:57:16] bronson: has joined #RubyOnRails
[09:09:57] ur5us: has joined #RubyOnRails
[09:12:39] timdotrb: Evening, all
[09:15:40] timdotrb: How would I go about showing a page on my site with a loading indicator while the server processes some data, then displaying the processed data? Would I have to do a JS request and display a partial after the page loads?
[09:25:18] lxsameer: has joined #RubyOnRails
[09:25:48] ur5us: has joined #RubyOnRails
[09:29:23] dminuoso_: timdotrb: Just do it manually, its simple
[09:30:04] dminuoso_: timdotrb: https://gist.github.com/anonymous/eb675071af422c5963a09991ca794576 something along those lines perhaps
[09:30:43] dminuoso_: Thats what I just happened to save a minute ago, it probably wont work as is, but you get the idea.
[09:31:06] timdotrb: dminuoso_: yea, so basically do it all via js
[09:31:33] ur5us: has joined #RubyOnRails
[09:31:35] dminuoso_: timdotrb: Its best to avoid all that rails magic that lives in $. and remove: true and what not - and just take the driver seat yourself
[09:32:10] timdotrb: Yea, makes sense.
[09:33:02] apparition: has joined #RubyOnRails
[09:35:25] timdotrb: dminuoso_: so I’d need to create a separate controller action / route for JS to call to return data? Then execute the JS call on document load?
[09:36:04] dminuoso_: timdotrb: Not necessarily. It seems to make sense to stay within the same controller
[09:36:17] dminuoso_: timdotrb: But depending on what you want to do, a separate action or just a separate format handler is enough
[09:36:51] timdotrb: dminuoso_: I’m trying to implement this for a search. So the user hits the home page, enters the search params, then is taken to the search results pages
[09:37:13] timdotrb: Right now they have to wait for the search results to finish processing. I’d like to have a loading indicator and then insert search results when they’re done
[09:37:46] dminuoso_: timdotrb: Are you using turbolinks?
[09:38:00] timdotrb: dminuoso_: not currently
[09:39:00] dminuoso_: timdotrb: Do you need to keep the URL in sync with that search action?
[09:39:12] timdotrb: dminuoso_: yes
[09:40:05] dminuoso_: timdotrb: Yeah just do it like in my gist, and additionally do a history.push(...whatever)
[09:40:28] dminuoso_: But should you make this a pattern, I think you ought to look into turbolinks actually
[09:40:47] ur5us: has joined #RubyOnRails
[09:41:04] timdotrb: Yea. I’m not opposed to turbolinks
[09:41:11] timdotrb: Just didn’t really have a use for it previously
[09:41:42] timdotrb: In the past, it has caused more issues than intended
[09:41:47] dminuoso_: Indeed. ;-)
[09:42:31] dminuoso_: Its quite fine if you understand how it works, but you have to respect that it makes the DOM.. different.
[09:50:12] timdotrb: My issue was my search results use a JS to load remote image and data
[09:50:46] timdotrb: I was originally working on this like a year ago, so the whole thing is a little fuzzy
[10:11:57] glasz: has joined #RubyOnRails
[10:17:00] dminuoso_: timdotrb: Just for reference, this is what Im going with now; https://gist.github.com/anonymous/50138d3cd2c3e8415ab5561a3873e703
[10:17:43] timdotrb: That’s lookin’ pretty good
[10:18:57] dminuoso_: Hardly. It'd be looking good if I was using RxJS
[10:20:59] dminuoso_: timdotrb: Of course you need webpacker if you wanted async/await, ES6 modules, object rest spread, etc. ;-)
[10:21:44] timdotrb: That’s a little more intense than what I’m looking for, but handy to have
[10:23:16] dminuoso_: Well it can all be written with plain ES5, its really simple
[10:23:17] dminuoso_: timdotrb: https://gist.github.com/anonymous/37f96bcf483faf0ab1ec8b2fff5ac6a8
[10:23:42] dminuoso_: ACTION smiles
[10:26:15] rfoust: has joined #RubyOnRails
[10:31:27] mikecmpbll: has joined #RubyOnRails
[10:37:42] rgr_: has joined #RubyOnRails
[10:56:49] mikecmpbll: has joined #RubyOnRails
[10:57:00] ahrs: has joined #RubyOnRails
[10:58:35] bronson: has joined #RubyOnRails
[10:58:48] timdotrb: has joined #RubyOnRails
[10:59:47] AzaToth: has joined #RubyOnRails
[11:05:05] Jameser: has joined #RubyOnRails
[11:17:03] drale2k: has joined #RubyOnRails
[11:19:10] dminuoso_: Opinions: I want to make the coupling between controllers and views more obvious, and pass everything explicitly through locals (no more instance variables in controllers)
[11:19:50] dminuoso_: And while Im at it, strictly avoid implicit render calls, so that every action has to have something like: `render :index, locals: { user: user }`
[11:24:36] mulander: has joined #RubyOnRails
[11:26:12] mulander: is there a preferred way to have a resource available on all pages? Example: List of last published articles with an option to search acccessible on all pages. Essentially I want the Articles.index controller and view rendering on the application level
[11:26:39] mulander: but I don't like the idea of duplicating the index action on the application level or moving the whole article resource there
[11:28:47] workmad3: has joined #RubyOnRails
[11:33:15] Jameser: has joined #RubyOnRails
[11:35:10] NoGodDamnIdea: has joined #RubyOnRails
[11:37:44] mulander: or to rephrase my question
[11:37:55] mulander: How does one render a view across the whole application in rails while still pulling logic+data from it's dedicated controller?
[11:41:10] dminuoso_: mulander: layouts serve that purpose
[11:42:00] dminuoso_: mulander: Just have the layout render a partial, which in turn uses JavaScript to fetch that special bit.
[11:42:33] dminuoso_: mulander: The thing is that it's not the view that pulls logic from its dedicated controller -> the relation ship is the other way around
[11:42:37] dminuoso_: Its controllers that invoke views.
[11:42:56] dminuoso_: And they can render any view they like (even outside their "controller namespace")
[11:45:07] dminuoso_: So you would have some LatestPages Controller with some appropriate views, add a route /latestPages (or whatever), then have your layout insert some anchor, add JS to fetch from /latestPages and insert the partial it retrieves into the anchor
[11:45:52] mulander: the index view I want to share across the application is already remote (pagination/filtering) - I didn't see a way to re-use it while keeping the javascript unobtrusive
[11:46:14] dminuoso_: mulander: You could use an <iframe> that fetches that partial.
[11:47:39] dminuoso_: Though idk what "keeping the javascript unobstrusive" means
[11:48:34] mulander: dminuoso_: as in having the page work without javascript enabled, the default way rails implements ajax requests allows for that
[11:48:58] dminuoso_: My 2 cents on the subject: screw unobstrusive javascript
[11:49:06] mulander: hence I was thinking if there was already a solution that allows this without manually triggering a fetch that would make the list always empty for people with no javascript
[11:50:00] mulander: and yes I will probably just do the call manually
[11:50:01] dminuoso_: I dont see a trivial way to do this in rails.
[11:50:25] mulander: the only vanilla way I think would be to duplicate the logic in the application controller but that felt ultra messy
[11:50:40] mulander: I also saw some cells gem that I think would allow exactly what I want
[11:50:46] mulander: but don't think it's worth the extra complexity
[11:51:05] mulander: either way, you helped - I needed verification that there is no obvious railsy way to do it that I just missed.
[11:51:09] mulander: so thank you
[12:22:46] mikecmpbll: has joined #RubyOnRails
[12:26:05] mices: has joined #RubyOnRails
[12:47:34] banisterfiend: has joined #RubyOnRails
[12:49:41] paranoicsan: has joined #RubyOnRails
[12:59:31] bronson: has joined #RubyOnRails
[13:05:29] jottr: has joined #RubyOnRails
[13:10:29] netzfisch: has joined #RubyOnRails
[13:17:21] netzfisch: has joined #RubyOnRails
[13:22:06] drale2k: has joined #RubyOnRails
[13:50:04] Rodya_: has joined #RubyOnRails
[14:10:20] ShalokShalom_: has joined #RubyOnRails
[14:12:52] beilabs: has joined #RubyOnRails
[14:56:33] beilabs: has joined #RubyOnRails
[15:00:24] bronson: has joined #RubyOnRails
[15:05:59] Stabs: has joined #RubyOnRails
[15:18:41] psychoslave: has joined #RubyOnRails
[15:21:49] orbyt_: has joined #RubyOnRails
[15:23:49] conta: has joined #RubyOnRails
[15:23:50] beilabs: has joined #RubyOnRails
[15:24:38] tamouse__: has joined #RubyOnRails
[15:27:57] netzfisch: has joined #RubyOnRails
[15:28:57] DTZUZO: has joined #RubyOnRails
[15:34:06] kapil___: has joined #RubyOnRails
[15:47:15] francuz: has joined #RubyOnRails
[15:47:26] francuz: Hello everyone, I have users and they can have serveral types of picture : private profile, public proile, avatar, signature etc... The same picture can be used at several places and by several users.
[15:47:27] francuz: So I have a model Picture(url), a model User, and a model JoinPictureUser(picture_id, user_id, role). And a few Method inside User to get the good picture.
[15:47:27] francuz: The question is => isn't there a way to make that automatically? I taught about not having a "JoinPictureUser" but a "JoinAvatarUser" table, a "JoinProfileUser" table etc... which would work but is kinda ugly(at least to me).
[15:50:33] tamouse__: francuz: i'm not sure what you're asking for, but have you looked at polymorphic tables?
[15:51:54] francuz: yeah, but i'd like to add not only a "picturable_type" to the table but also a "role", and for it to be automated, not sure how to explain it exactly ...
[15:53:01] conta: has joined #RubyOnRails
[16:05:01] beilabs: has joined #RubyOnRails
[16:11:20] s2013: has joined #RubyOnRails
[16:16:40] coder2000: francuz: on the polymorphic table you can have a field that defines what type of photo it is. As to allowing the same photo on multiple users I am stuck.
[16:29:53] gr33nw00d: has joined #RubyOnRails
[16:29:59] gr33nw00d: How can I replace the test command in rails 5
[16:30:07] gr33nw00d: i9u8ygtfdrsza`11se56rdxfgy789jn mklp[]\
[16:30:54] matthewd: gr33nw00d: I don't like your chances
[16:31:25] gr33nw00d: Darn, I was really hoping to run my rspec tests with `rails test`
[16:32:54] coder2000: you can use rails spec
[16:34:22] dviola: has joined #RubyOnRails
[16:35:17] Rodya_: has joined #RubyOnRails
[16:37:15] jottr: has joined #RubyOnRails
[16:46:20] defsdoor: has joined #RubyOnRails
[17:00:25] dminuoso_: My controller is receiving a param that is never being sent over the wire.
[17:01:55] bronson: has joined #RubyOnRails
[17:02:50] dminuoso_: https://gist.github.com/anonymous/5e92a2d7b69469032c0360d9155e83df
[17:03:21] dminuoso_: Why is rails being so hateful?
[17:04:43] dminuoso_: https://imgur.com/PeWVaig
[17:09:31] coder2000: Do you have a mac_addr field on your form?
[17:10:30] dminuoso_: The issue isn't mac_addr, it's that Im receiving a parameter ppp_session.
[17:10:32] dminuoso_: I shouldn't.
[17:11:27] dminuoso_: This happens in a couple other places, and there's absolutely nothing fancy that I'm doing.
[17:15:51] dminuoso_: ACTION pokes matthewd 
[17:15:59] dminuoso_: This is some shady StrongParameters business, isn't it?
[17:16:24] dminuoso_: It's as if rails is punishing me for not using form helpers.
[17:17:15] tbuehlmann: I'm certain it's some of your javascript
[17:17:40] dminuoso_: Well if you dont trust my devtools output, would you like a wireshark screenshot?
[17:19:39] tbuehlmann: have you checked whether it has to do with your ES9 transpilerpack?
[17:21:03] dminuoso_: I think you misunderstood what a Future is about.
[17:21:15] fugee: has joined #RubyOnRails
[17:21:35] dminuoso_: But fine, have it your way
[17:23:10] dminuoso_: tbuehlmann: wireshark agrees, there's no ppp_session incoming.
[17:23:23] dminuoso_: I have a distinct feeling that Im not quite respecting the params format rails is expecting
[17:24:14] fugee: i'm having a problem with mailboxer, sent messages don't appear in recipients inbox
[17:24:33] matthewd: dminuoso_: Route?
[17:27:08] dionysus69: has joined #RubyOnRails
[17:27:19] dminuoso_: matthewd: https://gist.github.com/anonymous/77b0913f70020bf1576558eeee3f23fb
[17:27:53] dminuoso_: But when I tried removing the resources/collection routes, and replaced it with two straight get/post routes - it still reproduced.
[17:28:53] matthewd: Hmm... rack middleware? :/
[17:29:33] matthewd: I'm struggling to think of a *way*, let alone a reason, we'd be inventing a parameter
[17:35:20] dminuoso_: matthewd: Okay I know it's somehow tied to the controller name.
[17:35:57] dminuoso_: The middleware stack is untouched I think https://gist.github.com/anonymous/e4583806d946c40e053de928ca988d7b
[17:36:12] dminuoso_: Well except warden. Let me unplug that
[17:37:29] dminuoso_: It seems to create a key, whose value is an object consisting of the rest of the params
[17:37:33] dminuoso_: Parameters: {"search"=>{"mac_addr"=>""}, "ppp_foo"=>{"search"=>{"mac_addr"=>""}}}
[17:38:00] matthewd: Yes, that's a thing
[17:38:23] matthewd: http://api.rubyonrails.org/v5.1/classes/ActionController/ParamsWrapper.html
[17:40:40] dminuoso_: matthewd: This might be a silly question, but what exactly is the purpose of that?
[17:41:12] dminuoso_: The guide doesn't compute
[17:43:56] dminuoso_: Well thanks anyway
[17:46:12] otherj: has joined #RubyOnRails
[17:46:22] matthewd: dminuoso_: I think it might be an XMLism, actually
[17:47:05] jgpawletko: has joined #RubyOnRails
[17:47:22] matthewd: dminuoso_: If you had an XML request body (back in the time when that was an acceptable thing to do), you'd need a single root element, so that's what your controller would expect
[17:48:14] matthewd: Then you switch to JSON, and decide to pull the parameters straight into the root object.. but your controller wants to handle both
[17:49:40] dminuoso_: matthewd: Ah. That sounds quite reasonable actually. What is interesting, that I have mindlessly ignored this initializer file or the default setting for years.
[17:49:43] matthewd: I guess it also provides a way of getting all the probably-relevant params while skipping the more administrative ones
[17:50:02] dminuoso_: well I can see some use with :include as a poor-mans strong params helper
[17:50:47] matthewd: Even without include, I think the default exclusions would be somewhat useful
[17:53:16] mices: i'm having a problem with mailboxer, sent messages don't appear in recipients inbox
[18:02:57] timdotrb: has joined #RubyOnRails
[18:03:06] netzfisch: has joined #RubyOnRails
[18:04:24] ahrs: has joined #RubyOnRails
[18:09:30] Saukk: has joined #RubyOnRails
[18:10:08] timdotrb: has joined #RubyOnRails
[18:41:18] dionysus69: has joined #RubyOnRails
[19:02:42] bronson: has joined #RubyOnRails
[19:14:12] bruno-: has joined #RubyOnRails
[19:30:42] andrevan: has joined #RubyOnRails
[19:31:51] hive-mind: has joined #RubyOnRails
[19:33:03] gusrub: has joined #RubyOnRails
[19:34:07] marr: has joined #RubyOnRails
[19:49:49] s2013: has joined #RubyOnRails
[19:54:12] desnudopenguino: has joined #RubyOnRails
[19:55:08] fragamus: has joined #RubyOnRails
[19:59:29] orbyt_: has joined #RubyOnRails
[20:27:34] gusrub: has joined #RubyOnRails
[20:50:09] cagmz: has joined #RubyOnRails
[20:58:30] gusrub: has joined #RubyOnRails
[21:03:41] bronson: has joined #RubyOnRails
[21:22:50] jottr: has joined #RubyOnRails
[21:45:47] mheld: has joined #RubyOnRails
[21:46:57] mheld: hey y'all -- can't seem to figure out why my STI keeps on getting blocked by rails. Have Feed, NewsFeed, and WeatherFeed (with WeatherFeed and NewsFeed being subclasses of Feed). Keep on getting "ActiveRecord::SubclassNotFound: Invalid single-table inheritance type: NewsFeed is not a subclass of Feed"
[21:49:25] mheld: ah I think the problem is that I have a has_and_belongs_to_many with STI attached to it
[21:53:43] mheld: eh fuck it, I don't *need* to have Feed be a super-class of NewsFeed or WeatherFeed
[21:59:59] gusrub: has joined #RubyOnRails
[22:09:36] arBmind: has joined #RubyOnRails
[22:15:13] orbyt_: has joined #RubyOnRails
[22:15:47] bios: has joined #RubyOnRails
[22:18:41] bios: hey *. I'm trying to use routing constraints to allow for subdomains to be used as a parameter, unless the subdomain is in a list of 'reserved' subdomains. Is this the right way to approach this?
[22:18:44] opekktar: has joined #RubyOnRails
[22:34:30] Radar: bios: what subdomains are reserved and why?
[22:38:25] gusrub: has joined #RubyOnRails
[23:04:50] bronson: has joined #RubyOnRails
[23:05:58] quazimodo: has joined #RubyOnRails
[23:24:13] h7br1x: has joined #RubyOnRails
[23:26:40] h7br1x: Forgive me if this is simple, but I've googled and the combo of words returns nothing helpful- I'm trying to change the default way rails handles date formats in regards to a URL param, right now it recognizes "2017-09-24" as a date but "09-24-2017" is not recognized. Any suggestions?
[23:26:59] Radar: h7br1x: what do you mean by "recognises"?
[23:27:04] Radar: In what context?
[23:29:29] h7br1x: So I have a url with a route with "/:id/:date" and in my view my I have something using params[:date], so if i visit foo.com/:id/2017-09-24 rails loads the page fine. If I put foo.com/:id/09-24-2017 it says invalid date. I changed the default in my en.yml but it didn't work.
[23:35:31] h7br1x: Any ideas, Radar?
[23:45:52] Radar: h7br1x: Where does it say "invalid date" exactly?
[23:47:41] h7br1x: ArgumentError - invalid date:
[23:47:41] h7br1x: activesupport (5.0.6) lib/active_support/core_ext/string/conversions.rb:45:in `to_date'
[23:48:45] Radar: h7br1x: and what's the remainder of that stacktrace?
[23:48:53] Radar: h7br1x: Where are you handling params[:date] in your controller?
[23:52:28] h7br1x: https://gist.github.com/ktdmedia/9a78fe12ddace6f0f7f315d20e4d1481
[23:52:51] h7br1x: Radar: Not using it in the controller currently.
[23:53:25] Radar: h7br1x: what is the remainder of the stacktrace then? Rails does not automatically process dates.
[23:54:16] h7br1x: Radar: commented on gist w/ stacktrace.
[23:56:46] Radar: <%= params[:date].to_date %>
[23:56:52] Radar: Seems like this line is probably the cause
[23:56:55] Radar: Look at Date.strptime
[23:57:16] Radar: as for why to_date doesn't work, try to think what date Rails should tell you that 12-12-12 is
[23:57:32] Radar: Or closer to the case you have: 12-11-2017
[23:57:40] Radar: Is that 11th December 2017? Or 12th November 2017?
[23:59:49] one_zero: has joined #RubyOnRails