Activity Graph

Page 1 of 3 | Next »


[20:40:18] werdnativ: Where is this method defined, it looks like it was removed? https://github.com/rails/rails/blob/82d12eb9045cba57172ec7cc0786d0f72a8b711f/activerecord/lib/active_record/sanitization.rb#L24
[20:40:50] werdnativ: ActiveRecord::Sanitization.sanitize_sql_hash_for_conditions
[20:41:12] werdnativ: yeah, but there it is being called.
[20:41:23] werdnativ: not just deprecated, removed
[20:42:51] werdnativ: Ohh. well that???s still a memory leak then. I reported it to @sgrif but he told me off because I reported it against Arel and that is an ???internal??? interface.
[20:59:23] werdnativ: thebatu1: all? is the iterator (???loop???) method. The stuff inside { } is a block that gets called for each item.
[20:59:54] werdnativ: The |p| is the block variable for each item in your array.
[21:01:36] werdnativ: thebatu1: see any? all? from http://ruby-doc.org/core-2.2.1/Enumerable.html
[21:04:54] werdnativ: and also bad reasons, where you???d want a decorator or something.


[21:36:04] werdnativ: isn't that what validates uniqueness does already?
[21:37:26] werdnativ: @jpstokes or look at find_or_create_by
[22:00:34] werdnativ: jpstokes: it should depend on how you try to save it. If you force it with create! or save! it will throw an error. If you do save or create, it returns false, and you get model.errors
[22:01:17] werdnativ: jpstokes: then try find_or_create
[22:03:43] werdnativ: @jpstokes something like Skill.find_or_create_by_name("Love") { |new_skill| new_skill.stuff }


[00:17:29] werdnativ: With the 4.1 secrets.yml is there any convention for database password key? Does that get ERB'd into database.yml?
[00:17:45] werdnativ: gen0cide_: sidekiq
[00:20:49] werdnativ: centrx: I've always gitignored database.yml, so I'm just wondering what's the change now that we're promoting secrets.yml as the place for that.
[00:22:04] werdnativ: I mean, if I can check in database.yml with the secrets removed, that's cool. Just wondering how it's supposed to work now.
[00:23:21] werdnativ: thanks Radar.
[00:28:46] werdnativ: centrx: no I don't think I ever worked on MediaWiki.
[00:31:41] werdnativ: centrx: puts "werdnA".reverse


