Activity Graph

Page 1 of 6 | Next »


[00:11:28] MrPunkin: Anyone in here?
[00:24:49] MrPunkin: Quit: MrPunkin
[18:56:56] MrPunkin: has joined #RubyOnRails
[19:06:32] MrPunkin: Can anyone help me diagnose why my helper methods aren’t available in view in Rails 5?
[19:50:11] MrPunkin: Quit: MrPunkin


[23:49:49] MrPunkin: has joined #RubyOnRails
[23:51:16] MrPunkin: Can anyone tell me why I’m getting a no method error in view template just calling a helper from ApplicationHelper in Rails 5? I don’t haveinclude_all_helpers set to false anywhere, and my understanding is Rails 5 should auto-load all helpers


[15:57:23] MrPunkin: has joined #RubyOnRails
[15:58:21] MrPunkin: is there a way to retain a requests format (.json, .csv, etc) when using the redirec() method in rails routes?
[16:41:47] MrPunkin: Quit: MrPunkin


[18:41:26] MrPunkin: has joined #RubyOnRails
[18:44:25] MrPunkin: Can anyone tell me why calling an association’s “update_attributes” method is triggering a before_save callback of my parent model?
[18:44:29] MrPunkin: is that normal?
[18:45:26] MrPunkin: So how can I update this associated model without triggering this before_save on my parent model? Is there a way? Rails 5
[18:45:59] MrPunkin: Right, so I need to make these simple column changes on the associated model via an update_all or something so that callbacks are skipped?
[18:46:32] MrPunkin: I have Statement which belongs_to Product. I update Product during calculation of statements, which triggers Statement#before_save
[18:59:38] MrPunkin: I have no “autosave” options set in this relationship lupine… would that matter?
[19:51:10] MrPunkin: Quit: MrPunkin


[16:01:31] MrPunkin: has joined #RubyOnRails
[17:11:51] MrPunkin: Quit: MrPunkin


[00:07:20] MrPunkin: has joined #RubyOnRails
[00:32:08] MrPunkin: Quit: MrPunkin


[00:15:57] MrPunkin: Quit: MrPunkin


[18:23:56] MrPunkin: has joined #RubyOnRails
[21:52:41] MrPunkin: Quit: MrPunkin
[22:56:15] MrPunkin: has joined #RubyOnRails
[23:01:37] MrPunkin: Does Rails 5 provide any good built in ways to bulk copy many DB records?


[17:59:47] MrPunkin: has joined #RubyOnRails
[18:00:36] MrPunkin: Hey all. Given a class like this ( how can I extend it via concerns? The normal method doesn’t seem to be changing the dynamic subclasses of Basecamp3 at all.
[18:10:17] MrPunkin: I need to extend that existing Basecamp3 ‘eigenclass’ so I can overwrite the connect method.
[20:55:59] MrPunkin: tpanarch1st: That’s because Rails defaults to Postgres which is a different DB.
[20:56:16] MrPunkin: tpanarch1st: You can install it, or you can opt to make your Rails project use MySQL instead, or any of the many DB clients available
[21:02:12] MrPunkin: I don’t believe it gets installed, I believe you still need to install it. I’ve never used it though, so I’m not the one to ask.
[21:02:53] MrPunkin: I believe it just expects it and installs the gem to interact with it, and you need to configure it with the port, host, username, password, etc to use it.
[21:02:57] MrPunkin: as you would with MySQL
[21:05:57] MrPunkin: I do all MySQL and as such have to install the mysql2 gem
[21:06:35] MrPunkin: tpanarch1st:
[21:07:53] MrPunkin: tpanarch1st: nope that seems like a good first step to get Ruby ready on your system before diving into rails.
[21:08:28] MrPunkin: That’s what I always do first on a new machine, get RVM installed with whatever ruby I want and the rails version I want
[21:09:11] MrPunkin: regarding Postgres / MySQL / SQLite… you’re going to need to do your research as to which to use. If you are familiar with MySQL I’d say just stick with that unless you wanna learn something new
[21:14:10] MrPunkin: tpanarch1st: I’m not really sure. SQLite is probably the most popular by installs, as they claim to be on most mobile phones and computers by default
[21:14:18] MrPunkin: but it doesn’t have a lot of the power features of the others I don’t think
[21:16:51] MrPunkin: I use Atom and am happy with it. I primarily just use it for writing code and then running my tests within the app
[21:18:11] MrPunkin: yeah I believe it’s just `rails serve` or something along those lines
[21:19:30] MrPunkin: You can run any normal terminal commands within Atom I believe, but I tend to keep my Mac terminal open instead
[21:20:19] MrPunkin: Yeah no problem :)
[21:21:12] MrPunkin: You’d be best to start out learning about basic rails “scaffolding”
[21:21:36] MrPunkin: which is a part of that getting started guide I sent a link to
[21:27:06] MrPunkin: tfitts: an easy way would be to simply hijack the as_json method on your model and override or delete the key in question based on your own criteria
[21:32:44] MrPunkin: Can anyone tell me how to add methods to a class defined in a gem? I’ve tried every example I can find online and none are making them available on instances of that class.
[21:54:13] MrPunkin: Quit: MrPunkin


