frem

Activity Graph

Page 1 of 1

2014-07-25

[21:56:28] frem: There's a common pattern in my application where I'm using `PhoneNumber.where(number: NumberConverter.format_phone_number(phone_number)).first` a lot.
[21:57:12] frem: Is there a way I can automatically apply NumberConverter.format_phone_number whenever I use `.where(number: phone_number)`?
[21:57:24] frem: bricker`work: strings
[21:57:56] frem: they're all stored formatted, but I have to remember to format them before doing the lookup
[21:58:35] frem: sounds good. thanks!
[22:03:13] frem: I thought it seemed a bit silly.

2014-07-15

[20:02:08] frem: Q: Why does inject fail when I try to ignore nils? https://gist.github.com/jamesgecko/5360040b931b949377a6
[20:04:01] frem: shevy: I don't understand. What's an array, now?
[20:05:43] frem: Oh, ok. Thanks!

2014-06-17

[22:03:23] frem: Dumb question: why are these cancan ability statements not equivalent? https://gist.github.com/jamesgecko/766cb7c51510c3b2b02a
[22:19:35] frem: I'm only trying to return false in the block. Other CanCan blocks have equality statements in them, too.
[22:25:40] frem: bricker`work: as i understand it, if a cancan block evaluates to false, it's not supposed to not allow access to the resource. cancan is allowing access, and I don't understand why.
[22:26:21] frem: err, ignore the double negative
[22:40:37] frem: bricker`work: oh, i missed that. nasty! thanks. :-)

2014-04-15

[19:37:35] frem: has anyone had issues with newrelic not showing exceptions in rake tasks started by clock.rb?

2014-03-06

[20:51:24] frem: I have a rails app, and I'd like to reuse user accounts in a small sinatra app that uses the same DB. Is there a description somewhere of how to hook into accounts created by Devise with a different app using Warden?
[20:52:41] frem: AxisOfEval: same domains
[20:57:14] frem: AxisOfEval: I don't know what the standard way is.

2014-03-05

[20:39:52] frem: MINASWAT?
[20:45:33] frem: something?
[20:45:33] frem: so, i have a big database full of legacy data. for reasons only recently come to light, validations were being ignored for kind of a lot of records. these records has_one for several other records. which also fail validations. short of manually editing my db all day, what is the best way to sort this out? can i make validates_associated conditional or
[20:46:55] frem: RubyPanther: i'm hacking on the legacy app. :)
[20:50:12] frem: teddythetwig: the main problem is missing data. there are groups of users, and the users has_one group. i need to let the users do stuff, but the user models are validating their associated groups on save. the groups are (mostly) the ones missing data.
[20:51:45] frem: s2013: burning out, apparently.
[20:54:14] frem: RubyPanther: it's mostly NULLs, afaict.
[20:55:45] frem: RubyPanther: I cannot.
[20:58:04] frem: RubyPanther: I want to have users do that. The missing data has to be entered manually. :-/
[20:58:44] frem: failing.
[20:58:44] frem: RubyPanther: I want to set it up so that existing user models that belong to known bad groups can be saved without failing validation, but new user models still validate groups so that no more groups that don't validate are introduced. Right now users are getting stuck at a certain screen because their validation is failing because the group validation is
[21:05:30] frem: RubyPanther: Hmm. I might try that. Thanks!
[21:06:48] frem: Some hikers call them "mini bears." Leave your pack unattended for just a little bit and they'll rip it all to shreds to get at the food inside.
[21:12:51] frem: in ancient rome, they did not have rats. there was "small mouse" and "big mouse." so sayeth the wikipedia.

2014-02-27

[00:45:06] frem: you bite that hand. :)
[04:27:10] frem: If a Foobar.create! fails validation in an after_save callback, is the validation error lost to the wind? Rails shows there was a problem saving the model tied to the controller, but I can't figure out how to get the actual validation error back up the chain.
[04:29:42] frem: centrx: would that mean I'd need to pass the object I'd been trying to assign the created model to all the way up the chain to get the validation message?
[04:30:47] frem: here's an example. i've trimmed down the spaghetti as much as I can https://gist.github.com/jamesgecko/7f97c486f2b5a624de8d
[04:34:10] frem: centrx: how would i access search cleanly from the controller?
[04:38:50] frem: centrx: my problem is that there's this failure off one model created in a callback by another model, and the controller knows there was a failure, but it's displaying a generic "Please complete your profile" type error instead of the more specific "[location] couldn't be found" and I can't figure out how to get that message to the controller without
[04:38:51] frem: terrible hackery.
[19:38:05] frem: What's the best way to rescue an exception that has a specific message? I tried re-raising the exception if the message doesn't match, but when I have a block like `begin; rescue Foo => e; rescue => e`, and the exception is re-raised in the first rescue, the exception is not caught by the second rescue.
[19:40:29] frem: RubyPanther: Can't help it. Rails is dumb when it comes to validations, especially when a different model raises an exception than the one the controller is validating. Same exception either way; only way to tell them apart is to read the message.
[19:42:07] frem: centrx: I agree! But you haven't seen the mess of model dependencies I spent hours trying to work around. It's not worth another day of work to try and get it working "the right way."
[19:43:35] frem: RubyPanther: is there something more specific than ActiveRecord::RecordInvalid I can rescue from?
[19:49:00] frem: RubyPanther: Oh! Ok, that helps a lot. Thanks!
[19:50:42] frem: No, wait. If I subclass it, I can't use the errors hash built into models.
[19:51:16] frem: This is a minimal, cleaned up version of the mess I have to work around right now. https://gist.github.com/jamesgecko/7f97c486f2b5a624de8d

2014-02-26

[23:41:13] frem: intentional pun? :)
[23:42:17] frem: I mean, it's from a greek word that means "mass of roots."

2014-02-21

[19:38:07] frem: Is there something obviously wrong with this validation? It never fires, even when coordinates are [nil, nil]. `validates_presence_of :coordinates, if: proc {|s| s.coordinates != [nil, nil] }`
[20:27:55] frem: Does anyone know why this validation is passing? https://gist.github.com/jamesgecko/7d638c587e9f5dd29853
[20:29:13] frem: crankharder: true
[20:29:58] frem: crankharder: so it's not using the if on that validator because [nil, nil] counts as a thing that is present?
[20:31:04] frem: crankharder: what is the best way to get around that?
[20:35:58] frem: crankharder: ah. the if argument determines if the validation runs or is skipped. thanks for the help.

2014-01-25

[01:03:08] frem: shinobi_one: rvm isn't a big deal for a lot of python projects. The newest version of python is 2.7, after all. ;)
[01:03:41] frem: shinobi_one: thats_the_joke.jpg

2014-01-24

[21:30:18] frem: I'm having trouble setting params in the URL on a redirect. Why isn't this working? https://gist.github.com/jamesgecko/426126b1b6e31210fd7b
[21:36:45] frem: cnk_: excellent guess. thanks!

2014-01-22

[23:56:47] frem: Question: if a model is saved with the validate: false argument, would that skip an after_validation callback?

2014-01-20

[21:24:23] frem: does anyone know if it's possible to have both the meta_search and ransack gems installed? or are they just going to stomp all over each other?
[21:27:19] frem: elaptics: I want to update my application to use ransack, but one of my gems is still depending on meta_search
[21:28:03] frem: said gem will have ransack compatibility in a future release, but i didn't want to wait for that release. :P
[21:28:55] frem: samuel_simoes: rather a lot of them.

2014-01-10

[21:34:38] frem: Question: should HAML be randomly inserting a closing tag into an html_safe string coming from a helper? I'm pretty sure the answer is "no."
[21:35:37] frem: Also, has anyone seen that and know how to work around it?
[21:35:54] frem: https://gist.github.com/jamesgecko/c276f1f31c324f22cb6c
[21:42:12] frem: toretore: ooohhhhhh. things make more sense now. thanks!
[21:50:58] frem: come to scenic atlanta. we have a mountain, and also traffic!

2013-12-30

[19:23:37] frem: I'm seeing a really weird thing where an older migration that created a table is shown as run, but the table isn't there. I didn't delete the table, and later migrations modify the table, so I can't rollback to the migration that created it.
[19:25:01] frem: What's the way to fix this? Manually go through migrations and write SQL to recreate what rails thinks the state of the database is?
[19:28:00] frem: ah, I'll just run db:reset and re-seed it.

2013-11-26

[04:42:36] frem: dumb question: i need to join two tables which have slightly different columns. How can I use ActiveRecord::Base#join or #find_by_sql and end up with an object that contains attributes for all the columns in each table?
[04:46:55] frem: s2013: Like, I have a query `SELECT * FROM a JOIN b ON a.key = b.key WHERE a.key='blah'`, and a has column foo, and b has column bar. `A.join("b ON a.key = b.key WHERE a.key='blah'")` will have column foo, but not column bar.
[04:57:21] frem: Yeah, it looks like if you use select on an AR join, the fields have to exist in the table you're joining on.
[04:59:18] frem: Guess I'll have to use AS. Thanks, erichmenge.

2013-11-04

[20:21:38] frem: question: when using `link_to` with `:method => :post`, very occasionally, clicking on the link performs a GET instead of a POST. I can't reliably reproduce it. What's the best way to track this down?
[20:25:47] frem: bricker`work: I don't think it's possible to POST using an a href without JS?
[20:26:39] frem: I've also seen the issue on a button_tag with type submit in a form, but that one does have some custom validation js tied to it.
[20:30:08] frem: pothibo: It's more like `link_to item_path, method: :post, remote: true, format: 'js' ...`
[20:33:18] frem: that sounds like what i've observed
[20:34:44] frem: droptone: if you open a rails console, can you interact with the database?