[04:07:05] werdnativ: Given a string of hex like "ffcc33", can "unpack" turn it into ordinal bytes like [255, 204, 51]?
[04:07:32] werdnativ: I see a lot of examples use scan(/../) to get the character pairs. Is there a better way without a regexp?
[04:09:57] werdnativ: I have: text.scan(/../).map { |h| h.to_i(16) } but wondering if there's a more direct way.
[04:17:24] werdnativ: benzrf: thanks, that might be better.
[04:17:37] werdnativ: Still I suspect there's a more direct way...
[04:19:14] werdnativ: benzrf: yeah, each pair of chars is a byte
[04:20:20] werdnativ: haha, yeah.
[04:21:37] werdnativ: :) that's it arubin!
[04:23:12] werdnativ: yeah, I see. plus, still need to map over it.
[04:23:48] werdnativ: big-endian.
[04:23:55] werdnativ: like normal reading left to right.
[04:24:22] werdnativ: me neither.
[04:25:15] werdnativ: I suspect I need one of the unpack directives that return an "Integer" not a String. There's x for moving forward a byte too... hm.
[04:25:33] werdnativ: krz: what does your input look like?
[04:30:14] werdnativ: krz and you want to eval that back into ruby?
[04:31:21] werdnativ: arubin, benzrf, Getting closer unpacking with "C" but still not sure how to get it to read the pair of chars...
[04:36:27] werdnativ: krz: I'm not sure what your question is.
[04:37:23] werdnativ: krz: it's not escaping, that's just how it shows the strings. if you use "puts" it won't show the backslashes.
[04:38:30] werdnativ: arubin: yeah, it works. I was just playing and thinking there has to be a way to unpack it directly... maybe not.
[04:42:26] werdnativ: krz you'd have to do arr = eval(line)
[04:43:38] werdnativ: mind that eval is evil... but if you want to go from that to ruby values that's the way.
[04:44:00] werdnativ: krz but I would ultimately suggest something like JSON for that.
[04:45:30] werdnativ: I wonder how easily it can be broken...
[04:47:05] werdnativ: that gem does look cool.
[04:48:26] werdnativ: agreed. I think it masks over the fact that you're still evaling input.
[04:49:09] werdnativ: haven't looked, I assume it has to regexp the code and eventually turn the input into ruby somehow...
[04:49:38] werdnativ: so there's some point when it has to eval "42" into 42.
[04:49:54] werdnativ: krz: JSON.parse
[04:50:58] werdnativ: ACTION cracks open lib/literal_parser to see
[04:51:13] werdnativ: https://github.com/apeiros/literal_parser/blob/master/lib/literal_parser.rb#L73
[04:52:38] werdnativ: one eval here: https://github.com/apeiros/literal_parser/blob/master/lib/literal_parser.rb#L286
[04:54:05] werdnativ: ruby_parser or such is a better idea. If you're gonna eval then be explicit about it.
[04:55:14] werdnativ: I guessed regex + eval before even looking ;-)
[04:55:44] werdnativ: arubin: not really. usually a stack that you push tokens onto.
[04:57:39] werdnativ: read bytes. Fundamentally you're right that you scan the input, but it's typically not a "general" regex parser but one that's designed for the things you need.
[04:59:01] werdnativ: jarray52: what version of ruby, what debugger? There are various incompatible combos.
[05:01:37] werdnativ: jarray52: https://github.com/deivid-rodriguez/byebug
[05:02:03] werdnativ: jarray52: debugger gem known issues: https://github.com/cldwalker/debugger#known-issues
[05:03:39] werdnativ: jarray52: `ruby --version` should tell you the patchlevel but your problem might be fundamental to 2.0+
[05:05:01] werdnativ: jarray52: pry with pry-byebug are a good combo.
[05:09:34] werdnativ: I still don't get monads. I think I get functional combinators, but it's like an abstract combinator for combinators or something?
[05:10:03] werdnativ: by the way, this: http://www.youtube.com/watch?v=FITJMJjASUs
[05:10:44] werdnativ: I'd have to look it up again, the terminology falls out of my head if I don't use the stuff.
[05:14:32] werdnativ: ultimate kata
[05:19:05] werdnativ: ACTION goes down the rabbit hole
[05:20:08] werdnativ: nope. I'm not deep into f.programming.
[05:26:32] werdnativ: watching the video, but I'm curious if you can show this in ruby benzrf