[17:11:51] MrPunkin: has joined #RubyOnRails
[17:14:03] MrPunkin: Is there a good way to parse and maintain multiple cookies across multiple requests with Net::HTTP?
[17:32:10] MrPunkin: Is there a good way to parse and maintain multiple cookies across multiple requests with Net::HTTP?
[20:26:00] MrPunkin: is there a way to read the URL used from a Net::HTTP response object?
[20:26:06] MrPunkin: or is that information not returned in the response?
[21:26:37] MrPunkin: has joined #ruby
[21:26:57] MrPunkin: Anyone familiar with Net::HTTP enough to help me figure out if there is a way to get the request URL from the response object?
[21:27:02] MrPunkin: has left #RubyOnRails: ()
[21:45:39] MrPunkin: Quit: MrPunkin


[01:09:44] MrPunkin: has joined #RubyOnRails
[03:05:37] MrPunkin: Quit: MrPunkin


[00:00:02] MrPunkin: Quit: MrPunkin


[23:27:00] MrPunkin: has joined #RubyOnRails


[20:46:05] MrPunkin: has joined #RubyOnRails
[23:04:42] MrPunkin: Quit: MrPunkin


[19:29:24] MrPunkin: has joined #RubyOnRails
[19:30:12] MrPunkin: How can I convert crazy unicode text into normal text? I have a string that is all \u000e\u000i stuff that I just want to work the same as if I ‘puts’ that data and it is rendered.
[20:12:28] MrPunkin: apeiros: It’s getting used in hash keys (CSV parsing) and then fails to properly map to my other UTF-8 keys.
[20:13:39] MrPunkin: Right, I did that. String is coming in as “ASCII-8BIT”. I’m using “encode” method to convert from that to UTF-8 while replacing invalid and undefined characters with nothing.
[20:14:24] MrPunkin: Okay, so what’s the proper way to convert one encoding to another?
[20:14:58] MrPunkin: The encoding of this email attachment’s body is coming up as ascii-8bit
[20:15:42] MrPunkin: #<Encoding:ASCII-8BIT>
[20:17:39] MrPunkin: apeiros: I’m not missing the encoding flag on the input
[20:17:42] MrPunkin: so no need to force
[20:17:48] MrPunkin: it knows that it is ASCII-8BIT
[20:18:13] MrPunkin: I need to get that over to a usable format with invalid characters removed. So everything I read online said to use encode to do that.
[20:18:54] MrPunkin: I’m not guessing on the encoding for input, it’s already there from the Rails email attachment parser.
[20:20:01] MrPunkin: I don’t know it better, I’m admitting I don’t understand something, but your condecending assumptions that I’m just missing a huge part make it hard to actually get the help I need.
[20:22:21] MrPunkin: apeiros: what’s wrong with my attitude?
[20:22:31] MrPunkin: If you can explain to me which part I’m missing I’m more than willing and happy to learn
[20:23:18] MrPunkin: In fact I’d prefer it, I’ve been reading about text encodings since Ruby 1.8.7 and don’t feel any smarter than I did 10 years ago on this particular topic.
[20:45:42] MrPunkin: apeiros: here’s actual code…
[20:55:35] MrPunkin: apeiros: with my end goal being this data becoming hash keys and data, what work do I need to do on the string so that querying the hash by a set of expected keys will work?
[20:59:32] MrPunkin: if I use force_encoding(“ASCII-8BIT”) or force_encoding(“UTF-8”) on the initial string or the string just before making a hash from it there is no change to the end result. This is where I clearly have no knowledge of what / when I’m supposed to do
[20:59:57] MrPunkin: I’ve tried all four methods and none result in valid hash key lookups for the “Date” key
[21:01:11] MrPunkin: apeiros: Okay, so in the future how can I determine that myself?
[21:01:20] MrPunkin: Since ruby was saying it had an encoding of ascii?
[21:01:44] MrPunkin: How did you know that?
[21:02:06] MrPunkin: Okay, I get that. I’m relying on the string variable returned from the core Mail stuff to read the attachment body.
[21:02:27] MrPunkin: So if I receive another file and I can’t trust the software that reads the file how do I know which encoding it is?
[21:03:41] MrPunkin: apeiros: So to expand on what you are saying about guessing… would it be correct to say there isn’t really a way I can accept user-generated files and get proper text output from them consistently because I don’t actually have control of the file data.
[21:05:39] MrPunkin: That’s a huge bummer. I really do appreciate your help with this.
[21:18:42] MrPunkin: apeiros: Okay, since I have a known expected keyset for this hash would it make sense to query the resulting string for one of these header keys and upon each failed attempt try another encoding until the common ones are exhausted? Seems for my specific scenario that could get me working without having any real clue to what the attachments real encoding is.
[23:13:43] MrPunkin: Quit: MrPunkin


