|
At least it was an easy fix?
|
# ? Mar 5, 2013 13:18 |
|
|
# ? May 15, 2024 04:14 |
|
This isn't rails, just vanilla ruby (1.9.2p180 on ubuntu ec2), but this seems like the best place to ask on here. I've got some code that hangs under certain circumstances (most of the time it's fine, so unfortunately this isn't easily repeatable by others). This is the bit in question: code:
What I'm observing is a hang on read_thread.value; it just blocks forever waiting on the read thread. Immediate suspicion with this sort of code is usually that the write half of the pipe hasn't been closed, except that in this case it has (as is clear by inspection of the code, also verified with lsof: the process has only one FIFO open. Does anyone have any clues what might be causing this to hang? (Or have any brilliant debugging tips?)
|
# ? Mar 7, 2013 01:02 |
|
I'm trying to debug a strange issue with rails forms helpers I haven't encountered before. I posted on stackoverflow so instead of re-typing the whole thing here, I'll provide a link. Anybody see this before? For some reason, the text_field helper in rails is providing values in the POST params as an array instead of as a pure string value. http://stackoverflow.com/q/15262119/1268161 E: Welp, somebody got it. Dumb mistake. I was supposed to use text_field_tag instead of text_field. DankTamagachi fucked around with this message at 04:06 on Mar 7, 2013 |
# ? Mar 7, 2013 03:58 |
|
*edit* I'm a moron
|
# ? Mar 7, 2013 04:20 |
|
Steve French posted:Does anyone have any clues what might be causing this to hang? (Or have any brilliant debugging tips?) One thought I had was that maybe it's a buffered I/O thing (probably on the command you're executing), but that seems kind of weird/unlikely for it to hang very long
|
# ? Mar 7, 2013 05:21 |
|
het posted:What does strace say the executed command is doing while hanging? Just attaching to the running process may not produce anything useful, but you could prepend the strace to the command you execute and have it output to a temp file that you remove on success. The executed command has already completed; it failed (in this particular case, as expected). The fact that it has completed and failed is what it is causing the call to read_thread.value, which is what is hanging.
|
# ? Mar 7, 2013 06:13 |
|
I have three questions: 1) I want to put a :limit clause on a relationship using a variable from the same class, like this (but it doesn't work). Ruby code:
Ruby code:
Ruby code:
|
# ? Mar 13, 2013 14:03 |
KoRMaK posted:1) I want to put a :limit clause on a relationship using a variable from the same class, like this (but it doesn't work). is `things_limit` a class method or an instance method? I think this might only work with class methods. KoRMaK posted:2) How would I override a relationship so that I can add in my own customizations Look at the options for this in the documentation. You might have to :extend the association. http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-has_many http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html KoRMaK posted:3) How would I override a model's find or all commands to only return the first X count of records (Thing is a model) try something like Ruby code:
|
|
# ? Mar 13, 2013 14:51 |
|
A MIRACLE posted:is `things_limit` a class method or an instance method? I think this might only work with class methods. That won't quite work. code:
Ruby code:
Ruby code:
|
# ? Mar 13, 2013 15:37 |
|
A MIRACLE posted:is `things_limit` a class method or an instance method? I think this might only work with class methods. I'm still taking in and processing the other couple of comments from you guys, thanks for the replies.
|
# ? Mar 13, 2013 15:45 |
|
KoRMaK posted:I have a confession: I still don't know how to tell the difference between the two after 1yr+ RoR development things_limit is a column on the Account model. Fortunately that is easy: code:
code:
|
# ? Mar 13, 2013 15:50 |
|
^ The use of self for that has always bugged me about ruby. I don't think they could have chosen a worse keyword to use in that position - its connotation is inextricably tied to "instance" not "class". Especially to a python refugee... That's one of the only things I'd change about ruby if somehow my opinion mattered on future direction
|
# ? Mar 13, 2013 15:54 |
|
Lexicon posted:^ The use of self for that has always bugged me about ruby. I don't think they could have chosen a worse keyword to use in that position - its connotation is inextricably tied to "instance" not "class". Especially to a python refugee... Well, you could do it like this: code:
code:
|
# ? Mar 13, 2013 16:01 |
|
Is Railsconf worth the money? Google I/O registration failed me this year and so now I'm trying to decide if I should burn the money on Railsconf instead.
|
# ? Mar 13, 2013 16:19 |
I decided not to go because work won't pay for it and it's on the other coast :-(. So I'm going on a month-long vacation to Asia instead!
|
|
# ? Mar 13, 2013 16:36 |
|
manero posted:Well, you could do it like this: Cool. I didn't know about the former syntax, actually. I guess it doesn't really matter that alternatives exist as you can't reasonably use them and not be out-of-lockstep with the rest of the ruby community - I'm mostly just annoyed by what they chose for the default. When I first learned that, I was like "Wait, what? 'self' means 'class' method?? COME ON!"
|
# ? Mar 13, 2013 16:43 |
|
kitten smoothie posted:Is Railsconf worth the money? Google I/O registration failed me this year and so now I'm trying to decide if I should burn the money on Railsconf instead. I find that I can get as much or more out of watching videos of conference talks after the fact without flying across the country to sit in a room where everyone is dicking around on their laptops. I've been told that this means I don't "get" conferences though, so YMMV.
|
# ? Mar 13, 2013 19:28 |
|
I've got a Cool question for ActiveRecord peeps. Take a look. Activerecord exposes a very helpful .build method on associations. Ruby code:
Ruby code:
Ruby code:
quote:Undefined method 'build' for Class. So if I can do: Ruby code:
Ruby code:
Ruby code:
Ruby code:
Or even better, how would I do this.
|
# ? Mar 14, 2013 16:12 |
|
Build is a method on associations, not on models. It basically calls `Thing.new(thing_haver: thing_haver_instance_on_whose_things_association_we_called_build)`. You might prefer an instance method on the class which holds the association. Ruby code:
Doc Hawkins fucked around with this message at 16:30 on Mar 14, 2013 |
# ? Mar 14, 2013 16:25 |
|
Yeah. My confusion comes from associations and classes both having find_by but not both having build and therefore it strictly not being available. In my example should I assume the find_by isn't doing what I want in this instance: Ruby code:
Nolgthorn fucked around with this message at 17:00 on Mar 14, 2013 |
# ? Mar 14, 2013 16:56 |
|
Well, there is no method `find_by` in rails, though there are the dynamic finders `find_by_*` for each attribute an AR model has, and `find_by_attributes` which would work with arguments like `(name: name_variable)`. I'm actually not sure if those methods return chainable scopes (probably?), but `where` definitely does, and you can use it to write class methods that can chain, be chained upon, and be called on associations.
|
# ? Mar 15, 2013 16:33 |
|
Novo posted:I find that I can get as much or more out of watching videos of conference talks after the fact without flying across the country to sit in a room where everyone is dicking around on their laptops. I've been told that this means I don't "get" conferences though, so YMMV. I went in 2011 and just did the free hallway track, and felt like I got my money's worth. Go for the inspiration and the networking, and consider that it's a great way to get work to pay for you to talk to the zillion companies there that will be begging for new employees. (Looks like they didn't accept my talk )
|
# ? Mar 15, 2013 16:42 |
|
I'm learning Ruby right now, going through the Koans and I'm trying to create a method for one of the exercises. Right now, though, I'm stuck on trying to match up a set of numbers to an array. Bottom line: Does .include? work if you pass an array to it? Will it then look inside a given array to see if the things are in there? Basically, here's what I have now: code:
|
# ? Mar 15, 2013 22:29 |
|
SquadronROE posted:I'm learning Ruby right now, going through the Koans and I'm trying to create a method for one of the exercises. Right now, though, I'm stuck on trying to match up a set of numbers to an array. Nope. It will look for the object it's passed (in this case the entire array) and that's it. Ruby code:
|
# ? Mar 15, 2013 22:58 |
|
SquadronROE posted:stuff Learn to love the console (irb in your terminal app) as Soup in a Bag just did. Any time you are unsure, you can simply run the command to see what happens and experiment to your heart's content. This accounts for a massive, massive difference in programmer productivity in ruby for those who came from the Java, C++, etc worlds. Big hulking slow tools, edit-compile-run cycles, etc.
|
# ? Mar 15, 2013 23:09 |
|
Ah, very very cool. That is about a billion times easier than I thought it would be. Thanks. EDIT: And thanks to IRB I was able to figure out that I needed dice.count(1) == 3. Man, that is SO much easier. Also, I did actually check out the ruby docs before I asked, but didn't make the connection between it looking for a literal array rather than what was considered in the array. turn it up TURN ME ON fucked around with this message at 23:48 on Mar 15, 2013 |
# ? Mar 15, 2013 23:43 |
|
Speaking of IRB, I just found out about Pry. Even though I only know how to use the basic features (new to Ruby as well), it looks pretty awesome. Check out the intro screencast http://pryrepl.org/.
|
# ? Mar 16, 2013 09:33 |
|
Pry's edit-method by itself is reason enough for me to use it over irb.
|
# ? Mar 16, 2013 13:09 |
|
Hefty posted:Speaking of IRB, I just found out about Pry. Even though I only know how to use the basic features (new to Ruby as well), it looks pretty awesome. Check out the intro screencast http://pryrepl.org/. Pry is awesome, as is awesome_print
|
# ? Mar 16, 2013 17:07 |
|
Hefty posted:Speaking of IRB, I just found out about Pry. Even though I only know how to use the basic features (new to Ruby as well), it looks pretty awesome. Check out the intro screencast http://pryrepl.org/. Both of these are awesome, thanks for the heads up.
|
# ? Mar 16, 2013 21:43 |
|
Well, it is Monday, all right.
|
# ? Mar 18, 2013 19:19 |
|
chumpchous posted:beep boop I set up a rake task for bundle audit and it's unfortunately not flagging any of these in its output. Anyone know why?
|
# ? Mar 18, 2013 19:22 |
|
Probably because the post is an hour old and audit isn't aware of it yet
|
# ? Mar 18, 2013 19:24 |
|
chumpchous posted:Probably because the post is an hour old and audit isn't aware of it yet I should've read more before posting. Turns out a feature of it is that it doesn't require a network connection, and has its own dataset of vulnerabilities that gets updated periodically. So presumably you only ever get notified if you bundle update it, and then run it? Hmph.
|
# ? Mar 18, 2013 19:28 |
|
Lexicon posted:I should've read more before posting. Turns out a feature of it is that it doesn't require a network connection, and has its own dataset of vulnerabilities that gets updated periodically. So presumably you only ever get notified if you bundle update it, and then run it? Hmph. wow, I also assumed it was querying a server somewhere. It would make sense that it takes at least an hour or two to get updates. That kinda sucks, but I don't think it's really intended as an up to the minute security watchdog; it's more more of a thing to use before an initial rollout/after major updates.
|
# ? Mar 18, 2013 19:32 |
|
chumpchous posted:wow, I also assumed it was querying a server somewhere. It would make sense that it takes at least an hour or two to get updates. That kinda sucks. I don't think it's really intended as an update to the minute security watchdog, and more of a thing to make sure something old doesn't get past you. Yeah :/ Fair enough - still a useful thing, but I guess it's not quite what I thought it was. edit: I totally don't blame anyone for not wanting to run a server for free, but it's rather humorous in 2013 to call doesn't-rely-on-network a feature. You can get gently caress-all done without a network connection, including updating the drat vulnerability list. Lexicon fucked around with this message at 19:36 on Mar 18, 2013 |
# ? Mar 18, 2013 19:33 |
|
Lexicon posted:Yeah :/ Fair enough - still a useful thing, but I guess it's not quite what I thought it was. Yeah it would just need to be an RSS feed setup somewhere with a vulnerability list. Anyhow, it's not going to tell you anything that the google group doesn't, so your best bet is to just subscribe to that.
|
# ? Mar 18, 2013 19:38 |
|
Why can't :until be used as a hash key?Ruby code:
|
# ? Mar 20, 2013 18:58 |
|
|
# ? May 15, 2024 04:14 |
|
Lexicon posted:Why can't :until be used as a hash key? is stringify_keys some sort of rails thing? Ruby code:
Ruby code:
|
# ? Mar 20, 2013 19:06 |