[18:32:24] werdnativ: Can someone answer why a gem says it's installed when it's actually not? https://gist.github.com/avit/502d3c9ebd78e19f2cc2
[18:36:32] werdnativ: gist updated with details ^, thanks guys
[18:36:51] werdnativ: havenwood yes, tried rbenv rehash
[18:37:20] werdnativ: dangerousdave: integration
[18:37:42] werdnativ: dangerousdave: or "acceptance" for desired outcome.
[18:37:57] werdnativ: integrated != unit
[18:39:18] werdnativ: jhass: yeah. weird. gem which active_support = ERROR: Can't find ruby library file or shared library active_support
[18:39:48] werdnativ: I installed activesupport in the scope of an app bundle with --deployment
[18:40:14] werdnativ: now I'm installing some other gems. I'm expecting it should not find those other ones.
[18:40:35] werdnativ: jhass: this is outside the bundle now.
[18:40:52] werdnativ: for bluepill
[18:41:13] werdnativ: yeah, I know... but gem install bluepill outside the bundle depends on active_support, and it fails!
[18:41:36] werdnativ: I guess! but why?
[18:42:13] werdnativ: btw, this is for a chef recipe, so "by hand", oh yay. :(
[18:43:55] werdnativ: Hanmac: I'm not switching any versions, I only have global 2.1.1
[18:44:23] werdnativ: interesting that gem install active_support gets 3.0.0, outside of any bundle
[18:44:43] werdnativ: havenwood: no, because it thinks it's installed. it shows up in gem list
[18:44:54] werdnativ: yes, but the require is 'active_support'
[18:45:04] werdnativ: oh, I see for install
[18:45:16] werdnativ: thanx, always f that up
[18:45:58] werdnativ: still not the problem tho... that's just from installing manually
[18:47:30] werdnativ: odd how tight rails is about naming conventions and they screwed this one up...
[18:48:31] werdnativ: Hanmac: my wife showed me that, I was like, ...and? what? Until I got it.
[18:51:05] werdnativ: Yeah, I think they started with the different power levels over USB for charging original iPad, but I think that's standardized by now.
[19:35:03] werdnativ: I filed an issue, not sure where the error lies but I think it's something with bundler --deployment: https://github.com/bundler/bundler/issues/2955
[19:58:14] werdnativ: havenwood: no, just rbenv
[20:04:08] werdnativ: havenwood: yes /opt/rbenv/shims/bundle
[20:05:17] werdnativ: havenwood: but I'm actually interested in installing some global gems outside of bundle
[20:08:06] werdnativ: ls /opt/rbenv/plugins: rbenv-vars ruby_build
[20:09:25] werdnativ: not sure if rbenv-vars is doing anything, I haven't loaded any of my own vars yet; I could try removing that.
[20:11:58] werdnativ: havenwood: thanks. I'll just wait and see if anyone responds to my github issue.
[20:12:09] werdnativ: working around it in the meantime


[22:28:57] werdnativ: why does Array({:a => 1}) != [{:a => 1}] ? it's actually [[:a, 1]] which I find surprising.
[22:34:50] werdnativ: right I guess that makes sense, I was thinking more along the lines of "wrap it as an array, unless it's already an array"
[22:37:48] werdnativ: centrx: that's cool but not very helpful for hsh.wrap
[22:38:14] werdnativ: oh, sorry, class method...
[22:39:49] werdnativ: yeah, I see.
[22:55:20] werdnativ: apeiros: generally I agree, this is a bit of a special case.


[23:39:47] werdnativ: If you have multiple rails app servers, how do deal with saving cached pages to the front-end web servers? (Some sync process, or?)


[02:54:06] werdnativ: jrhe: array.all? { |i| i.is_a? Type }.should be_true
[02:57:34] werdnativ: yeah, you can do that too.
[02:58:18] werdnativ: yeah, all? just reduces the array to a true or false...
[03:00:30] werdnativ: jrhe: not exactly. It depends what you put in the block. It should return a boolean for each item. [true, true].all? { |i| i.is_a? Fixnum } #=> false
[03:02:06] werdnativ: ah, sorry == true
[03:02:17] werdnativ: or ` be true`
[03:02:53] werdnativ: jrhe: be_true tries to do `true.true?` which is not a thing.
[03:03:21] werdnativ: true is a singleton TrueClass
[03:03:42] werdnativ: it doesn't have a .true? method which is what rspec's be_true translates to.
[03:04:14] werdnativ: however `x should be true` compares object identity.
[03:04:36] werdnativ: object1 should be object1 # same instance
[03:04:49] werdnativ: object1 should == object2 # compares identity
[03:05:02] werdnativ: sorry, * compares value
[03:05:32] werdnativ: "be" compares identity, "==" or "eq" compares value.
[03:06:01] werdnativ: "be_something" calls ".something?" and sees if it's true.


[20:58:25] werdnativ: How do you find which patchlevel release includes a fix? https://github.com/ruby/ruby/blob/trunk/doc/ChangeLog-2.1.0
[21:21:40] werdnativ: Is there a breakdown of the ruby changelog that shows which fixes landed in each patchlevel release?


[00:02:20] werdnativ: How do you guys deal with type casting from postgres? e.g. assoc_count returns a string, not a fixnum: http://wiki.postgresql.org/wiki/Driver_development#Type_Conversions
[00:07:16] werdnativ: lethjakman: something like: Rails.configuration.some_api.secret_key = ENV['SOME_API_SECRET_KEY'] || File.read(Rails.root.join("config/some_api.key")
[00:08:13] werdnativ: why be bound a file?
[00:08:43] werdnativ: just say MyGem.config.key = some_value, then it doesn't matter where the value comes from. can be file, can be ENV


[20:57:33] werdnativ: Anyone using pg, how do you handle casting for comparisons between dates and timestamps? It seems Arel only quotes Time objects as '2012-12-12 00:00:00' which the database sees as strings...
[20:59:58] werdnativ: If I do `where(some_date: time0..time1)` it becomes WHERE some_date BETWEEN '2012-12-12 12:12:12' AND '2012-12-12 12:12:12'
[21:01:13] werdnativ: This is comparing the date column to strings, I believe postgres internally casts the strings to DATE, which is not what I want??? I want to see if the date (at midnight) is between those times.
[21:02:59] werdnativ: Why doesn't Arel do (TIMESTAMP '2012-12-12 12:12:12') with Time values?
[21:06:36] werdnativ: tubbo: "it depends"
[21:10:40] werdnativ: Then I'd JSON that, assuming you don't need the actual relations in your data structure. Keep in mind any ActiveRecord query for that model will load the data unless you explicitly set `select` to not load that column. So if it gets too big, I'd put it elsewhere.


[17:49:01] werdnativ: This is kind of a hard thing to google for, but how can I get a list of class methods for an ActiveRecord model that are actually defined in that class; not generated/included from ActiveRecord::Base?
[17:53:55] werdnativ: mikecmpbll: yeah, but that includes all the before_* & after_* callbacks & everything else.
[19:55:42] werdnativ: nested forms are fine for the simple case, but it quickly gets messy.
[19:56:45] werdnativ: scyllinice: indexes. explain query.
[19:59:49] werdnativ: scyllinice: also, if there's concurrent writes to the database, your transaction might be waiting for locks to release, try a "show processlist" or "show innodb status" (as mysql root) to see what else might be running.
[20:00:55] werdnativ: I hate those. Especially when they come back.


[08:19:33] werdnativ: I'm trying to write a test in the devise test suite, I can't figure out how to POST with a valid authenticity_token: https://gist.github.com/avit/df2551ae37da6b267577
[08:20:15] werdnativ: Chintan: sentiment is an attribute on tweet or topic?
[08:21:43] werdnativ: Chintan: use has_many :through instead.
[08:24:08] werdnativ: Chintan: http://guides.rubyonrails.org/association_basics.html#the-has-many-through-association
[08:24:17] werdnativ: yes, something like that.
[08:27:51] werdnativ: How would you write the opposite of this test? https://github.com/plataformatec/devise/blob/master/test/integration/authenticatable_test.rb#L435
[08:29:09] werdnativ: sevenseacat: in other words, "POST request with a correct authenticity_token keeps session"
[08:29:46] werdnativ: sevenseacat: this is failing on the second assert… why? https://gist.github.com/avit/df2551ae37da6b267577
[08:30:24] werdnativ: (even without messing with the 'OK' token… I'm just trying to see why.)
[08:31:40] werdnativ: I'm not tinkering, I'm bug hunting. :)
[08:34:05] werdnativ: I have something I can reproduce normally, but I can't get CSRF posts to work right in the test environment, so I don't know how to express the test.


[05:42:23] werdnativ: echosystm, sevenseacat, why not pry-debugger?
[05:43:06] werdnativ: just sayin' :)


[00:51:14] werdnativ: I can't figure out how to read the "stored" value of a serialized attribute… this used to work in 3.2.12: mod.attributes_before_type_cast["attr"].serialize
[00:52:40] werdnativ: now in 3.2.14 the "serialize" method doesn't get injected into the serializer, you have to do Serializer.dump(mod.attributes_before_type_cast["attr"])
[00:53:49] werdnativ: I'm wondering if there's a better way, since that seems really clumsy.
[01:01:33] werdnativ: ARMIGER1: you can do redirection directly in routes too: http://guides.rubyonrails.org/routing.html#redirection
[01:05:49] werdnativ: I don't quite follow either... gist or gtfo. :-)
[01:25:34] werdnativ: gabeodess: you can mark the body string html = '<a href="…">'.html_safe
[01:27:04] werdnativ: gabeodess: actually I'm not sure that's your problem there.
[01:27:57] werdnativ: yeah, just noticed that.
[01:30:53] werdnativ: Anyone know how to read the serialized value for an attribute? https://gist.github.com/avit/be74ac0c42f705c3a012
[01:36:00] werdnativ: JoshuaPaling: class names and constants start with capital letters. instances are lowercase.
[01:36:18] werdnativ: @article = Article.find(1)
[01:36:59] werdnativ: instance variables start with @. In the case of controllers, anything you put into @article (or whatever) will also be shared with the view template.
[01:37:55] werdnativ: JoshuaPaling: when you call Article.find(1), it returns an instance
[01:38:54] werdnativ: JoshuaPaling: if you're just starting, go with the flow. I wouldn't worry about calling the static class in a controller.
[01:39:46] werdnativ: we don't call it that in ruby, but yes.
[01:40:18] werdnativ: there are "class methods" and "instance methods"
[01:41:26] werdnativ: basically, nothing is static in ruby. :-)
[02:00:22] werdnativ: anime4christ: maybe the locale is not set? or default_locale?
[02:00:49] werdnativ: crystalneth: http://api.rubyonrails.org/ ?


[21:14:58] werdnativ: It looks like Arel doesn't support inserting multiple rows at all. Is there a good trick to generate the bulk-insert SQL for "INSERT INTO t VALUES(1,2,3), (4,5,6)", safely?
[21:18:53] werdnativ: yes, not the usual ".save"… Hmm. that will be any faster?
[21:19:08] werdnativ: thanks fryguy, looking at that just now...


[17:19:24] werdnativ: Hey is there anything in activerecord to say if a model is newly persisted, i.e. just been created, not reloaded from db?
[17:21:59] werdnativ: I guess i can use an after_create callback to set an ivar… just wondering if there is already something for it.
[17:22:27] werdnativ: rsl, I know those… but persisted is true for old reloaded records too.
[17:24:27] werdnativ: rsl, I build a ImportTable that has many ImportCells. the cells "touch" the parent table… but when I trigger the first save on the the parent table, each cell "updates" the parent table as it gets saved.
[17:25:03] werdnativ: so I need to say touch: proc { |c| c.parent_table.newly_persisted? } or similar
[17:26:06] werdnativ: yup. doing that! thanks.
[17:28:37] werdnativ: that almost seems like it should be made default behaviour… I might try: def touch; @touched=true; super; end
[17:29:17] werdnativ: and I mean super unless @touched
[17:30:17] werdnativ: yeah, other order…
[17:30:20] werdnativ: that way it only saves to the database the first time.
[17:32:17] werdnativ: to be clear: def touch; super unless @touched; @touched = true; end
[17:38:39] werdnativ: rsl, I don't think "changed" should play into it. I might want to allow touching it even when it hasn't changed. (like when only its association changes.)
[17:41:41] werdnativ: rhizome: I am. the question is when multiple children all get saved and each one touches the parent, it triggers too many needless sql updates. Only need to touch once.


[01:13:07] werdnativ: Anyone know how CollectionProxy is delegating method_missing to the @target now? This changed from 3.2 to 4.0, I'm trying to find where it went: https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/associations/collection_proxy.rb#L39


[00:00:09] werdnativ: it gets you beatings from fellow devs tho.
[00:01:04] werdnativ: CAT5 o nine tails?
[00:01:51] werdnativ: it's dramatic though. that's what matters. :)