[22:48:41] MrPunkin: has joined #RubyOnRails
[23:00:19] MrPunkin: Quit: MrPunkin


[17:00:56] MrPunkin: has joined #RubyOnRails
[18:22:03] MrPunkin: Quit: MrPunkin


[18:11:24] MrPunkin: has joined #RubyOnRails
[18:15:23] MrPunkin: It seems that direct “connection.execute(…)” calls in an AR model break the transaction rollback during testing and persist between tests. Is there any way to prevent this and ensure that my database / fixtures start fresh each test?
[18:29:07] MrPunkin: Sorry, rather it seems that calling truncate, which isn’t transactional with MySQL, persists between rails unit tests. Any way to force rebuilding of the fixtures / table at certain points in my test code after calling truncate?
[18:55:55] MrPunkin: garyserj: that generate command will still generate a ‘comments_controller’ I believe.
[18:57:00] MrPunkin: but the wording of the generate command is inteionally reflecting the model the controller will interface with in a RESTful setting
[18:57:12] MrPunkin: intentionally*
[19:01:54] MrPunkin: Quit: MrPunkin
[20:17:05] MrPunkin: has joined #RubyOnRails
[20:18:26] MrPunkin: Is there a way I can programmatically reset the test database mid test? Like does AR offer any hooks to rebuild the test dabase in rails 5.1?
[20:49:29] MrPunkin: dminuoso: I believe that’s the default, but things like “truncate” aren’t transactional with MySQL and thus don’t get rolled back. This is a table that gets truncated as part of the code, and thus my tests, and I need to forcibly reset the database to it’s initial state at a few points in my testing
[20:50:17] MrPunkin: dminuoso: yep.
[20:51:19] MrPunkin: This table is just a read-only table for use to duplicate report data only to be used in the case of an emergency. It doens’t receive writes except from this same model via a single bulk insert from a CSV.
[20:52:00] MrPunkin: dminuoso: I’ll accept the suggestion, however this is a production app that I can’t just switch currently.
[20:52:23] MrPunkin: So was hoping for a way to force rails to rebuild the testing DB when I need it to since it can’t roll back my truncation
[20:52:57] MrPunkin: I thought I had read in rails 5 they removed the rake db:test:prepare task which is what is generally suggested for this stuff
[21:19:44] MrPunkin: dminuoso: any chance you know where I can find the source code for the various rake tasks to know what they are actually doing?
[22:24:39] MrPunkin: seriously how on earth can I repopulate a table from fixtures midway through a test? Is this really something nobody has done before?
[22:25:37] MrPunkin: It won’t work. Throws an error about some SAVEPOINT issue
[22:27:43] MrPunkin: Well my understanding is that each rails test runs within a transaction, right? So I either need to turn off transactions altogether in this test, which is not what I want, or I need to find a way to just recreate the data within a transaction… right?
[22:29:32] MrPunkin: I’m not sure about that. It seems random when it is run but I’m not sure if there is a way to order them manually
[22:37:36] MrPunkin: dminuoso: but I don’t need to rebuild the whold DB structure, just reload fixtures. I put a call to db:fixtures:load in the teardown task which I can confirm is being called but the fixtures don’t re-populate once the truncation happened during my test execution.
[22:37:43] MrPunkin: no errors, just no data in the table either
[22:40:29] MrPunkin: dminuoso: it works fine, but leaves the entire DB blank without any fixtures loaded.
[22:40:45] MrPunkin: that was just db:reset
[22:41:43] MrPunkin: dminuoso: I was trying. The rake tasks load fixtures using ActiveRecord::FixtureSet.create_fixtures() and I can call that just fine but it doesn’t actually populate the DB. It caches the fixtures and everything but never inserts the rows or throws an error.
[22:43:21] MrPunkin: invoking just db:fixtures:load from the command line populates it all fine. invoking it from the teardown callback doesn’t. Something else is wonky with what my truncate does to the transaction or something.
[22:45:40] MrPunkin: Yep, that did it.
[23:21:24] MrPunkin: without a ton of additional code I’m curious, is it possible to intercept one class method and redirect to another class? Obviously I can just return the other class’ method results within my Class A method but I’m thinking more metaprogramming here where if Class B contains the same method name use that otherwise try and call it on Class A
[23:21:40] MrPunkin: Sort of like method_missing metaprogramming without relying on not defining the methods
[23:59:43] MrPunkin: Quit: MrPunkin