2013-10-15

[21:03:58] frem: Q: I have a model which is failing to save with ActiveRecord::RecordNotSaved. The stack trace for the offending spec is completely useless. How do I find out which model callback is failing?

2013-10-07

[20:12:30] frem: When re-running certain specs, I get a bunch of failures saying things like `PG::Error: ERROR: prepared statement "a1" already exists`.
[20:14:23] frem: captproton: https://gist.github.com/ :-)
[21:01:13] frem: I have a controller method which renders a .js.haml template. It is accessed via ajax, and it works when I try it in the browser. When I point capybara at it, the controller suddenly can't find the template. What am I doing wrong? https://gist.github.com/jamesgecko/67f49da46611cd2be76f
[21:03:04] frem: bingomanatee1: Are you looking for JSON.parse, maybe? http://www.ruby-doc.org/stdlib-2.0/libdoc/json/rdoc/JSON.html#method-i-parse
[21:08:57] frem: dasibre: i can do that, but if it requests html, it gets html and doesn't interpret the JS. It needs to be requesting js, it just doesn't know that.

2013-10-04

[20:25:45] frem: i have a haml file that i want to use as both a partial and a normal view. but i need to pass variables into it. can i do something like `render 'my_partial', locals: {my_var: 'yay'}` in the controller? my_var doesn't seem to be getting passed.