[23:58:40] werdnativ: drale2k: backslash to escape the space works
[23:59:22] werdnativ: but it looks bad. prefer normal array syntax when it gets to that point...


[18:36:15] werdnativ: hey all, what's the nice way to get an input field for a model method that takes an array? https://gist.github.com/avit/b02cb1d213dbded01f8a
[18:38:39] werdnativ: toretore: good try but nope.
[18:39:32] werdnativ: "multiple: true" rejects the "column_names[]" as a method, and if I leave off the brackets then it doesn't add them back into the form input.
[18:41:24] werdnativ: toretore: "multiple: true" is for selecting multiple values in one input. I need several inputs each of which can select one value.
[18:44:49] werdnativ: kinda lame, but this'll have to do: = select_tag "#{f.object_name}[column_names[]]"
[18:47:05] werdnativ: webdestroya: +1 thanks.
[18:47:57] werdnativ: still wish there were a "this field takes a hash/array" option for form inputs.
[18:48:48] werdnativ: webdestroya: well, that generates a single multi-select input. I want separate single inputs, due to ordering (or hash keys)


[21:10:27] werdnativ: Looking at this solution: http://stackoverflow.com/a/12216253/61439 …it looks like the early return would look like a success and the task would not be retried. Am I wrong?
[21:21:47] werdnativ: Ontolog: yes. they are mixed into the view.
[21:22:48] werdnativ: yes. helper methods are mixed into the view. they share instance variables
[21:27:13] werdnativ: what he said
[21:27:42] werdnativ: http://stackoverflow.com/questions/3549713/controller-helper-method/3549739#3549739
[21:28:05] werdnativ: helpers are dumb easy… just ruby modules.
[21:28:31] werdnativ: what's weird is how rails shares stuff between controller and view
[21:28:52] werdnativ: by default yeah. but you can include more
[21:31:00] werdnativ: Ontolog: I don't remember what the default is anymore, but you can put helper :all in your ApplicationController and get all helpers all the time.
[21:31:36] werdnativ: I thought it did match up by controller name to helper module name but I could be wrong now.
[21:32:31] werdnativ: http://api.rubyonrails.org/classes/AbstractController/Helpers/ClassMethods.html#method-i-helper
[21:37:44] werdnativ: DouweM, Ontolog: so it's determined in Rails.configuration.include_all_helpers
[21:38:25] werdnativ: yeah, you can turn it off and set it in each controller. I think "off" means just load the matching helper module name for the controller.
[21:38:37] werdnativ: …if it exists
[21:39:05] werdnativ: I'm going from memory. Don't trust me. :)
[23:22:47] werdnativ: Is there a way to set what *_path a model name translates to? https://gist.github.com/avit/c990e17721eb85a3f313
[23:33:07] werdnativ: Thanks Radar. I figured as much: I was wondering if there's a way to override class_name or some similar method (Model.param_name, I wish)