[17:39:40] MrPunkin: has joined #RubyOnRails
[22:23:23] MrPunkin: Quit: MrPunkin


[18:38:54] MrPunkin: has joined #RubyOnRails
[18:44:43] MrPunkin: Hey there. We have a contact form that takes UTF info from an HTML form (HTML5 site with proper UTF-8 meta tag in head), stores it via utf-8 into MySQL tables with proper charset and collation, including on the fields, and yet still having some bogus characters causing YAML decoding issues in Delayed::Job. This is just a contact form, so I’m fine removing / santitizing it after input before storing in the DB.
[18:44:44] MrPunkin: anyone suggest a good simple way to sanitize the input to remove any non standard characters that wouldn’t be needed for a contact form?
[20:23:33] MrPunkin: voker57: I tried this on some of the test data that was causing issues and it didn’t seem to clean it up unfortunately. I’ll try again though
[21:10:03] MrPunkin: Quit: MrPunkin


[00:14:59] MrPunkin: Quit: MrPunkin


[23:36:50] MrPunkin: has joined #RubyOnRails


[22:32:02] MrPunkin: has joined #RubyOnRails
[22:32:49] MrPunkin: Can anyone tell me a character that will for sure cause UTF-8 encoding issues? Trying to decode some DB / Rails encoding issues and trying to reproduce it.
[23:23:14] MrPunkin: Intii: Thanks, that indeed does break things.
[23:28:43] MrPunkin: Intii: Your database timestamps should all be UTC, and allow Rails to handle all time-zone issues.
[23:29:17] MrPunkin: Intii: Or do you mean when you try and save a date outside of DST it saves as if it’s the DST offset because current time is DST?
[23:30:14] MrPunkin: How are you passing the date through?
[23:30:47] MrPunkin: For example, in console if you do,12,2).to_time you should see a -0800 offset instead of the current -0700… which makes me wonder if the form is passing in additional info
[23:31:20] MrPunkin: Intii: can you share the params being posted from the form?
[23:32:00] MrPunkin: Sure, whatever is easiest.
[23:34:16] MrPunkin: Intii: are you using datetime_select?
[23:35:58] MrPunkin: Intii: Yeah, sort out those issues first.
[23:39:44] MrPunkin: Intii: It looks like you are using Simple Form?
[23:40:04] MrPunkin: Intii: I’m not familiar with it. I’ve always used the default rails form builder for date / time info.
[23:40:36] MrPunkin: so they write to the same attribute you mean?
[23:40:49] MrPunkin: You could always merge them in the controller before saving to the start_date model attribute.
[23:42:09] MrPunkin: Intii: Check this out:
[23:45:53] MrPunkin: Excellent! Yep, no problem
[23:51:59] MrPunkin: Quit: MrPunkin


