#RubyOnRails - 02 May 2017
« Back 1 day Forward 1 day »
[00:31:03] amperry: hey folks, I've got an AR query that runs over a model (Placement), a 1:1 association with that model (Ledger), and a many:1 association with Ledger (LedgerLines). I want to filter the LedgerLines by date, but I don't know of an AR query that will allow me. How would I filter, for each Placement |p|, p.ledger.ledger_lines to remove unwanted dates?
[01:58:12] amperry: thomasfedb: thanks, but that doesn't seem to work. I think this is because it includes the ledger of a ledger_line within a certain date, then takes all of the ledger_lines belonging to it, so even if I try to restrict the date, it grabs them all.
[05:03:58] MrPunkin: I’m trying to get some JSON from an API that is only available via a client-side JS library
[05:04:18] MrPunkin: so I’d like to evalute the JS on an HTML page to get the JSON, then use that JSON in my app.
[05:05:42] MrPunkin: there is no JSON url. The API is consumed entirely via JS and returns JSON via the JS requests.
[05:06:08] MrPunkin: the endpoint their own JS library uses requires the JS authentication system they developed.
[05:06:50] MrPunkin: Not that I’ve been able to figure out. They generate a token and I’m not sure exactly how.
[05:09:41] xhoy: @client.post('/loginage?action=login', 'login_field=login&password_field=password')
[06:05:08] DaniG2k: I have a nested namespace in lib/foo/v2/my_class.rb which I'm trying to access via Foo::V2::MyClass.new
[06:06:08] DaniG2k: I noticed that if I add it to the autoload_path in application.rb, the file gets loaded but it cases issues with Sidekiq
[09:13:27] universa1: cheeti: so why do you think validates_presence_of :service is a viable validation in your case? what does it actually do? what values are allowed for a presence validation, and which are not? (hint: try the .present? method on different values)
[09:41:52] MrCrackPotBuilde: hi i know how to do an image tag but little confused how i would turn this to ruby
[09:41:55] MrCrackPotBuilde: <figure class="elementwrapper"><a class="imgoverlay" href="#"><img src="images/demo/480x285.png" alt="">
[09:42:30] MrCrackPotBuilde: i thought id just have to remove the img src part as it looks like a separate part
[10:51:48] norfumpit: so ive got an rails 5 api endpoint which includes some bookmark, like its a resource endpoint and it includes in the response all the bookmarks on that resource. this is serialized by AMS. and ive got pundit for authorization. so i've got the resource finder wrapped in a policy_scope, but then i use includes(:bookmarks) ... how to authorize that?
[10:56:08] norfumpit: right now ive overriden the bookmarks method on the serializer and wrapped it in a scope, but this runs the query again, it doesnt use the preloaded data
[11:55:44] nacho_: Hi all, I'm currently migrating from rails 4.1 to 4.2 and came across some issues with the serializer
[12:09:11] helpa: We cannot help you with your problem if you don't show us your code. Please put it on http://gist.github.com and give us the URL so we can see it.
[12:13:48] nacho_: Here's the code https://gist.github.com/anonymous/d42436f966b18bb3c7f3048eca24069e
[12:14:14] nacho_: What rails is actually complaining about is that ActiveRecord::SerializationTypeMismatch (Attribute was supposed to be a Hash, but was a String.
[12:16:32] nacho_: Though I assume there would be the same with records to be updated since the code is kind of the same
[12:23:25] nacho_: I added the error log into the gist here: https://gist.github.com/anonymous/e4c3cea2be9fc527b69ecb5b53e5091b
[12:30:25] nacho_: With the post log added at the beginning so that it makes more sense understanding what kind of parameters arrive in there
[13:31:43] Knockys: Hello there ! I'm building a form and I need to find a way for the user to select images and I thought of how Google do it : http://bit.ly/2pBrnmq, does someone know a lib that can achieve that ? I'm using Materialize but there's nothing like that :/
[13:38:21] LyndsySimon: Is it a stupid idea to have a concern that is included in both models and controllers?
[13:38:45] LyndsySimon: It's for configuration handling, which on the app I'm working on is quite unique.
[13:41:29] LyndsySimon: Our config is a cascade, with "tenant" and "department" being the levels. The concern resolves the correct config object based upon the tenant and department in context for a model or controller instance.
[13:42:38] LyndsySimon: The config object is my own creation, and is where the vast majority of the business logic lives. The concern is just the way the correct config object is resolved. It provides hooks to specify the department to which an instance of a model belongs (or to which a controller belongs)
[13:44:09] nacho_: What I wonder is what exactly you do really need to configure in the model and the controller
[13:45:39] nacho_: What kind of configurations do you need to perform to modules and controllers?, just as curiosity
[13:46:43] LyndsySimon: I'm under time pressure at the moment, and there's too much business logic in there to share it at the moment.
[14:48:59] hotpancakes: Hi everyone. I'm trying out 5.1 now. After I install bootstrap via yarn, must I do anything else in application.css and/or application.js?
[15:15:48] sunya7a: I'm using foundation abide and have trouble with invalid fields that are marked for destruction. how do i tell abide to ignore these fields so that I can submit the form?
[15:28:25] soule: Hi, if i updated a linked_file in Capistrano, how can i get it to upload to my server?
[15:53:55] fryguy: soule: linked files/dirs are explicitly separate from the deployment, and are to be provided separately ahead of the deployment. you are responsible for maintaining the content of them yourself (we use our configuration management tool for this)
[17:07:31] brent__: I want to send an email if a user spent x seconds on a page, what is the best way to handle that and track how long the user spent on a page
[17:11:25] gheegh: Hey all.. anyone upgrading to Rails 5.1 yet? I'm having a WEIRD problem with the Twitter Gem. I have a User model, but the Twitter gem keeps trying to use it for the Twitter::User model.
[17:22:21] brent__: dminuoso: thanks, yeah looks like i can just do some sort of window.onLoad() that will initialize a start time and look for window.onLeave()? type fuction to see if the time has hit the x seconds and then ajax to a rails controller that will create the mailer
[17:22:36] brent__: just wondering if there was some sort of rails specific way to accomplish it better
[18:26:51] ornerymoose: Hello. I’m having a hard time wrap my head around how to correctly update a subscriber’s current categories. Can someone offer some insight? https://gist.github.com/ornerymoose/4952c5fa42a7b3c5779576af3aeabcb5 I have quite a few users to update, so would rather not do it manually one by one. (rails_console.rb) is the file in question in the Gist
[19:00:10] aFineDay: Hey, I'm having trouble When I push a form from User A to User B's page using ActionCable the form wont verify. I wrote a SO question with a different architecture because I thought there might have been a problem pushing from another user's session, but the issue is still there. Here's the question https://stackoverflow.com/questions/43549899/a-form-inserted-through-actioncable-wont-verify
[19:33:58] hnanon: I'm creating the customer first, then if successful, charging them (upgrading), then if successful, saving the user.
[19:35:53] dminuoso: Which is why a) you have some abstract high level description of your problem that I cant relate to your code.
[19:38:25] dminuoso: hnanon: As it stands right now all stripe errors end up doing the same thing. So catch them in a single rescue.
[19:40:02] dminuoso: hnanon: That's fine, but even then move that into a separate method or something.
[19:40:25] dminuoso: hnanon: Anyway. The important thing is not to dry up right now, but make a test case.
[19:40:37] hnanon: The weird thing is that when I trigger an error, and resubmit, it PATCHES instead of POSTS.
[19:45:36] dminuoso: hnanon: The problem is you have a really large code example and a very abstract description. Try to reduce your code as much as possible so that you can point at a single line of code and ask me "why does this do X and not Y" ?
[19:45:59] dminuoso: hnanon: Note this is not for me, this is a debugging technique and will help you debug things on your own.
[19:57:08] mlt-: So params is not available when declaring before_action ? I want it only if a certain parameter was set
[20:03:38] rails4444: some one knows if it is possible to use a rails validation method on a delegated attribute?
[20:31:01] amperry: Hey folks, I'm trying to get an AR query right, but I'm trying to filter a has_many association by date and still getting all the results. I think I know *why*, but I don't know how to rewrite it. Gist is here: https://gist.github.com/amp108/f9006426ac06d713716649ec38f32d7f
[21:56:07] amperry: If anyone's joined since last I mentioned it, I've got a nested tables query problem at: https://gist.github.com/amp108/f9006426ac06d713716649ec38f32d7f. Boils down to how to place conditions on a doubly nested query.
[21:57:42] Leonardo_0112: I'm reading this ebook online https://www.railstutorial.org/book/_single-page. Is there a way to download it in PDF? So I can read it in my tablet offline.
[21:59:59] Alayde: Leonardo_0112: Afaik, no. If you want to read it offline, you have to purchase a copy.
[22:28:01] amperry: Radar: probably because I've been trying it both ways and left both in when I hould have taken it out :S
[22:37:11] amperry: Radar: what I suspect is happening is that the query filters out the unwanted ledger_lines, but then grabs the containing ledgers and all of their ledger_lines again.
[22:45:13] amperry: Radar: why unnecessary? I'm trying eventually to get a list, broken down by apt, of all the transactions (ledger_lines) that happened for it within a date range.
[22:46:25] amperry: okay. I am using it in the view, however, but I'll remove it if you think that's the better thing to do.
[22:47:01] Radar: Ok, if you're using it in the view then it probably makes sense for that to be an includes association
[22:50:38] amperry: ? That's what I don't get about how this works (or, one of the things I don't get). The Ledger joins LedgerLines, but not the Placement. Can I .joins(:ledger_lines) directly like that?
[22:52:22] amperry: List broken out first by apt, then by ledger_line date, of all lines within a given date range.
[23:42:37] amperry: Radar: fixed it by going backwards from lines -> ledger -> placement -> apt; Placement was supposed to be a container object, but this worked as needed. Thanks for your help.