[00:00:45] werdnativ: scrapcode: you'll prolly have to escape the whole url if you're passing it as a param with query args like that.
[00:04:15] werdnativ: scrapcode: you will have a bad time passing a url with query args like "/add/title/http://youtube.com/?v=something" you will need to escape the "?" or else it will get split out.
[00:05:35] werdnativ: scrapcode: yes
[00:13:15] werdnativ: celluloid in front, calling to rails stack behind it, I assume?
[00:19:34] werdnativ: Any good resources for tracking down memory leaks in rails 3.2 & ruby 1.9? Craving something like this: https://github.com/tmm1/gdb.rb/blob/master/README#L110
[00:21:27] werdnativ: gp5st: is it in the Gemfile.lock? look at the lines above it to see what is depending on it.
[00:23:48] werdnativ: gp5st: yes you should definitely start it through bundle exec there.
[00:24:46] werdnativ: gp5st: if you start it without bundler before a gem loads its dependencies, it might load a different version from your system than what your Gemfile.lock file specifies.
[00:25:23] werdnativ: gp5st: add gem "raindrops", "~> 1.2.3" or whatever the version is
[00:26:47] werdnativ: gp5st: the main problem is you're not loading your app through bundler, and it's picking its own versions from the system before bundler loads.
[00:27:38] werdnativ: that should solve it gp5st.
[00:29:25] werdnativ: I hate anon classes. https://gist.github.com/avit/5499197 Trying to trace down memory leaks: anyone recognize what this "#<Class:0xb8f4e33c>" is?
[00:31:48] werdnativ: good idea, thanks rushed


[23:39:26] werdnativ: s2013: yes, bundler is separate from rails
[23:40:06] werdnativ: s2013: bundler is a gem that manages gem dependencies
[23:43:07] werdnativ: gem list -r gem # nope, gem is not a gem. someone should write one. :P
[23:54:24] werdnativ: scrapcode: I think it matches on the period for :format, but I don't remember.
[23:54:53] werdnativ: could be wrong for /* though