[15:57:17] MrPunkin: has joined #RubyOnRails
[16:12:05] MrPunkin: Can anyone tell me if rails offers a nice way to group_by / reduce at the same time? Basically I want to create create arrays of files where each array is limited to under a 1Gig
[16:20:32] MrPunkin: Quit: MrPunkin


[22:25:22] MrPunkin: has joined #RubyOnRails
[22:28:13] MrPunkin: Anyone here use Mocha with testing? Trying to figure out how I can fake a return the first time a method is called in a loop, but allow the second+ times to run as normal. Anyone have any info?
[22:47:21] MrPunkin: Quit: MrPunkin


[18:54:05] MrPunkin: has joined #RubyOnRails
[18:54:09] MrPunkin: has joined #ruby
[18:54:48] MrPunkin: So I know we can use str % arg for string interpolation, but is there a way with the same format string to pull the data back out into a hash?
[18:55:41] MrPunkin: so say I do “foo = %{foo}” % {:foo => ‘bar’} … any way to then get {:foo => ‘bar’} back from “foo = foo” using the same format template?
[20:38:41] MrPunkin: Quit: MrPunkin


[15:59:31] MrPunkin: has joined #RubyOnRails
[16:36:55] MrPunkin: I have upgraded a prior install to Rails 5.1.5, which now apparently requires Yarn to compile assets. Does Rails not install these dependencies for me?
[16:40:55] MrPunkin: Okay, thanks havenwood
[17:05:19] MrPunkin: Quit: MrPunkin


[16:35:43] MrPunkin: has joined #RubyOnRails
[16:39:34] MrPunkin: Can anyone tell me what a Rails 5 way to have a delete button within the same form as an edit form? I can obviously move the button outside the form and re-style the page to account for that, but there must be some way around this where I can have a button that generates a delete request with valid authenticity_token right?
[17:23:42] MrPunkin: Quit: MrPunkin


[22:21:18] MrPunkin: has joined #RubyOnRails
[23:09:48] MrPunkin: Quit: MrPunkin


[19:44:03] MrPunkin: has joined #RubyOnRails
[19:53:31] MrPunkin: has left #RubyOnRails: ()


[00:11:19] MrPunkin: has joined #RubyOnRails
[00:54:34] MrPunkin: Quit: MrPunkin


[00:21:42] MrPunkin: has joined #RubyOnRails
[00:33:05] MrPunkin:
[00:33:05] MrPunkin: Trying to upgrade from rails 4.2 to rails 5 but I’m getting an odd “TypeError: can't quote Hash” error in one of my unit tests. The full blocktrace makes it seem as though it’s an issue with quoting some of the arel / to_sql stuff perhaps but never takes me further into my own code than just the line in my unit test where I call the class method:
[00:34:02] MrPunkin: If I replace the assertions with any sort of thing such as even just “puts to_reconcile.count “ I get the same error. But I can call Product::to_reconcile within console just fine with valid output and it returns a valid AR::Relation
[01:10:16] MrPunkin: Quit: MrPunkin


[00:30:36] MrPunkin: has joined #RubyOnRails
[00:45:55] MrPunkin: has left #RubyOnRails: ()