2013-09-24

[22:11:47] frem: Question: I have a model that `belongs_to Message` and has `attr_accessible :message_id`. When I try to create an instance of the model `MyModel.create({message_id: foo})`, the model says it doesn't have the attribute `message_id`. But it does have `messaged_id`. Wat?
[22:29:41] frem: never mind. i had a typo in my migration... -_-

2013-09-18

[23:27:20] frem: I'm trying to use link_to to make a link that uses an ajax call to replace itself with the content it fetches.
[23:27:38] frem: Is there a way to tack a javascript callback onto link_to or something?
[23:36:25] frem: thanks, optobear

2013-05-24

[21:06:11] frem: So, I'm using JBuilder, and I need to include stuff that is already stored as JSON in the db. Am I going to have to deserialize it so that JBuilder can convert it back to JSON?

2013-04-18

[20:27:04] frem: I'm trying to add a new namespace for some classes in lib, but rails isn't finding them. What am I doing wrong? https://gist.github.com/jamesgecko/6b97bf658665434db192
[20:29:02] frem: toretore: ಠ_ಠ

2013-03-15

[23:07:09] frem: Can someone help me fathom the intricate mysteries of link_to? I can't get jt to add params in links to external sites. https://gist.github.com/jamesgecko/637c5f612cc500b5ecca

2013-03-04

[16:35:08] frem: Dumb question: I have a named scope that accepts an array. Is it possible to make it add several other scopes to the chain, each accepting one element of the array?

2013-02-12

[16:44:34] frem: question: if i have a routes file for an api, and there are a bunch of nested resources in a namespace, is there a way to say that none of those resources have :edit or :new routes without adding `:except => [:edit, :new]` to every single resource?
[16:45:19] frem: <3 workmad3

2012-11-06

[17:40:11] frem: I'm using a little OneOff class for running single-use operations. Building OneOffs is a pain though, because they won't reload without restarting rails console. Can someone tell me where I'm going wrong? https://gist.github.com/e39740831ea91720063a

2012-10-13

[00:16:53] frem: I have a page that makes the server print "Killed" and terminate when visited. How do I go about debugging this?