[18:38:44] MrPunkin: has joined #RubyOnRails
[18:38:55] MrPunkin: has joined #ruby
[18:40:11] MrPunkin: I’m calling a bash script via %x(/bin/bash /path/to/script) and within that script I have a command that is supposed to run in the background (ends with &). It seems that if I run the shell script directly from the command line it does, however it seems that Ruby is waiting for the background subprocess to finish too. How can I program around this?
[18:46:05] MrPunkin: lupine: thanks for the direction, much appreciated
[21:01:52] MrPunkin: Quit: MrPunkin


[23:09:07] MrPunkin: has joined #RubyOnRails
[23:24:56] MrPunkin: Quit: MrPunkin


[18:33:01] MrPunkin: has joined #RubyOnRails
[18:36:21] MrPunkin: Client Quit


[03:56:45] MrPunkin: has joined #RubyOnRails
[03:57:16] MrPunkin: Is there any way I can render HTML AND evaluate the javascript on the page server-side within RoR?
[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:15] MrPunkin: Trying to query the JSON directly without the authentication fails
[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:22:22] MrPunkin: Quit: MrPunkin
[21:15:41] MrPunkin: has joined #RubyOnRails
[21:15:43] MrPunkin: has left #RubyOnRails: ()


[20:48:16] MrPunkin: has joined #RubyOnRails
[20:52:09] MrPunkin: has left #RubyOnRails: ()


[21:02:53] MrPunkin: has joined #RubyOnRails
[21:09:02] MrPunkin: has left #RubyOnRails: ()


[22:29:20] MrPunkin: has joined #RubyOnRails
[22:32:35] MrPunkin: Are ranges a reliable attribute format for a Active Model model that’s based on returning projected data? It has a few date windows that ranges would be good for, but is it more reliable to make the start / end of each window it’s own attribute? Is there additional overhead with ranges or anything?
[22:33:30] MrPunkin: I guess as far as serlialization and such they wouldn’t be good, kind of answering my own question here thinking about it
[23:26:46] MrPunkin: Quit: MrPunkin


[18:41:06] MrPunkin: has joined #RubyOnRails
[18:59:50] MrPunkin: Without wanting to actually make calls to an external service, as VCR does, is there a currently preferred GEM to help with mocking up API responses from third-party APIs?
[19:26:17] MrPunkin: Quit: MrPunkin
[20:00:13] MrPunkin: has joined #RubyOnRails
[20:01:16] MrPunkin: Client Quit


[22:08:58] MrPunkin: has joined #RubyOnRails
[22:09:48] MrPunkin: What’s the best way to generate XML that will be POSTed to an external API? It seems like using views is the easiest way to generate the XML, however getting those views rendered into whatever model handles the API integration seems like a break in the MVC system.
[22:28:04] MrPunkin: baweaver: Actually I realized the built in to_xml methods for hashes will achieve what I need for how non-complex the dataset that needs to get POSTed is.
[22:28:06] MrPunkin: thanks though
[23:04:09] MrPunkin: Quit: MrPunkin


[16:17:17] MrPunkin: has joined #RubyOnRails
[17:05:27] MrPunkin: Quit: MrPunkin


[18:28:34] MrPunkin: has joined #RubyOnRails
[18:41:11] MrPunkin: has left #RubyOnRails: ()
[20:14:15] MrPunkin: has joined #RubyOnRails
[21:32:21] MrPunkin: Quit: MrPunkin


[19:14:00] MrPunkin: has joined #RubyOnRails
[19:33:22] MrPunkin: has left #RubyOnRails: ()


[19:03:44] MrPunkin: has joined #RubyOnRails
[19:09:22] MrPunkin: has left #RubyOnRails: ()
[21:27:56] MrPunkin: has joined #RubyOnRails
[21:54:12] MrPunkin: Quit: MrPunkin


[23:45:34] MrPunkin: has joined #RubyOnRails
[23:45:38] MrPunkin: has left #RubyOnRails: ()


[16:18:44] MrPunkin: has joined #RubyOnRails
[17:08:57] MrPunkin: has left #RubyOnRails: ()


[22:29:08] MrPunkin: has joined #RubyOnRails
[22:29:12] MrPunkin: Client Quit