« Back to channel list

#RubyOnRails - 05 November 2013

« Back 1 day Forward 1 day »
[00:00:58] Apane: thanks bricker
[00:04:16] smathy: blackmesa, { data: the_code_that_generates_that_array_of_hashes }.to_json
[00:04:32] bricker: data: magic(true).to_json
[00:05:29] smathy: I always try to match the quality of my answer to the quality of the question.
[00:06:46] blackmesa: thx Ill try that smathy
[00:11:32] kara_sweets: i have a pretty db intensive query that i run when my home page loads, it takes around 20 seconds to finish
[00:11:44] kara_sweets: i was wondering what the best way to run this in the background and store it wouldbe
[00:11:54] kara_sweets: basically run the query, store data, and hand to front end
[00:13:07] smathy: kara_sweets, background, or - http://guides.rubyonrails.org/caching_with_rails.html
[00:18:47] Apane: So i have an array of movies, how can I create a range from a-z of them?
[00:21:00] smathy: Apane, do you mean how can you order an array alphabetically based on something within the array?
[00:21:11] Apane: smathy, right
[00:22:05] smathy: Apane, probably with the Array#sort_by method, but without knowing more about the elements of your array that's all I can suggest.
[00:24:40] kara_sweets: i followed the steps in rails guides for caching, https://gist.github.com/anonymous/ba438b7a5670bbd81a13
[00:24:56] kara_sweets: but i still see a massive sql query running in my logs when i refresh the page
[00:25:03] kara_sweets: takes around 30 seconds to load
[00:25:35] soahccc: kara_sweets: development
[00:25:53] kara_sweets: before pushing
[00:26:06] soahccc: I think you need to enable caching for the environment
[00:26:12] soahccc: but I'm not sure for test
[00:26:44] Kamuela: What's a good rails project to look at to help you understand rails conceptually?
[00:27:04] kara_sweets: i added it development.rb in cofig
[00:27:24] soahccc: and for test as well
[00:29:42] EminenceHC: tubbo: Thanks that worked
[00:30:50] crucify_me: Hi in a model for a micropost, there is the statement: ' default_scope -> { order('created_at DESC } ' . This is not obvious to me: why would a method that returns microscope in descending order be an issue of scope?
[00:30:51] kara_sweets: tubbo: any idea why this is still generating sql query instead of searching cache? https://gist.github.com/anonymous/ba438b7a5670bbd81a13
[00:31:38] smathy: crucify_me, scopes are used for all sorts of things, basically anything that can be added to a model find/query, including order.
[00:32:45] crucify_me: smathy: thanks. I'm a noob, I only understand scope in terms of program flow in pure ruby. could you elaborate?
[00:33:26] smathy: crucify_me, I can't do a better job of the docs: http://api.rubyonrails.org/
[00:33:45] crucify_me: ok smathy thanks
[00:36:04] kara_sweets: anybody know how to get fragment caching working? https://gist.github.com/anonymous/ba438b7a5670bbd81a13
[00:41:51] crucify_me: smathy: If I could ask, default_scope is not to be understood in the same way as with program flow, is it?
[00:42:27] crucify_me: if that makes sense...
[00:42:37] makerop: in rails 4 is there anything special i need to do to setup a button_to with destroy?
[00:43:00] makerop: I can't seem to actually delete the record, even though my logs look like it is posting the param to the right controller
[00:43:34] makerop: https://gist.github.com/makerops/f1c2d401b88894960ecf
[00:47:15] smathy: crucify_me, correct, different thing. It's the same underlying meaning, ie. restricting the context of some operation.
[00:47:59] smathy: crucify_me, so the original default_scope (and named scope) would do things like add "status = 'active'" to every query for a model, hence limiting the scope of all queries to only those results where status = 'active'
[00:48:54] crucify_me: ok so the argument is the restriction . smathy
[00:49:06] smathy: crucify_me, very soon (maybe from the very beginning), all types of query changes were added, so any part of an ActiveRecord query, eg. order() or limit() anything you like. But they're still called scopes, even though strictly they're not anymore.
[00:50:23] crucify_me: smathy: thats why I was confused, because it just looked like it was saying "accept this argument for the object," like it was pointless.
[00:51:40] bricker: default scope :( :( :( :(
[00:52:01] crucify_me: bricker: you don't like using it?
[00:52:42] smathy: Most people don't like it, although for an order() it's fairly innocuous.
[00:52:56] bricker: crucify_me: it is a bad idea. It will confuse you, but worse, it will confuse other developers on the project. It will introduce bugs into your code. It will make your code harder to test.
[00:54:13] bricker: It's a classic anti-pattern. Seems nice, but will just cause you headaches down the line.
[00:54:45] makerop: do i need to explicitly permit :id in rails 4?
[00:55:28] crucify_me: class Article < ActiveRecord::Base
[00:55:28] crucify_me: default_scope { where(:published_at => Time.now - 1.week) }
[00:55:30] bricker: makerop: you shouldn't be sending the ID in the form params
[00:55:41] crucify_me: bricker: smathy what would be a better way to write parameters in this case the api example ^^
[00:55:47] bricker: crucify_me: No! Noooo!!!!
[00:55:52] bricker: crucify_me: Just make it a normal scope!
[00:56:14] bricker: scope :recent, -> { where(published_at: Time.now..1.week.ago) }
[00:56:14] justthisguy: Context: Radio stations and Zip codes. A radio station has lots of info [:name, :frequency, :call_letters, ...] but the only info about a zip code is the code '12345' which can be stored as a string. We all know how to build a many-to-many association between two ActiveRecord models but it would be preferable to not create an ActiveRecord table for zip code.
[00:56:15] bricker: or whatever
[00:56:19] makerop: bricker how would i do a delete?
[00:56:21] justthisguy: Question: Is it possible to build a many-to-many association between one ActiveRecord model and a string?
[00:56:31] makerop: button_to*
[00:56:50] bricker: makerop: what do strong parameters have to do with deleting a record?
[00:57:49] crucify_me: thats was the api example but thanks bricker smathy
[00:58:03] bricker: justthisguy: you can define an array and fake it, or use something like active_enum, or wait until Rails 4.1 is released when that functionality is built-in
[00:58:33] julian_: does anyone know of the HTML language that is assosiated somewhat with RoR? JS vs Coffeescript and HTML vs ... ? what exactly?
[00:58:44] julian_: you don't have to close the divs. It know what you're doing from indentation. Very cool, but I've forgotten the name :(
[00:59:02] bricker: (or use rails master branch of course)
[00:59:37] bricker: julian_: ERB is default, although JS : CoffeeScript is not the as HTML : ERB
[00:59:37] bricker: julian_: HAML
[00:59:37] bricker: Slim maybe
[00:59:54] julian_: yeahh it's HAML that's the one
[01:00:47] bricker: Liquid... there are lots, here you go https://www.ruby-toolbox.com/categories/template_engines
[01:00:51] DanBoy: do a lot of people use haml/
[01:01:34] bricker: DanBoy: It's certainly the second most popular, after ERB
[01:01:53] julian_: I was thinking that
[01:02:04] julian_: I mean do people use coffeescript ?
[01:02:36] julian_: well that's good because I do like it x)
[01:02:54] justthisguy: @bricker thanks. did you see the Context just above the question? I can see how an array or active_enum could add many zip codes to one radio station but I do not see how that will allow me to add many radio stations to one zip code.
[01:03:14] julian_: and YAML does make sense..no more getting in a mess because I've misplaced some random </div>
[01:03:34] julian_: I do like being on the server side of things
[01:03:47] DanBoy: yaml ain't markup language tho :P
[01:03:52] bricker: justthisguy: oh, if you need many, use ActiveRecord#seralize, and serialize it into an array
[01:04:14] julian_: DanBoy: what does ML stand for then??
[01:04:24] DanBoy: lol i dunno i was just joking :P
[01:04:39] julian_: sir, are you high?
[01:04:52] bricker: justthisguy: http://apidock.com/rails/ActiveRecord/Base/serialize/class
[01:05:20] bricker: julian_: YAML stands for "YAML Ain't Markup Language"
[01:05:26] DanBoy: thats the joke
[01:05:30] DanBoy: not funny one
[01:05:33] DanBoy: but that was my joke :D
[01:05:37] julian_: I see now :(
[01:06:14] julian_: hoooold on
[01:06:25] julian_: I thought it stood for YET ANOTHER markup language ?
[01:06:38] DanBoy: bricker, has it right
[01:06:57] julian_: I think someone must be high
[01:07:10] julian_: because I just realised I was talking about HAML a few seconds ago x)
[01:07:28] bricker: julian_: used to stand for that. http://en.wikipedia.org/wiki/YAML
[01:07:43] DanBoy: if i was stoned i wouldn't be wasting it here
[01:08:26] julian_: DanBoy: This is a lovely place!
[01:08:34] julian_: bricker: Ah I see
[01:09:29] julian_: I wish these geeks would create sensible names for new languages. It all gets a bit confusing!
[01:09:37] julian_: AJAX is the best name. Sheer genius name
[01:12:02] julian_: sevenseacat: What? Ajax is a figure in Greek mythology, that what makes it clever IMHO
[01:12:15] jrobeson: it's an acronym.. and not a language either.
[01:12:23] sevenseacat: thats... got nothing to do with ajax in programming
[01:12:29] sevenseacat: and ajax also isnt a language
[01:12:57] julian_: I know it's nothing to do with it in a programming context
[01:15:34] kain: controller spec: request.env['X-AUTH-TOKEN'] = 'bla' , controller: request.headers['x-auth-token'] => nil, ideas?
[01:15:55] kain: Rails 4.0.1, works in 3.2.x
[01:20:23] kain: meh, I have to change specs to send request.env['HTTP_X_AUTH_TOKEN']
[01:48:54] Apane: https://gist.github.com/Apane/c9d646155eeda6ceda9f why isn't this working? pretty simple isn't it?
[01:50:08] Kamuela: What's a good resource to look at open rails projects?
[01:50:53] AlwaysBCoding: anyone know of a good strategy to screenscrape data with Nokogiri from a site that loads its data with javascript?
[01:51:08] sevenseacat: Apane: you misspelt 'initialize'
[01:51:21] julian_: all_image[23][0]["title"]
[01:51:47] julian_: what is the rule when creating HTML attributes?
[01:51:52] julian_: all_image[23][0]["title"]
[01:52:14] julian_: that returns the value of the "title" attribute perfectly
[01:52:18] julian_: but all_image[23][0]["title"]
[01:52:42] kara_sweets: Radar: you in here?
[01:52:53] julian_: but this all_image[23][0]["test"] doesn't return anything at all
[01:53:19] sevenseacat: julian_: you know theres a set of valid HTML attributes, right
[01:53:24] sevenseacat: and test isnt one of them
[01:53:25] kara_sweets: configured action_controller to perform caching in development and added caching code, but i still see the query running in the logs https://gist.github.com/anonymous/ba438b7a5670bbd81a13
[01:55:22] julian_: sevenseacat: I do know the valid HTML attributes but nobody cares about them, and the page renders perfectly 100% of the time even with legacy browsers when using 'custom' attributes
[01:55:45] sevenseacat: i dont really care about helping you then
[01:55:52] julian_: also, as of HTML-5 you can prepend any custom attribute with " data- "
[01:56:07] sevenseacat: however, you're not
[01:56:43] julian_: all_image[23][0]["title"]
[01:56:59] julian_: urgh this damn this keeps htting enter automatically when I paste
[01:57:03] julian_: as all_image[23][0]["title"]
[01:57:25] julian_: all_image[23][0]["data-title"]
[01:57:32] kara_sweets: anybody got advice for fragment caching?
[01:57:35] julian_: that still doesn't retrive the data
[01:57:37] kara_sweets: having a hard time :(
[01:57:48] sevenseacat: julian_: so whats all_image[23][0] ?
[01:59:08] julian_: sevenseacat: It's a multidimensional array.
[01:59:21] julian_: Standard attributes get through aright though
[01:59:28] sevenseacat: well no wonder you cant call ['data-title'] on it then
[01:59:43] sevenseacat: cuz that would be a single dimension
[02:00:13] julian_: no but all_image[23][0]["title"]
[02:00:17] julian_: that works fine
[02:00:30] julian_: a multidimensional array is just an array containing more arrays, right?
[02:00:38] julian_: the last array is a hash, then#
[02:00:59] sevenseacat: how about when i ask you 'what is it', you actually show me what it is, then
[02:01:06] sevenseacat: instead of being coy
[02:01:35] julian_: jesus get a load of Nanny Mcphuk
[02:02:12] sevenseacat: its not like im asking stupidly complicated questions here
[02:02:44] sevenseacat: mornin' dopie
[02:03:12] dopie: Readying for a tittalating question??
[02:04:33] dopie: what am i trying to do , I have search which searches for crimes the user searches.... the thing is Crimes belongs to Crimeheader which in turn belongs to Category ... how do i route to the specific Crime after the person searches??
[02:04:43] dopie: https://gist.github.com/staycreativedesign/7312628
[02:05:10] dopie: category_crimeheader_crime_path
[02:05:25] sevenseacat: put that path in the link_to?
[02:05:35] dopie: categories/:category_id/crimeheaders/:crimeheader_id/crimes/:id(.:format)
[02:05:51] sevenseacat: also, why outdated activerecord querying syntax :(
[02:06:07] dopie: sevenseacat, what?
[02:06:11] dopie: for the search?
[02:07:08] dopie: railscast
[02:07:21] sevenseacat: a rails 2 railscast by the looks of it
[02:09:46] dopie: sevenseacat, <%= link_to(search.name, category_crimeheader_crime_path(crime.name)) %>
[02:10:07] sevenseacat: your route doesnt take a string
[02:10:41] kara_sweets: would fragment caching work for iterating though an array of objects and creating JS?
[02:12:02] dopie: sevenseacat, params
[02:12:09] kara_sweets: is fragment caching the bane of irc
[02:12:31] bricker: kara_sweets: sure, that would work
[02:12:43] kara_sweets: bricker: hallelujah sweet jesus a response
[02:13:01] kara_sweets: I'm not getting much luck here, doesn't rails typically store the cached output in the public dir?
[02:13:13] kara_sweets: or lib/assets?
[02:14:55] kara_sweets: sevenseacat: sadly still not seeing anything
[02:14:58] kara_sweets: heres my code : https://gist.github.com/anonymous/87e267c7f4e0cd59bd5b
[02:18:31] sevenseacat: kara_sweets: are you actually having a problem?
[02:18:46] kara_sweets: yea basically when i refresh the page i still see the sql query running like crazy in the logs
[02:18:53] kara_sweets: doesn't seem to be pulling the cached data at all
[02:19:05] kara_sweets: that loop takes almost a minute locally
[02:20:38] sevenseacat: did you restart your server after changing your development.rb file? just tried caching stuff and it worked fine
[02:21:12] sevenseacat: it'll appear in your logs like this https://gist.github.com/karpah/7312784
[02:23:08] kara_sweets: agh ok no i don't think i restarted doh
[02:23:12] kara_sweets: trying right now
[02:23:27] kara_sweets: with this set up I'm guessing i manually expire the cache?
[02:23:42] sevenseacat: you can set an expiry time, or manually expire it
[02:24:17] jstrong: in Rails can you do a create that goes directly to sql?
[02:24:37] sevenseacat: probably, but why would you?
[02:24:46] jstrong: because this particular part of the flow has some validations
[02:24:49] jstrong: but it's a mass assignment
[02:24:52] kara_sweets: sevenseacat: wow caching is amazing
[02:24:58] kara_sweets: loading so fast now
[02:25:00] jstrong: all the validations are done upfront in a robust class
[02:25:03] kara_sweets: feelsgoodman.jpg
[02:25:06] jstrong: then it needs to do like 9000 inserts
[02:25:21] jstrong: so i don't want the n+1 bonanza of model by model validation
[02:26:46] mjc_: jstrong: n+1 bonanzas almost sound fun :(
[02:27:03] kara_sweets: interesting - so by wrapping the code in the cache block, rails also recognizes when you make a change to the code, and expires the cache?
[02:27:08] jstrong: mjc_ really I need to do one insert statement wrapped in a transaction but I want to start by just skipping all the model callback cruft
[02:27:13] jstrong: mjc_ this is why callbacks are evil
[02:27:15] sevenseacat: kara_sweets: no
[02:27:17] kara_sweets: at least thats anecdotally what just seemed to happen
[02:27:37] kara_sweets: sevenseacat: hmm , i changed a param and it didn't grab from the cache
[02:27:40] mjc_: it recognizes changes to the template
[02:28:02] mjc_: jstrong: one of the many reasons
[02:28:20] jstrong: mjc_ BUT if you've got them you've got them and they are a bitch to refactor and I can't quite do that right this sec
[02:28:39] mjc_: jstrong: I just like the 80s super sale image you put in my head by calling it a bonanza :P
[02:28:48] kara_sweets: sevenseacat: it looks like its caching both versions
[02:29:02] kara_sweets: so it doesn't expire the old, but makes a new store
[02:29:41] jstrong: what's worse is taht rails doesn't even have a good way of skipping callbacks for a save or create
[02:29:58] jstrong: once you have to go skipping callbacks you know things are wrong butt
[02:34:20] Technodrome: anyone here serve their app with gzip?
[02:34:41] mjc_: probably most of us tend to make nginx or apache or whatever do the gzipping
[02:35:59] Technodrome: thats what i mean i guess
[02:36:02] Technodrome: i mean is it worth doing
[02:36:07] Technodrome: or does it increase cpu usage alot?
[02:38:26] mjc_: it's almost insignificant these days
[02:39:09] mjc_: it would be silly not to gzip text
[02:39:25] Technodrome: i mean what is the advantages of gzipping?
[02:39:40] Technodrome: i mean i know its supposed to be better for the client? but
[02:39:46] Technodrome: i mean can it really save that much time for them?
[02:39:47] sevenseacat: smaller file sizes
[02:40:36] mjc_: less bytes sent over the wire
[02:40:56] mjc_: webpagetest.org can help you measure loading times
[02:41:11] sevenseacat: ACTION sends that link to pivotal tracker
[02:41:25] sevenseacat: their app is freaking slow as shit
[02:42:12] Technodrome: i mean, having gzip on won't make the rails app server pump out more request
[02:43:31] mjc_: on most apps page load times are most of what the user actually spends time waitingo n
[02:43:53] mjc_: not a large number of requests from rails itself
[02:43:55] sevenseacat: transwer times, asset load times
[02:43:58] aquarian_1981: I'm in the process of upgrading to rails4 and am having trouble with one of my config lines
[02:44:10] DanBoy: hey im writing a test for a controller that accesses all the restful actions as an admin and expects 200 to be returned, with update and destroy im getting 304
[02:44:17] DanBoy: 304 means nothing has changed right?
[02:44:21] sevenseacat: pivotal tracker for example loads a 3MB unminified JS file before you can use the app
[02:44:21] aquarian_1981: in rails 3 i `config.paths["config/routes"] += Dir[Rails.root.join('config', 'routes', '*.rb').to_s]` in my applicaiton.rb
[02:44:28] aquarian_1981: but that doesn't work in rails 4
[02:44:28] sevenseacat: it takes a *long* time
[02:46:17] DanBoy: sorry im getting 302
[02:46:45] sevenseacat: 302 is a redirect
[02:51:14] Technodrome: i wonder whats better deflator or using gzip with nginx
[02:56:31] kara_sweets: is there any way of keeping js private so that people on client can't see it?
[02:56:54] sevenseacat: kara_sweets: no.
[02:57:18] kara_sweets: sevenseacat: did you change your username from karpah?
[02:57:18] sevenseacat: thats like asking if you can hide your HTML.
[02:57:29] coca_rails: What's up Danboy!
[02:57:42] DanBoy: just working on some specs
[02:57:51] coca_rails: nice, specs for what?
[02:58:12] DanBoy: just some controller
[02:58:51] coca_rails: You should join me on my project ;) As you can tell my recruiting efforts are persistent.
[02:59:05] crucify_me: hi line 141 has a test that tests for the deletion of associated microposts for a soon-to-be deleted user. I see why to_a is used, but is line 145 an iteration over the microposts still in the database or the array 'microposts' (line 142) github.com/railstutorial/sample_app_rails_4/blob/master/spec/models/user_spec.rb thanks
[03:00:16] kara_sweets: im having a brain stop
[03:00:19] kara_sweets: does this make sense
[03:00:25] kara_sweets: points = find_points(users)
[03:00:39] kara_sweets: assuming find_points is a function that returns a value
[03:01:18] sevenseacat: crucify_me: it's an iteration over the array, to make sure the microposts were actually deleted
[03:01:59] sevenseacat: its basically 'these were the users microposts before we deleted the user, now we deleted the user, now let's make sure each of the microposts were deleted too'
[03:02:29] crucify_me: sevenseacat: thanks, one sec I'm rereading the textbook.
[03:07:01] kara_sweets: does ruby handle avg's of floats well to 6 decimal places?
[03:07:13] kara_sweets: i.e. will it round or keep them significant?
[03:07:38] Technodrome: AntelopeSalad: you around?
[03:07:48] sevenseacat: nothing with floats is precise
[03:07:52] sevenseacat: try using actual decimals
[03:10:08] crucify_me: sevenseacat: well, I can't see it, because if rspec is iterating over a copy of a (full) array, where and how does it simulate the deletion? github.com/railstutorial/sample_app_rails_4/blob/master/spec/models/user_spec.rb
[03:11:08] sevenseacat: crucify_me: it doesn't 'simulate' anything, it deletes in the @user.destroy
[03:13:05] DanBoy: sevenseacat, generally update and destroy should always redirect right?
[03:13:25] sevenseacat: DanBoy: for a html response, yeah.
[03:13:33] DanBoy: ok thanks
[03:14:04] kara_sweets: coordinates = find_avg_of_points(posts_nearby)
[03:14:05] kara_sweets: does that make sense?
[03:14:11] kara_sweets: or does that work?
[03:14:27] sevenseacat: depends what you have find_avg_of_points and posts_nearby defined as
[03:17:35] sjuxax: What the HECK is the deal with all these url_for documents?!?!
[03:17:45] kara_sweets: find_avg_points is a function
[03:17:48] sjuxax: http://apidock.com/rails/ActionView/Helpers/UrlHelper/url_for
[03:17:51] kara_sweets: posts_nearby is an array
[03:17:55] sjuxax: Options do not include :controller or :action
[03:18:00] crucify_me: sevenseacat: ok thanks that is helpful. But line 146 is testing for an *empty* Micropost. So I guess the deleted user's Micropost array in the database is still there, its just empty, right?
[03:18:01] kara_sweets: would it need to be a block?
[03:18:15] sjuxax: immediately used in the examples are :controller and :action
[03:18:36] jrobeson: sjuxax, what rails version are you actually using? 4?
[03:18:45] jrobeson: apidoc hasn't gone past rails 3 yet
[03:19:04] jrobeson: not sure whwne the last time apidoc.com was updated
[03:19:06] crucify_me: or not array, whatever the active record term is sevenseacat
[03:19:25] sjuxax: I am using Rails 4, but regardless of version it doesn't make any sense for this page to tell me a list of options, and immediately start using options that aren't listed
[03:19:34] kara_sweets: hmm how do i define a function in a model for use in another function in the model, but not as a class or instance method?
[03:19:42] sjuxax: Why can I say things like :controller and :action and get them picked up if the API claims it doesn't know anything about those?
[03:19:59] sevenseacat: crucify_me: it looks up each micropost and makes sure it is no longer in the database. i have no idea what you just said so i dont know if its the same thing or not.
[03:20:03] jrobeson: because you're looking at the wrong api docs sjuxax
[03:20:09] jrobeson: go to api.rubyonrails.com
[03:20:23] sjuxax: So APIdock is simply wrong?
[03:20:45] jrobeson: it's simply out of date
[03:20:57] jrobeson: which is what i said in the first place
[03:21:18] sjuxax: Yes, I understand it's out of date. The problem is that the document appears to be self-contradictory regardless of its age
[03:21:37] sjuxax: Options: lists no option named :controller or :action
[03:22:00] PPH: Anyone already tried to run webrick on centos?
[03:22:00] sjuxax: so example usage shows it passing options :action and :controller
[03:22:01] crucify_me: thanks sevenseacat there is a name for the format of the object, a active record term, before it is converted to an array. cant find it but thanks!
[03:22:16] jrobeson: those are possible options sjuxax .. they are just not really recommended
[03:22:26] jrobeson: it's likely that you're looking at the wrong url_for
[03:22:40] PPH: I'm wondering what would be a Good os to run a rails server on.
[03:22:56] sjuxax: If they're possible options, how come the API documentation doesn't list them as possible? I checked both ActionView and ActionController
[03:23:23] jrobeson: they are listed somewhere..
[03:23:45] crucify_me: sevenseacat: sorry its called an active record collection proxy
[03:24:54] jrobeson: in any case. sjuxax .. you likely shouldn't be using them anyways..
[03:25:44] foucist: PPH: put gem 'thin' in the gemfile, and then rails server will run that by default, and it'll be a lot faster than webrick.. any unixy OS is good, linux, osx, etc
[03:26:06] jrobeson: sjuxax, or you know.. it could just be a doc bug that you could fix if you really think it's missing
[03:27:07] kara_sweets: hmm I'm getting a method can't be found error for find_avg_of_points here https://gist.github.com/anonymous/1eec0d0e4dacc7f32c82
[03:29:31] PPH: foucist: I tought I read thin wasn't suited for prod.. Am I wrong?
[03:29:55] foucist: PPH: thin is good for prod, that or unicorn
[03:29:58] jrobeson: thin is fine for prod.. but i use unicorn or puma
[03:29:58] foucist: unicorn is better than thin
[03:30:10] foucist: webrick is not suited for prod at all
[03:30:17] kara_sweets: unicorn will utilize your server resources better
[03:30:23] kara_sweets: more bang for your buck
[03:31:30] kara_sweets: anybody understand why find_avg_points would return an undefined method error here? https://gist.github.com/anonymous/1eec0d0e4dacc7f32c82
[03:31:54] dyer: Hey guys, anything change in 3.2 w/ controllers ? Its been a while since I have used rails and I am try to log something from a controller and it doesnt seem to be happening... I can see in the logs where its hitting the index route of my controller ( Processing by BrowsersController#index as HTML ) but nothing in the index method seems to happen. ( eg, logger.error, logger.fatal, exit 1, ect )
[03:32:21] PPH: foucist: well I'll give a try to thin.. my coworker's a fan of the guy who made it so he's gonna be cheerful:P
[03:33:46] kara_sweets: should the method be in a helper?
[03:33:57] kara_sweets: or just put in private
[03:37:23] foucist: kara_sweets: what? it shouldn't return undefined
[03:37:39] foucist: kara_sweets: what do you mean by helper, you're not trying to call it from the view are you
[03:37:57] kara_sweets: I'm getting an undefined_method error
[03:38:02] kara_sweets: for find_avg_points
[03:38:07] kara_sweets: and i don't understand why
[03:38:11] DanBoy: is there any public repo's of some real world rails applications i could see and learn from?
[03:38:42] foucist: kara_sweets: change it to protected and see if that makes a diff
[03:38:54] foucist: but that doesn't make sense
[03:39:21] kara_sweets: i don't get it either
[03:39:49] foucist: kara_sweets: er, gistie the actual error message
[03:41:34] kara_sweets: undefined method `find_avg_of_points' for #<Class:0x007fcea3cbe278>
[03:43:19] jonathancutrell: Hey folks. I'm working with activeadmin/formtastic, and I'm trying to understand how I can set the labels of a checkbox selection.
[03:43:23] jonathancutrell: it's a group of objects.
[03:43:49] jonathancutrell: f.input :project_ids, :label => "Selected Sections", :as => :check_boxes
[03:44:25] kara_sweets: should it be a lambda or something?
[03:44:50] foucist: kara_sweets: er, where's the error message showing up though? how are you callng this
[03:45:05] kara_sweets: <% circles = User.circles_to_map %>
[03:45:38] sevenseacat: kara_sweets: i think you need to gist all of the code and the full error message
[03:45:55] jrobeson: if your maps lead in in circles, they aren't very good
[03:46:25] jrobeson: bah dum bump
[03:47:40] Technodrome: what would be faster , rack deflator gzip or doing the gzip with nginx?
[03:48:02] jrobeson: nginx anything
[03:48:17] jrobeson: anything that doesn't have to touch ruby has a huge chance of being way faster
[03:48:35] jrobeson: since hopefully you're zipping up more than your ruby output..
[03:50:35] kara_sweets: foucist: sorry, i was calling that inside of a view
[03:56:51] kara_sweets: alright solved that problem
[03:56:57] freedrull: what happens if you call index_by and there are duplicate keys?
[03:57:02] kara_sweets: just made it a class method (even tho that doesnt seem right)
[03:57:07] kara_sweets: but now this issue Math::DomainError: Numerical argument is out of domain - "acos"
[03:57:48] helpa: freedrull: Why don't you try it and find out for yourself?
[03:57:48] jrobeson: freedrull, !try
[04:00:32] sevenseacat: kara_sweets: if you're not gisting code and errors, we cant help you.
[04:00:43] sevenseacat: we're not mindreaders.
[04:04:25] kara_sweets: https://gist.github.com/anonymous/d194327e687613631982
[04:04:33] kara_sweets: error and values in description
[04:04:41] kara_sweets: this is a mathy trig error
[04:04:45] bricker`LA: I'm trying to add a callback at the beginning of this method: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/nested_attributes.rb#L513 To modify the receiver in a certain way. The reason is because assigning objects like `self.pets << new_pet` runs before_add and after_add, but just assigning `self.pets_attributes = { ... }` doesn't run these callbacks for already-existing Pet objects.
[04:04:45] kara_sweets: anybody good at trig?
[04:05:00] bricker`LA: The only way I got it to work was to completely override those methods, but that is a dumb idea
[04:05:28] bricker`LA: Is there an option that I'm forgetting?
[04:06:30] kara_sweets: you know what, i was using the inverse
[04:06:32] kara_sweets: instead of standard
[04:06:35] bricker`LA: I think I need to rethink my strategy
[04:06:41] kara_sweets: crisis averted
[04:06:46] kara_sweets: ill be here all night folks
[04:26:32] rhizome: bricker`LA: nothing wrong with overriding the setter
[04:28:05] bricker`LA: rhizome: *_attributes= you mean? Unfortunately that won't work for me - I need to modify the parent object.
[04:28:22] bricker`LA: I think I got it though, without having to override anything
[04:40:35] bricker`LA: I hate the inconsistency of assigning associated object. I wish `persisted_record.pets << new_pet` wouldn't save until the parent object was saved. This is the case if the parent object is new, but if it's persisted, it goes straight to the database. That's odd if you ask me.
[04:42:31] sevenseacat: if i add something to the association of a persisted record, i expect it to be persisted
[04:43:23] bricker`LA: sevenseacat: then I guess you and I have different opinions about this.
[04:43:32] sevenseacat: i guess we do
[04:43:48] bricker`LA: sevenseacat: imo, `person.name = "sevenseacat"` and `person.pets = [dog]` should behave the same
[04:44:23] helpthebored: any idea why my schema file automatically changed itself to use colons in place of hash rockets?
[04:44:38] helpthebored: I'm on sublime+ruby2+rails4
[04:44:39] bricker`LA: helpthebored: did you upgrade to rails 4?
[04:44:39] sevenseacat: wait, youve changed from << to =
[04:44:56] jrobeson: helpthebored, because they liked it better?
[04:44:58] helpthebored: does the upgrade automatically do that?
[04:45:02] bricker`LA: helpthebored: rails 4 generates schemas with the new hash syntax
[04:46:05] helpthebored: do you suppose git will be smart enough to auto merge a schema file with hashrockets with the new rails 4 schema file?
[04:46:25] helpthebored: or will it ask me to manually fix all the hashrocket/colon merge conflicts?
[04:46:39] sevenseacat: easy way to find out
[04:47:23] bricker`LA: sevenseacat: same thing, << and = both save the associated object(s) https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/collection_association.rb#L130
[04:47:31] bricker`LA: unless the parent record is a new record
[04:48:19] sevenseacat: but complaining about the behaviour of << and then saying the behaviours of = should be the same are unrelated
[04:48:30] helpa: sevenseacat: PEDANT DETECTED. DISPERSING CUPS OF CALM THE FUCK DOWN.
[04:48:30] bricker`LA: sevenseacat: !pedant
[04:48:43] sevenseacat: and this is why we cant have sane discussions
[04:49:03] bricker`LA: sevenseacat: I can't roll my eyes hard enough
[04:49:16] helpthebored: weird. so master is rails 4 (as specified in gemfile) and I have feature branch rebased onto master. feature branch has rails 4 schema. master still has hash rockets. i guess the hashrocket replacement only happens once you make a new migration after upgrading to rails 4?
[04:49:32] bricker`LA: helpthebored: yes
[04:49:44] bricker`LA: or otherwise regenerate the schema file
[04:55:09] funburn: I've got a controller spec (POST) that can't pass because the model has a before_filter that calls a remote API. How do I override that or skip the callback?
[04:56:22] sevenseacat: sounds like a bad place for a callback
[04:56:59] funburn: sorry, I don't follow
[04:57:33] sevenseacat: dont write dodgy callbacks
[04:58:12] drocsid: I am having trouble with using code in an application.html.erb file. http://pastie.org/8456226
[04:58:28] drocsid: should be a cakewalk for an experienced rails developer
[04:59:09] funburn: sevenseacat https://gist.github.com/mtuckerb/b48226f77ce4504b0baa
[04:59:18] bricker`LA: funburn: if your test can't pass because of some code that it has to run, then the code is broken.
[04:59:30] funburn: its the purchase method that causes the problem
[04:59:45] sevenseacat: drocsid: and the problem is?
[04:59:48] bricker`LA: funburn: you can use webmock if you don't want your test suite making HTTP reqests
[04:59:49] funburn: in that the active merchant helpers don'e support #store
[05:00:07] drocsid: ActionView::Template::Error: undefined method `>' for nil:NilClass
[05:00:17] drocsid: sevenseacat: ActionView::Template::Error: undefined method `>' for nil:NilClass
[05:00:18] sevenseacat: so session[:counter is nil
[05:00:25] sevenseacat: session[:counter]
[05:01:05] drocsid: that makes sense
[05:01:19] sevenseacat: do you see how i drew that conclusion from that error message?
[05:02:09] bricker`LA: aaaaand he's gone
[05:03:38] funburn: bricked`LA: it seems like I should, in this one case, just override purchase
[05:03:46] funburn: to return true
[05:05:56] drocsid: sevenseacat: yeah i do.... just was suprised it didn't print the whole line for the error.
[05:06:08] drocsid: sevenseacat: thanks!
[05:21:39] tygator: DEV BootCamp, any one here care to persuade / dissuade me? My final application interview is tomorrow and I want to talk to some actual dev's to make sure I'm doing the right thing.
[05:29:18] bricker`LA: tygator: how much does it cost?
[05:34:37] Valentinial: Can someone tell me why this foundation 4 menu doesnt work? If you shrink the site down so that the menu hides, then click the area in the upper right (icon not showing but its there) you can see the drop down. If you click a different page in the drop down and it goes to that page, the drop down menu will no longer work unless you refresh the page
[05:34:45] Valentinial: http://184.168.111.214:3000/events
[05:37:54] Valentinial: join #zurb-foundation
[05:38:25] Valentinial: oops pretend that never happened
[05:38:44] sevenseacat: pretend what never happened? >_>
[05:53:47] dcope: hey all, does delayed_job have anything built in to schedule a job when a group of jobs have completed?
[05:54:03] sevenseacat: dont think so
[05:55:27] dcope: sevenseacat: bummer :(
[05:56:16] dcope: i figure i can expose a key in a job to group them logicaly. when one finishes i can query all the jobs to see if any others exist with said key and if not, schedule the final job.
[06:05:44] rhizome: that seems reasonable
[06:58:22] tagrudev: the dead Tuesday
[07:07:10] royalty: still Monday ova here
[07:16:49] grahamsavage: hi.. i have to send rails basically an "array" of form elements e.g. [{name: 'a'}, {name: 'b'}] etc what should i be naming the name attribute
[07:16:55] grahamsavage: name_1 or name[1] ?
[07:20:17] tagrudev: I don't get your question
[07:21:02] grahamsavage: ok so imagine we have 20 * first_name, last_name, gender on the page.. (textfield, textfield, select) in an html form
[07:21:12] grahamsavage: so in total we have 60 fields
[07:22:00] grahamsavage: what does rails expect the names of each field to be, so that we can construct a hash in the controller
[07:22:27] grahamsavage: that contains 1 => {:name => 'bla', last_name => 'something}, 2=> etc
[07:23:00] tagrudev: check out how you can handle nested forms
[07:24:14] grahamsavage: yeah i have.. they used fields for
[07:24:20] grahamsavage: but i'm not using any of the rails helpers
[07:24:40] grahamsavage: so i really just need to work out what the controller expects.. and i can't find that in the docs
[07:25:14] tagrudev: that's probably because that's not how you do it
[07:26:56] tagrudev: I am not suggesting that: doesnt matter how you send it just handle it in the create/update action
[07:27:15] tagrudev: yolo driven development
[07:27:18] grahamsavage: i think what i'll do
[07:27:31] grahamsavage: is on the client side, manually retreive the results and just build my own json hash
[07:27:38] grahamsavage: rather than calling the submit action on the form
[07:27:52] grahamsavage: that sounds the easiest/most straight forward way of doing it
[07:28:18] sevenseacat: sounds like a mess
[07:28:34] tagrudev: it sure does
[07:38:15] teufelChiCoder: got an issue with fancybox - https://gist.github.com/albertpak/97c3cd6f9774ee88d4ee - on a first click, it opens up just that div, but upon second click, it loads whole page - any idea why?
[07:38:48] rvanlieshout: cause the 2nd triggers a javascript error?
[07:39:49] teufelChiCoder: nope, no errors in console
[07:40:20] rvanlieshout: not even just when you click?
[07:40:29] rvanlieshout: it could get removed directly cause of the page load
[07:41:28] rvanlieshout: and is this using turbolinks?
[07:41:42] teufelChiCoder: no turbolinks - it's on rails 3.2.14
[07:41:52] rvanlieshout: then recheck that error on second click
[07:43:02] rvanlieshout: javascript error that is. make sure your javascript console isn't emptied on page load
[07:45:05] teufelChiCoder: ok, will try it now
[07:49:54] teufelChiCoder: hmmm, looks like u were right - gem that i was using, is generating an error
[07:51:49] sevenseacat: fancy that ;)
[08:01:25] rhizome: guard minitest spork == sads
[08:03:36] tobago: is there a helper transforming a name like "foo[bar][goo]" into an id like "foo_bar_goo"?
[08:04:40] tagrudev: tobago, nope there isn't build it yourself
[08:05:12] rvanlieshout: sure there is
[08:05:33] rvanlieshout: look at the source of an input helper
[08:06:20] tagrudev: input helper ?
[08:06:36] jrobeson: anybody using the reform gem with a has many relationship and wanna share their controller tests?
[08:06:39] bricker`LA: why use `%q` here? s.add_runtime_dependency(%q<activemodel>, [">= 3.0"])
[08:06:43] bricker`LA: https://github.com/rspec/rspec-rails/blob/master/rspec-rails.gemspec#L24
[08:06:56] rvanlieshout: tagrudev: like text_field
[08:06:57] bricker`LA: What advantage does it have over normal quotes in this case?
[08:07:32] rvanlieshout: tobago: http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-text_field_tag
[08:07:39] rvanlieshout: click on show source
[08:08:02] rvanlieshout: it uses a private method sanitize_to_id though :)
[08:08:25] tagrudev: which is not a helper
[08:08:34] rvanlieshout: it is, but private
[08:08:36] tobago: tagrudev, sanitize_to_id does it
[08:08:55] tobago: I#ll copy the regexp
[08:09:19] bricker`LA: also, why isn't actionview on rubygems? I am so confused
[08:09:31] sevenseacat: its part of actionpack
[08:11:06] tagrudev: I wonder why it's private
[08:12:14] rvanlieshout: create a pull request and ask?
[08:12:59] tagrudev: gonna dig some more before doing that
[08:16:25] tagrudev: it's tied to the form makes sense
[08:18:14] teufelChiCoder: is there a way to specify which version of jquery rails loads?
[08:18:30] teufelChiCoder: right now it loads 1.10 - what if i wanna load 1.8.3?
[08:19:20] Macaveli: What's wrong with this : https://gist.github.com/YOUConsulting/0f899602e835a63d8660 it works separately status and sap_id but not together?
[08:20:20] sevenseacat: define 'nor working'
[08:20:55] Macaveli: it returns nil
[08:21:07] sevenseacat: it will never return nil
[08:21:17] sevenseacat: unless im mistaking what detect does
[08:21:28] Macaveli: it returns nil in rc
[08:21:51] sevenseacat: ah, just returns the first one
[08:22:07] sevenseacat: so need a bit more context, what is job.sap_id ?
[08:22:09] bricker`LA: oh, it seems rails master is in the middle of moving around action view or something
[08:22:22] bricker`LA: That's what was confusing me
[08:22:46] gwillen: does anybody here have advice on dealing with stale resque workers? I guess that's not exactly in scope.
[08:22:59] Macaveli: sevenseacat I'm a nub :p I'm querying for stage-f but the array states stage-n
[08:23:08] Macaveli: so It's me that's wrong :p
[08:23:08] sevenseacat: Macaveli: well we knew that tbh
[08:23:30] bricker`LA: gwillen: what do you mean stale?
[08:32:54] sjuxax: Have some questions about why Rails uses symbols so extensively. I'm newish to Rails but not to Ruby. A symbol is an immutable string. Why are arguments that are function names etc., passed in to Rails functions are symbols? Does Ruby really create a mutable string object if I pass in before_action test instead of before_action :test?
[08:33:31] sevenseacat: then later on you could modify the callback name and then your code would asplode
[09:14:15] tomoyuki28jp: To insert build db records in db/seeds, creating sql dump file is the fastest way, correct? Is there a built-in way to create a sql dump file?
[09:32:26] adac: does bundler support http auth?
[10:01:08] jarr0dsz: hey everyone i refactored my faye websocket private_pub stuff to rails 4 with SSE and redis push now only i need to find a way to have a private channel
[10:01:36] jarr0dsz: wondered if anyone already had attempted something like that, sending data to a certain source = new EventSource('/queue/events') that would be "private"
[10:02:07] jarr0dsz: i think of just appending the current_user.id to the Eventsource channel but not sure that would be solid enough
[10:02:44] mooru: rvanlieshout: Thanks for yesterday. I finally solved it
[10:03:51] rvanlieshout: mooru: happy to hear that
[10:04:32] mooru: rvanlieshout: It was pretty easy, just had to use the active record conditions
[10:06:03] bobbobbins: so i've been working on what seems like it should be a very easy problem for about a week now, trying various methods, but i can't seem to figure it out...all the code is here: https://gist.github.com/bobbobbins/9807888c2f0e9ba9595a
[10:06:39] bobbobbins: basically start_time and end_time need to display on the form in mm:ss format, but be stored in the db as an int of the number of seconds
[10:07:01] bobbobbins: so i tried whats there now, and the validation fails...
[10:15:18] bobbobbins: eh, its late, i'll ask again in the morning
[10:55:10] jrobeson: dear workmad3 .. do you happen to have any controller tests for your places you used reform that i could look at?
[10:55:32] workmad3: no, unfortunately the project I used reform on I no longer have access to :(
[10:55:49] workmad3: I also don't tend to do controller tests :)
[10:56:31] jrobeson: well.. what do you use instead of reform?
[10:56:37] jrobeson: the regular rails stuff? or your own form objects?
[10:56:53] jrobeson: i wish accepts_nested_attributes would die.. :(
[10:57:24] workmad3: I think you misunderstood... I have used reform, and I probably will again
[10:57:43] workmad3: but I've only used it on one project (the most recent rails stuff I did) and I don't have access to the code for that anymore
[10:58:09] workmad3: I also don't tend to write isolated controller tests, especially as I like to pare my controllers down to the bare minimum :)
[11:03:14] gcds: Is it possible to downlaod from other server and server to user but not like download from other server and then send to user but make that it streams transperently from other server ?
[11:06:44] jrobeson: it'd still be in effect the same thing
[11:06:52] jrobeson: except not saved in between on your server
[11:07:12] jrobeson: better to just link directly to the other server.. it'll be faster
[11:15:18] workmad3: gcds: !g proxy server
[11:18:17] bauruine: hide, is there a best practice about rails security from a sysadmin point of view?
[11:19:39] gcds: workmad3: I need to do it with browser not setting something
[11:22:02] bauruine: main concern is to reduce the impact of a hacked (eg. code injection) rails app to other hosted apps.
[11:51:20] codenapper: Say I have a model Group that has_many Users. How do I create a scope that gets me all Groups with less than 10 associated Users?
[11:54:50] rvanlieshout: codenapper: joins(:users).group("group.*").having("count(users.*) < 10")
[11:56:08] elaptics: codenapper: do you have a counter_cache on the user belongs_to? Then it's even simpler
[11:56:32] codenapper: nope, but it sound like i want to look into that
[11:57:08] rvanlieshout: that might even be better
[11:57:12] elaptics: it's worth looking at, then you can simply filter based on that column
[11:57:24] elaptics: Group.where("users_count < 10")
[12:04:32] codenapper: Perfect, works like a charm! Thanks, elaptics and rvanlieshout!
[12:10:03] solars: hey, anyone using simplecov and knows how to enable files in lib/**/* ? I'm using the 'rails' config but it doesnt work
[12:11:25] visof: schema file on db can i load it to postgres manually?
[12:11:37] visof: i mean without rake tasks?
[12:11:51] rvanlieshout: visof: manually convert it to sql and run that
[12:12:05] visof: rvanlieshout: how can i convert it to sql?
[12:12:29] workmad3: well, there's a config option to dump it out as SQL
[12:12:35] workmad3: rather than ruby
[12:12:42] visof: workmad3: how can i do this?
[12:13:04] workmad3: visof: !gg rails schema SQL
[12:13:21] elaptics: visof: change schema type to sql from ruby - it's in the config somewhere
[12:16:01] msimkins: visof: its in config/application.rb
[12:16:37] msimkins: visof: config.active_record.schema_format = :sql
[12:16:59] visof: msimkins: is it supporting postgresql?
[12:17:10] lxsameer: how can i override engine assets in my app ?
[12:17:27] rvanlieshout: lxsameer: try it
[12:17:34] msimkins: visof: Its fairly basic SQL, it should work fine
[12:17:50] lxsameer: rvanlieshout: i tried but i can't, i wonder if there is a way
[12:17:55] msimkins: visof: Why do you not want to use the rake tasks ?
[12:18:21] rvanlieshout: lxsameer: then start with explaining your problem
[12:18:33] elaptics: visof: the dump is done by your database adaptor so it's specific
[12:19:10] elaptics: the whole point is so that you can put db specific stuff into your migrations and have it set in your schema
[12:19:19] lxsameer: rvanlieshout: i have an engine which defines an emberjs source tree, i want to add a javascript file which can be injected in engine javascript files manifest
[12:19:40] rvanlieshout: lxsameer: that is something totally different
[12:20:00] lxsameer: rvanlieshout: so sorry for bad explanation
[12:20:31] rvanlieshout: lxsameer: why not load the gem js in your application.js and add yours to that?
[12:21:38] lxsameer: rvanlieshout: seems good, let me try it
[12:23:18] msimkins: elaptics: visof Sorry, I meant basic in the fact that if you are converting from ruby it will not have the (very) database specific things like create procedures/functions etc by default
[12:24:37] Kamuela: does rails g Users username:string email:string make any sense?
[12:27:06] rvanlieshout: Kamuela: wouldn't that be rails g User ... ?
[12:27:14] michael_mbp: rvanlieshout: is there anyway to handle arguments for initialize when it's be aliased via alias_method?
[12:27:26] rvanlieshout: michael_mbp: don't know
[12:27:35] michael_mbp: I'm doing this in 1.9.3 so no 2.00's prepend yet.
[12:27:52] Kamuela: rvanlieshout: rails g scaffold User username: string email:string ?
[12:28:21] rvanlieshout: Kamuela: read the documentation about generating scaffolded things
[12:29:31] Kamuela: rvanlieshout: i'm reading it right now. would that line make sense?
[12:29:51] rvanlieshout: Kamuela: it'll never make sense if you don't understand it
[12:30:24] Kamuela: rvanlieshout: and then if i had a complex CreditCard need, would i do that independently rails g scaffold CreditCard something:something , and that associate them within their code-bases?
[12:31:17] rvanlieshout: Kamuela: there is no right or wrong here.. you should be the one that knows how you want to organise your data
[12:31:22] msimkins: Kamuela: No it does not - you need to define what you are talking about - But your options at this point would be rails g model User.... or rails g scaffold User.......
[12:31:51] Kamuela: msimkins: Why doesn't the line make sense?
[12:32:14] msimkins: Kamuela: rails g User...... is invalid
[12:32:30] Kamuela: msimkins: oh yeah, the original line. i f'd that up lol
[12:33:23] msimkins: Kamuela: so - rails g model User.... will just generate the database table, rails g scaffold User.... will generate the model, controler, views, etc
[12:34:18] Kamuela: msimkins: so scaffold is MVC, model, controller, are individuals?
[12:34:29] msimkins: Kamuela: But the line you used will generate <something> called User with two fields username, and email, both accepting a text string up to 255 characters each
[12:34:58] Kamuela: msimkins: is there a built-in (ruby or rails) type for email?
[12:35:36] msimkins: Kamuela: Yes, models and controllers are seperate as are views, if you are quick starting (although the scaffolds are horrible), then use scaffold, but really you should write them yourself
[12:36:10] msimkins: Kamuela: Not as such, HTML5 has a form attribute for email, but the storage is a string - most databases have a limited number of datatypes
[12:37:01] Kamuela: msimkins: thank you, most people assume that everyone can learn from a book. and what's funny is that i have in the past, i'm just so drawn to rail because of how fast i see it being. i fully intend to get better at understanding all connections, but it would probably help to have it build, tweak, and see what that means for my final code
[12:38:28] Kamuela: msimkins: so do that validation in the view then, for the email <form type="email" validate>
[12:38:57] rvanlieshout: Kamuela: you should start with server side validation
[12:49:37] denym_: hey there, I have a scope from inherit ressource like this: `@libraries = LibraryPolicy::Scope.new( current_user, @user, end_of_association_chain.includes(library_elements: [:library, :article]) ).resolve.page(params[:page])`
[12:50:31] msimkins: Kamuela: I agree with rvanlieshout , you should probably do it server side first, and move it to the client side later
[12:50:41] denym_: if i want to random order would it work if I put @libaries.order('random()') in the neyt line?
[12:50:52] msimkins: Kamuela: look up validates_format_of in the rails documentation
[12:59:15] denym_: ok I put my question on SO http://stackoverflow.com/questions/19789540/randomize-inherited-resources-scope-result
[13:00:28] ecnalyr: I have a <%= f.fields_for :sub_models do |s| %> block that shows a text box form field for each of my model.sub_models. I only want to show this text box form field for the last of my :sub_models - how can I do this?
[13:02:42] ecnalyr: denym_ you ask if something will work in your question - why not try it and see if it works first?
[13:03:39] ecnalyr: denym_ your list.order('random()') should work
[13:05:43] denym_: actually I have no enviroment
[13:05:52] denym_: just some internet notebook :)
[13:07:04] denym_: ah no... I found something for it
[13:08:46] denym_: ecnalyr: mhm doenst work :( just used the @users=User.all; @users.order('random()') of a demo app
[13:09:24] denym_: still have: FROM "users" WHERE "users"."id" = 6 ORDER BY "users"."id" ASC LIMIT 1in the server console
[13:10:02] tbuehlmann: denym_, why do did you extend the Scope initializer by a third argument and wouldn't handle that in a method?
[13:10:10] tbuehlmann: asking out of curiosity
[13:10:13] ecnalyr: denym_ works for me in my app with that user line you gave
[13:10:52] ecnalyr: denym_ the sql that gets fired: User Load (7.1ms) SELECT "users".* FROM "users" ORDER BY random()
[13:11:42] denym_: mhm weird...
[13:12:55] IlyaLevin: Hey guys. Any help on this one will be hugely appreciated: http://stackoverflow.com/questions/19789802/
[13:15:17] denym_: damnit this is annoying, i hate it if even the simplest examples causing trouble
[13:16:29] denym_: And it works in the rails console, thats the weirdest
[13:18:27] denym_: ok I changed it to @users=User.all.order('random()') ... this works oO
[13:20:02] makerop: how do i iterate over a ActiveRecord::Associations::CollectionProxy
[13:21:07] makerop: there is an extra row being inserted upon rendering, and I cant figure out how to test for an empty
[13:21:15] makerop: .any? returns true, but there are no entries
[13:22:22] msimkins: makerop: .empty? or .size < 1
[13:23:08] makerop: .empty doesnt work though because there is always one
[13:23:29] makerop: .many? works though, but if there is one entry, it shows up as two lines when i loop through them to create a table
[13:23:44] elaptics: makerop: what's the actual problem you're trying to solve? Can we see your code?
[13:26:26] makerop: https://gist.github.com/makerops/7318990
[13:27:00] makerop: it's a pretty simple has_many belongs_to relation, I basically want to render a table with all the searches, in new
[13:27:36] makerop: but there is always 1 extra being added to the collection, I when I call @searches.each_with_index, it always loops through once
[13:27:48] Ergo: hey folks, what do you guys think about my new dashboard and angularjs based ui https://errormator.com/user/demo - lots of work was put into this
[13:27:49] makerop: if I create 1 search, it will loop through twice
[13:29:05] sevenseacat: Ergo: why does everything i click open a new tab
[13:29:39] Ergo: sevenseacat: your shift key might have stuck? ;-)
[13:29:48] Ergo: sevenseacat: and on a more serious note
[13:29:55] Ergo: what opens up in new tab?
[13:29:58] Ergo: that shouldnt happen
[13:30:02] sevenseacat: oh its just links to reports from the dashboard
[13:30:16] sevenseacat: only sometimes... odd
[13:30:39] Ergo: thats weird... the code is the same for every one of them...
[13:30:45] sevenseacat: any of the links to reports that are like Latest Report 1 2 3 4 5
[13:30:55] malusalexandru: https://gist.github.com/maimutza/5db251a05cff7126be76
[13:31:20] elaptics: makerop: well you're calling #build on searches in your new action so I guess that's the extra one you're getting
[13:31:21] Ergo: a yeah those were supposed to open in tabs
[13:31:29] sevenseacat: seems strange
[13:31:36] Ergo: people seem to like it better when exploring slow info
[13:32:01] Ergo: this behaviour might change though
[13:35:58] Ergo: sevenseacat: i might have some minor UI issues here and there - this is all fresh, but imo already tons better than what airbrake has
[13:36:54] sevenseacat: a steaming pile of horse shit is better than what airbrake has
[13:37:04] sevenseacat: your bar isnt set very high :P
[13:37:25] sevenseacat: seriously, airbrake is the worst and flakiest webapp i use, ever
[13:38:00] Ergo: sevenseacat: haha, yeah i actually believe its also better than sentry UI and featurewise ;-)
[13:38:02] juo: i love it
[13:38:03] Ergo: but thats different discussion
[13:39:06] Ergo: juo: you love airbrake?
[13:39:21] juo: for the most part
[13:39:26] juo: but I'm using a free open source version
[13:39:34] juo: because i cannot afford it for my personal projects
[13:39:39] juo: yeah, errbit
[13:39:50] juo: at work we use airbrake
[13:39:53] Cork: is there a clean way to handle localize for date columns that might be missing? (l(record.created_at) will crash if the columns isn't set yet)
[13:40:24] Ergo: juo: interesting
[13:40:25] sevenseacat: `l(record.created_at) if record.created_at` ;)
[13:40:35] rsl: Cork: l(record.created_at) if record.persisted?
[13:40:37] elaptics: Ergo: it looks pretty, will have to have a look. One question though, I'm not clear on the usage and pricing. i.e. what does 50Mb/month mean?
[13:40:55] rsl: Cork: or provide a default: l record.created_at || 'record not saved'
[13:41:04] elaptics: Ergo: i.e. what's a report that means I get 50,000 of them?
[13:41:11] msimkins: Ergo: Looks good, shame I cant use it for work though :(
[13:41:25] Ergo: elaptics: yeah, well the problem is i have more than single API
[13:41:32] Cork: rsl: oh, so l can take a string
[13:41:33] Ergo: so i cant count just reports
[13:41:39] Cork: rsl: that would work, thx
[13:41:40] Ergo: because you have logs, you have performance metrics
[13:41:53] Ergo: so i could this up and measure this
[13:41:54] rsl: Cork: yeah cause if created_at is nil it'd short-circuit to next value
[13:42:15] Ergo: elaptics: but yes - on average that means that you can get 50k reports for free
[13:42:16] Cork: rsl: no i meant l(nil||'string here')
[13:42:29] Ergo: some reports are smaller/bigger though
[13:42:35] Ergo: depends on app really
[13:42:38] rsl: Cork: exactly. that's standard ruby. without spaces. but standard.
[13:42:51] Ergo: some apps do lots of slow reports with query info, some send lots of logs
[13:42:57] Cork: rsl: ya, i just didn't know l accepted random strings
[13:43:20] Ergo: elaptics: basicly there is 2 week no string attached trial you can use to see how much your app sends to me
[13:43:25] rsl: Cork: oh it might be a symbol... dunno. i don't use localization much. but the CONCEPT is there... use || to provide a default
[13:43:25] Ergo: after that it becomes a free account
[13:43:27] sevenseacat: rsl: the second one won't work.... l('string here') will be some kind of error
[13:43:42] elaptics: Ergo: I presume the client middleware sends the data, etc out of band so it doesn't slow down the request/response cycle massively?
[13:44:03] rsl: again... i am showing you how to provide a default by using ||. whatever arguments that code needs is up to you to provide. i don't use it. just providing the concept.
[13:44:21] Ergo: elaptics: for rails you can reuse airbrake gem (im not a ruby dev :( )
[13:44:32] Cork: rsl: well if l doesn't accept it, || can't be used there
[13:44:40] rsl: it takes SOMETHING
[13:44:43] Ergo: elaptics: for python/js - the clients indeed send the data in separate threads, batchign them etc
[13:44:47] Ergo: batching
[13:44:49] rsl: if it's not a string, give it what it wants.
[13:45:05] elaptics: Ergo: ah I see, cool. I will maybe give you a try out
[13:45:12] rsl: it doesn't NOT reject using the || operator
[13:45:23] rsl: rather it doesn't reject using the || operator
[13:45:33] Cork: rsl: "Object must be a Date, DateTime or Time object" so no go there
[13:45:34] Ergo: elaptics: for example car.gr did 451.0k requests in last 30 min
[13:45:34] rsl: any method that takes a single value can use this concept
[13:45:46] Ergo: elaptics: there are no performance problems in python
[13:45:46] rsl: then give it what it expects as a default!
[13:45:55] sevenseacat: rsl: i think you're missing the point
[13:45:58] Ergo: i guess i could use a "proper" ruby client though :-)
[13:46:07] Technodrome: anyone here use rack deflator?
[13:46:35] sevenseacat: the right answer is, only try to localize the value if its present
[13:46:48] Technodrome: i wonder if it's better to use rack deflator, or to use gzip caching in nginx
[13:47:32] Cork: sevenseacat: ya, though the code can be quite wield if you need to do this for several fields
[13:47:35] rsl: what kind of localization only takes times?
[13:47:52] Cork: rsl: l vs t
[13:47:54] sevenseacat: Rails `l` method
[13:48:11] Cork: l=localize t=translate
[13:48:25] rsl: cool. srsly i never touch localization so i have zero idea. was purely trying to help how how to provide default value. ;)
[14:08:13] TorpedoSkyline: hey guys, just curious. I haven't fired up Rails yet, but does it make timestamps nullable? Why or why not?
[14:09:53] tbuehlmann: TorpedoSkyline, don't understand the question
[14:09:54] rvanlieshout: TorpedoSkyline: why should it make what timestamps null? or what do you mean by nullable?
[14:10:59] greengriminal: Is it possible to write the following as a scope. https://gist.github.com/anonymous/7319553#file-snippet-rb-L22-L24
[14:11:12] TorpedoSkyline: so when you're creating a migration you can use t.timestamps, or just create a column with a timestamp type. Let's say you wanted to create a date_due column but wanted that to be null
[14:11:29] rvanlieshout: greengriminal: .joins(:violations)
[14:11:32] rvanlieshout: that would be enough
[14:11:35] rvanlieshout: in your scope
[14:11:54] TorpedoSkyline: if in the case a task had no due date. I've been dealing with a badly written database that uses "0000-00-00 00:00:00" for no data/time.
[14:12:03] rvanlieshout: TorpedoSkyline: you don't have to have the timestamp columns
[14:12:11] rvanlieshout: and datetime columns can be nil
[14:12:41] tbuehlmann: yeah, rails' provided timestamps are not meant here
[14:12:44] codenapper: greengriminal scope :with_retailer, -> { where.not(retailer_id: nil) }
[14:12:44] rvanlieshout: greengriminal: cause an inner join requires the joined to be present
[14:13:05] TorpedoSkyline: rvanlieshout ok, thanks. I'm guessing by default though when Rails creates timestamps using the timestamps method they don't allow null
[14:13:14] TorpedoSkyline: tbuehlmann what do you mean?
[14:13:28] tbuehlmann: do you mean rails' created_at and updated_at columns?
[14:13:31] rvanlieshout: TorpedoSkyline: they allow nil and rails will only create them if you want them to be created
[14:13:39] rvanlieshout: you can even choose other names for the columns if preferred
[14:13:48] TorpedoSkyline: right, sounds good. thanks
[14:13:56] TorpedoSkyline: tbuehlmann yeah that's what I was talking about
[14:14:15] greengriminal: rvanlieshout: (y) Yes was just thinking how I could do that. But you cleared it up
[14:14:45] greengriminal: rvanlieshout: scope :retailer, -> { joins(:violations).where("retailer_id IS NOT NULL") }
[14:15:00] rvanlieshout: greengriminal: no need for the where
[14:15:42] rvanlieshout: greengriminal: only the joins will do :)
[14:16:19] greengriminal: rvanlieshout: You sure, so how would I check if retailer_id IS NOT NULL if i don't do the "where" clause
[14:16:34] rvanlieshout: greengriminal: you don't have to check that.. using an INNER JOINS implies that
[14:16:36] Technodrome: anyone here run a production app on a dual *processor* server?
[14:16:55] greengriminal: rvanlieshout: scope :retailer, -> { joins(:violations)} should be enough
[14:16:57] rvanlieshout: Technodrome: yes.. up to 24 cores for now
[14:17:01] rvanlieshout: greengriminal: exactly
[14:17:09] foucist: Technodrome: it doesn't really change anything, you run multiple processes anywas
[14:17:10] Technodrome: rvanlieshout: so its how many processors?
[14:17:17] rvanlieshout: Technodrome: 2 only
[14:17:22] Technodrome: how many cores each?
[14:17:23] tbuehlmann: if it's no has_many relationship I'd prefer the NOT NULL way, though. not sure what's the case here
[14:17:29] rvanlieshout: Technodrome: do your own math :) whyso?
[14:17:38] Technodrome: what kind of processor is it?
[14:17:46] Technodrome: does the 2nd processor help the rails app a lot?
[14:18:17] Technodrome: what app server are you using?
[14:18:31] rvanlieshout: but it'll only help your app if you created a decent app
[14:18:36] rvanlieshout: it won't help shitty code
[14:18:46] Technodrome: just trying to squeeze
[14:19:03] rvanlieshout: don't try to overadd hardware if there is no real problem yet
[14:19:04] Technodrome: with the older app servers multi processors i'm not sure helped so much
[14:19:18] Technodrome: but with ruby 2.1 with Puma , it could really utilize the entire system much more
[14:19:20] rvanlieshout: not even if you just run multiple instances?
[14:19:30] Technodrome: we do 400 request per sec, things are *ok* right now
[14:19:38] rvanlieshout: even rails 2 apps could use all of your system
[14:19:43] rvanlieshout: as can rails 1
[14:19:44] Technodrome: but since we have a dual processor unit coming, i just want to utilize it
[14:20:18] Technodrome: well from mongrel to puma we got a 2x increase, 150\-200 request a sec to 500
[14:21:23] FooBarWidget: you know that there is still a global interpreter lock in ruby, right?
[14:21:26] workmad3: Technodrome: if you're running on MRI, only one thread can be active at once (I don't think they're removing the GIL in 2.1 anyway), however it does use real threads and they aren't pinned to a processor so dual-processors do give you some advantage (namely that the thread can be scheduled on whichever processor has spare cycles)
[14:21:34] tbuehlmann: totally depends.. if you use MRI and puma single process, that's not clever
[14:21:36] FooBarWidget: so with 1 puma process and multiple threads, you can preempt on I/O, but it still uses 1 core
[14:21:54] TorpedoSkyline: so if you're doing any serious scaling should you not use MRI?
[14:21:55] FooBarWidget: not that that is necessarily a problem. if your app happens to be I/O bound then that works great
[14:22:01] FooBarWidget: if it's CPU-bound then not so much
[14:22:18] FooBarWidget: no. if you're doing serious scaling and you use MRI, you should use 1 process per core
[14:22:18] Technodrome: right now puma with 5 workers 16 threads has doubled performance
[14:22:27] FooBarWidget: MRI works fine with scaling to multiple CPUs. just use multiple processes
[14:22:40] FooBarWidget: I'm saying that *threads* in MRI don't use multiple CPUs. processes do
[14:22:40] Technodrome: isn't that what puma does?
[14:22:50] FooBarWidget: no. it'll only do that if you tell it to
[14:22:54] FooBarWidget: ditto with for example passenger
[14:22:59] FooBarWidget: or other app servers
[14:23:07] Technodrome: so to use all 8 cores i need 8 processes?
[14:23:07] FooBarWidget: if you tell them to use multiple processes, you get to utilize multiple cores
[14:23:23] workmad3: Technodrome: well, all 8 cores can be used by 1 process
[14:23:24] Technodrome: i've never done this
[14:23:25] TorpedoSkyline: ah so use processes. Now do servers like Unicorn handle that or do I need to be explicit in the code?
[14:23:25] workmad3: Technodrome: but only one at a time
[14:23:39] TorpedoSkyline: yeah, I can start multiple unicorn processes in the config so
[14:23:44] Technodrome: unicorn did much worse than puma for us TorpedoSkyline
[14:23:49] chendo: FooBarWidget, if i used jruby with passenger with a threadsafe app, will it use more than one core?
[14:23:50] workmad3: TorpedoSkyline: unicorn uses multiple processes
[14:23:54] chendo: per instance?
[14:24:01] TorpedoSkyline: Technodrome really? in what way?
[14:24:04] wmoxam: chendo: yes
[14:24:12] wmoxam: chendo: same with Rubinius
[14:24:14] Technodrome: do some research puma is the most amazing one speed wise
[14:24:21] chendo: is there an advantage to using torquebox then?
[14:24:24] workmad3: Technodrome: marketting bullshit ;)
[14:24:37] wmoxam: Technodrome: depends on the ruby interpreter
[14:24:37] TorpedoSkyline: Technodrome oh, this looks cool. I'll check it out
[14:24:38] workmad3: Technodrome: as already stated, a CPU-bound app on MRI won't get the same improvements
[14:25:04] Technodrome: i have no idea, unicorn gave 200 request per sec, i benchmarked the shit out of it so many ways
[14:25:07] workmad3: Technodrome: pick your app server based on your app characteristics
[14:25:08] Technodrome: puma with 5 workers does 500
[14:25:15] FooBarWidget: chendo: yes. threads in jruby use multiple cores
[14:25:20] FooBarWidget: threads in MRI *do not* use multiple cores
[14:25:27] Technodrome: and the server load has been cut by 40 percent over the past 1.5 days
[14:25:29] rvanlieshout: Technodrome: that's one lousy comparision
[14:25:30] FooBarWidget: multiple processes *always* use multiple cores whether it's MRI or JRuby or whatever
[14:25:42] Technodrome: rvanlieshout: all the benchmarks show the same thing
[14:25:48] chendo: FooBarWidget, was just making sure that passenger would serve more than one request at a time to a process if it's jruby
[14:25:57] rvanlieshout: Technodrome: you can benchmark all you want, but it has no value if you don't know what you're really benchmarking
[14:26:29] Technodrome: rvanlieshout: heroku recommends it as well to squeeze as much performance
[14:26:31] FooBarWidget: are you guys talking about the jrochkind benchmark?
[14:26:36] Technodrome: maybe its because it utilizes that C extension
[14:26:40] workmad3: Technodrome: one of my apps slowed to a crawl with puma in production
[14:26:41] rvanlieshout: Technodrome: heroku sucks balls
[14:27:10] rvanlieshout: Technodrome: if you want more speed you should know what is slowing things down
[14:27:11] Technodrome: I'm just explaining my experience so far, if it did worse i would say so
[14:27:17] FooBarWidget: chendo: for that, you will need to enable multithreading in passenger
[14:27:20] workmad3: Technodrome: great
[14:27:23] workmad3: Technodrome: but say it as your experience
[14:27:28] rvanlieshout: and that's not something like puma or unicorn without any reason
[14:27:29] workmad3: Technodrome: not 'puma is the best speed wise'
[14:27:32] Technodrome: my experience
[14:27:35] FooBarWidget: chendo: it performs one-request-per-process by default
[14:27:38] Technodrome: but workmad3 i'm not the only one saying this
[14:27:43] FooBarWidget: until you tell it otherwise
[14:27:43] workmad3: Technodrome: no, you're not
[14:27:44] chendo: FooBarWidget, how does passenger know how much requests to serve each process?
[14:27:52] workmad3: Technodrome: many apps do well with the puma style of threading
[14:27:55] chendo: concurrently etc
[14:27:55] workmad3: Technodrome: but many do not
[14:27:58] workmad3: Technodrome: know your stack
[14:27:58] FooBarWidget: chendo: it knows that by the settings you give it
[14:28:03] workmad3: Technodrome: and know your app
[14:28:03] rvanlieshout: chendo: it's described in the config
[14:28:12] FooBarWidget: chendo: the default settings says "1 request per process at at time"
[14:28:15] workmad3: Technodrome: don't rely on other people's benchmarks, your app is not the same as a benchmark
[14:28:18] rvanlieshout: chendo: by setting min, max things
[14:28:25] chendo: makes sense
[14:28:26] TorpedoSkyline: workmad3 so how can you tell which server is the best for your code? Just test each of them and benchmark them?
[14:28:37] workmad3: TorpedoSkyline: pretty much
[14:28:47] workmad3: TorpedoSkyline: you can make some educated guesses too
[14:28:49] rvanlieshout: TorpedoSkyline: and stop looking at 'the server' as one thing
[14:29:05] workmad3: TorpedoSkyline: based on where the heaviest load is in your code
[14:29:10] Technodrome: workmad3: i only benchmarked it myself , there is no DB slow down, everything is good there, no caching turned on, it was doing 250 per sec with mongrel, puma with 5 workers, got a quick 500 request per sec almost instantly , and i've been monitoring cpu usage heavily
[14:29:17] FooBarWidget: also, benchmark over the network, not locally
[14:29:19] Technodrome: workmad3: i could lie and say it's not true but it's what happened :P
[14:29:23] TorpedoSkyline: rvanlieshout what do you mean by that?
[14:29:25] rvanlieshout: find out if you have enough iops, cpu power and memory
[14:29:31] workmad3: Technodrome: yes, and that's fine
[14:29:31] rvanlieshout: and if you're using all of it
[14:29:37] FooBarWidget: performance differences between app servers do not matter, they're all similar to each other
[14:29:44] FooBarWidget: *how* they serve requests matters more
[14:29:47] FooBarWidget: i.e. the I/O model
[14:29:51] wmoxam: Technodrome: how many endpoints are you testing?
[14:29:55] Technodrome: puma uses that C parser ,
[14:29:58] wmoxam: FooBarWidget: +++
[14:30:00] workmad3: Technodrome: so does unicorn
[14:30:04] FooBarWidget: and that can be measured more properly over the network than locally
[14:30:11] TorpedoSkyline: so it sounds like if you're having performance issues, check your code and DB first and assume it's the server last
[14:30:24] FooBarWidget: TorpedoSkyline: yes
[14:30:31] FooBarWidget: there is only 1 exception
[14:30:35] workmad3: TorpedoSkyline: any performance issue, profile first
[14:30:38] Technodrome: workmad3: http://ylan.segal-family.com/blog/2013/05/20/unicorn-vs-puma-redux/
[14:30:38] Technodrome: i can't even find a benchmark where puma does worse than unicorn
[14:30:43] FooBarWidget: *if* you know that your code is I/O bound,
[14:30:54] FooBarWidget: e.g. it performs a lot of blocking I/O calls, such as HTTP requests to twitter APIs,
[14:31:04] FooBarWidget: then it is advantageous to use a multithreaded server
[14:31:10] workmad3: FooBarWidget: or an evented server
[14:31:11] Technodrome: 500 request per sec for this app on one server is not bad, we do 400 request per sec, we have another server to load balance + that new dual processor 12 cores each coming
[14:31:11] FooBarWidget: with lots of threads configured
[14:31:17] FooBarWidget: such as puma or passenger enterprise
[14:31:29] FooBarWidget: workmad3: well that only holds if your code is also evented
[14:31:30] rvanlieshout: so as workmad3 said, don't rely on other peoples benchmark
[14:31:32] workmad3: Technodrome: can you stop posting your results please
[14:31:33] FooBarWidget: which most code bases are not
[14:31:34] TorpedoSkyline: workmad3 yeah, and I've had database performance issues with indexing and such so that could be the source of long responses
[14:31:38] rvanlieshout: unless they've tested a similar thing as you're running
[14:31:42] TorpedoSkyline: who hasn't though ;P
[14:31:44] wmoxam: Technodrome: how many endpoints were you testing?
[14:31:45] workmad3: Technodrome: we don't give a crap about your results... they're good for you, fine
[14:31:56] wmoxam: Technodrome: like, 500 req/sec for the login page is useless
[14:32:18] rvanlieshout: wmoxam: not if you have a bounce rate above 90% :)
[14:32:18] wmoxam: as that would be cached anyways
[14:32:28] Technodrome: no its a page with 3 queries, but yeah , the fact is not what the page does, that's not relevant workmad3
[14:32:31] Technodrome: the fact the same thing got 250 before is the part that is
[14:32:32] wmoxam: rvanlieshout: they can hit the CDN then ;)
[14:32:38] workmad3: Technodrome: but you've already demonstrated that you're ignorant of exactly where your increases come from anyway
[14:32:49] workmad3: Technodrome: which makes your experience non-transferable
[14:32:54] Technodrome: workmad3: don't call me ignorant please
[14:32:57] wmoxam: Technodrome: so, one endpoint. How many does your app have?
[14:32:59] Technodrome: here we go, programmers get emotional
[14:33:09] workmad3: Technodrome: I'm not calling you ignorant in general
[14:33:19] workmad3: Technodrome: I said you don't know where your increases came from
[14:33:22] Technodrome: seriously, it's a freaking app server, people get attached to this shit like its a woman or something
[14:33:23] workmad3: Technodrome: so you're ignorant of that fact
[14:33:26] wmoxam: Technodrome: "There are lies, damned lies, and benchmarks"
[14:33:34] Technodrome: wmoxam: maybe so
[14:33:43] wmoxam: Technodrome: microbenchmarks are misleading
[14:33:56] JRizzle: and then there are blueberry pancakes :D
[14:34:01] wmoxam: Technodrome: FYI I run both puma and unicorn in production
[14:34:09] Technodrome: i'll swap out puma for webrick
[14:34:25] workmad3: Technodrome: I wouldn't bother
[14:34:28] wmoxam: Technodrome: micro optimizing your web server is pointless IMO
[14:34:28] Technodrome: i was just happy for the increase, thanks for the buzz kill
[14:34:36] workmad3: Technodrome: be happy
[14:34:53] workmad3: Technodrome: just don't assume that said increases will be gotten for everyone just by switching
[14:34:56] wmoxam: Technodrome: correctly configure etags, expiry headers and use a CDN and you'll be 1000X happier
[14:35:04] TorpedoSkyline: JRizzle yay blueberry pancakes =D
[14:35:07] workmad3: Technodrome: you're lucky, you have an app that fits puma well... not every app is :)
[14:35:27] FooBarWidget: workmad3 sums things up nicely
[14:35:40] Technodrome: i can't use a CDN , everything is on these services but it gets very good ping rates from the east and west coasts
[14:35:48] Technodrome: but i use a cdn for a few things , like JS and stuff
[14:36:04] workmad3: Technodrome: as I said, I've had an app where performance went through the floor by switching to a threaded server with 1 worker :(
[14:36:08] wmoxam: Technodrome: I can't parse that.
[14:36:11] workmad3: Technodrome: I've also had apps where a threaded server was great
[14:36:13] Technodrome: you know these servers cost like 200 bucks a month to colocate, the cloud hosting was costing 4k a month
[14:36:27] Technodrome: heroku *banks* on that
[14:36:34] Advocation: is there a way of automatically setting the maxlength of fields to their maximum set in the model?
[14:37:21] tagrudev: validates_length_of :foo, max: 100
[14:37:53] workmad3: tagrudev: I think Advocation is asking for a way to set the input field max automatically based off that validation ;)
[14:37:53] Technodrome: i always felt paying heroku 4k a month was a bit too much
[14:38:03] Advocation: workmad3: yeah, thats it
[14:38:05] helpa: Technodrome: Don't you mean http://lolroku.com/?
[14:38:05] workmad3: Technodrome: !heroku
[14:38:24] Technodrome: sign up for free!
[14:38:27] Advocation: rather than having to do :maxlength => 100 on each line..
[14:38:33] Technodrome: they'll just take all your money later
[14:38:40] workmad3: Technodrome: only if you let them ;)
[14:38:54] tagrudev: well then use client_side_validation gem
[14:39:15] Technodrome: i've never saw a hosting cost above 4 or 5k , and that one "what is my lyric" website was paying like 20k a month? that's insane
[14:39:15] elaptics: Advocation: it works if you use form objects using virtus and active model along with simple_form :)
[14:39:15] tagrudev: it's no longer maintained hmm
[14:39:43] Technodrome: they're literally just milking for every dime they can get for shared hosting
[14:39:43] TorpedoSkyline: why does Heroku suck?
[14:39:56] TorpedoSkyline: expensive, sheesh
[14:39:59] Advocation: elaptics: that's a good approach - do you have any documentation on that?
[14:40:13] workmad3: TorpedoSkyline: you mean apart from them being overpriced and providing massively limited services?
[14:40:28] workmad3: TorpedoSkyline: no reason at all then :P
[14:40:45] TorpedoSkyline: workmad3 what service are you using? I've been using linode and it's *ok*, not as performant as I'd like
[14:40:56] Technodrome: the company has the money , but jeesh 5k a month is just a ton for hosting
[14:41:06] workmad3: TorpedoSkyline: I'm building servers out on DO at the moment
[14:41:12] Technodrome: linode you get more for your money
[14:41:25] TorpedoSkyline: Don't use the NYC2 servers ;P
[14:41:43] workmad3: TorpedoSkyline: any reason?
[14:41:54] tagrudev: if we don't mind the credit card hack they rock :D
[14:41:56] Technodrome: you guys should just colocate , cheap as 80 a month these days
[14:42:13] Technodrome: buy a really good server for a few hundred dollars
[14:42:22] TorpedoSkyline: workmad3 I got one and they're going down for maintenance every couple days, the San Fran ones don't have an issue for some reason. see digitalocean status
[14:42:40] workmad3: TorpedoSkyline: hmm, not had an issue with the couple of servers I have on NYC2
[14:43:02] workmad3: TorpedoSkyline: although most of the ones I need up are going to end up in Amsterdam (fewer issues with EU data protection) :)
[14:43:04] TorpedoSkyline: workmad3 http://www.digitaloceanstatus.com, and yeah guess not. I saw it a lot because I was running an IRC bouncer on one
[14:44:02] elaptics: Advocation: not specifically, it's just an approach I've taken recently. Here's an example of the form objects themselves https://gist.github.com/andyh/09fcd3886975f97cf7b6
[14:44:19] Advocation: elaptics: great, thanks :)
[14:44:40] elaptics: Advocation: then I'm just using simple_form in the views to render these objects and it picks up the validations and sets the attributes appropriately
[14:45:28] elaptics: I might get around to writing about it one day though :)
[14:46:49] GeorgesLeYeti: I have a problem when i try to deploy my app with capistrano: https://gist.github.com/anonymous/76d93acca169854c9165
[14:47:52] GeorgesLeYeti: And the weird thing is that it's working when i manually do the asset:precompile on my server (with the exact same command as capistrano)
[14:48:10] pskrz: what's a good way to do a technology inventory at a web shop?
[14:50:04] pskrz: i want to do something like http://www.thoughtworks.com/radar , but the collection of information seems a little overwhelming
[14:50:09] Technodrome: workmad3: you're like my arch nemesis now
[14:55:41] workmad3: Technodrome: I'll make a note of that in /dev/null
[15:02:09] Technodrome: workmad3: you're not even a rails developer, you're a turbo gears 1.x developer in disguise mad at the world
[15:02:10] gnagno: hello all
[15:03:10] workmad3: Technodrome: oh drats! you've found me out! now I must go and change my name!
[15:03:11] gnagno: I am working on an application, on a specific request some before filter is blocking the request, I am working in a rspec, is there a way using pry to see which filters the request passed trough?
[15:03:20] workmad4: Technodrome: you'll never find me now!
[15:03:33] Technodrome: I used to be a turbo gears dev :P
[15:04:42] Technodrome: its a true shame how the framework turned out, but oh well
[15:06:20] derebos: universa1, ping
[15:09:49] sheeny: Hi all, is there a way to break out of an iframe when doing a redirect_to in a controller?
[15:10:08] sheeny: without posting some horrible javascript back to do it..
[15:10:43] workmad3: sheeny: there are headers that decent browsers respect nowadays that say a URL shouldn't be framed
[15:11:08] workmad3: sheeny: https://github.com/twitter/secureheaders may be a worthwhile thing to look at and play with ;)
[15:12:05] solars: hi, is there a gem to enable CORS in rails? (something like https://github.com/britg/sinatra-cross_origin)
[15:12:36] workmad3: solars: https://github.com/cyu/rack-cors
[15:13:07] sheeny: workmad3 so that would help with the issue? there is no way I can get around the iframe, as its used for payment and im just handling the postback
[15:13:14] solars: workmad3, thanks
[15:13:27] workmad3: sheeny: yes, it should
[15:13:59] workmad3: sheeny: the X-Frame headers get to the browser and interpreted as 'this site shouldn't be framed, lets load it on its own' afaik
[15:14:22] workmad3: sheeny: rather than relying on hacky javascript :)
[15:14:30] utdemir: Hi. Can you tell me how where can I translate "confirmation_token" in my application using devise?
[15:14:36] sheeny: workmad3: ah cool ta
[15:14:54] derebos: what may cause this error: java.lang.IllegalArgumentException: The archive is malformed and will be ignored: an entry contains an illegal path [WEB-INF/../] which was not expanded to
[15:15:06] derebos: i just packaged the war file as rpm and then install it i got this error
[15:15:07] workmad3: sheeny: there are some other useful headers in that gem too ;)
[15:15:13] derebos: and if i deploy war without rpm it's working okay
[15:15:20] sheeny: workmad3: ill take a look thanks
[15:15:24] derebos: i'm using warbler gem what may cause this error
[15:15:33] derebos: anyone can help
[15:19:38] allaire: is `cd /home/u/rails-project/ && bundle exec sidekiq -e production ...` the same a doing `/home/u/rails-project/bin/sidekiq -e production ...` ? I'm trying to fully understand binstubs vs cd + bundle exec
[15:25:52] voidbottle: hi guys i need a make recurcive validation for parent_id (that validates that parent_id is not exist in some of subordinates) i don't know how many subordinates can be. Only way to make this validation make recursive fuction?
[15:32:53] GeorgesLeYeti: I'm using this script: http://atevans.com/2012/11/07/precompile-assets-in-capistrano.html in order to precompile locally my application and then send it. But when i making cap deploy, first it works fine but then it makes the assets:precompile
[15:33:13] GeorgesLeYeti: How can i say to capistrano no to execute assets:precompile ?
[15:34:04] mlitwiniuk: GeorgesLeYeti: in deploy.rb "load 'deploy/assets' "
[15:34:30] makerops: how would you guys suggest I handle this; two models, Searches, and Order, I want to allow 1-5 searches per order, and when the "order" is filled up, be able to test for that
[15:34:47] makerops: the is created via a form
[15:35:03] makerops: the search*
[15:35:07] tubbo: makerops: validate that the searches.count is < 5
[15:35:28] makerops: how do I track the order between searches ?
[15:35:30] GeorgesLeYeti: mlitwiniuk: the deploy/assets is in my Capfile
[15:35:48] makerops: I'd rather avoid cookies
[15:37:28] tubbo: makerops: Order doesn't belong_to Search?
[15:37:32] elaptics: makerops: what do you mean by tracking the order between searches?
[15:37:41] tubbo: makerops: scratch that...reverse it :P
[15:37:53] tubbo: if Order has_many :searches, you can do what i suggested
[15:38:40] makerops: yes, search belongs to order, but basically I want 5 unique searches associated with 1 order
[15:38:56] elaptics: makerops: as tubbo says just validate it, if you're showing the search form via the orders as a nested route then you can easily control whether the user can create any more searches
[15:39:30] makerops: ok, I currently am not, and showing the search form via search, but that makes sense
[15:41:17] tubbo: makerops: well i feel like the uniqueness of the searches should be validated in Search, while Order handles validating the amount of searches that is tied to it
[15:41:49] makerops: ya, uniqueness of searches is validated in searches, I just wasnt sure how to validate the amount
[15:42:02] makerops: but i wasn't thinking right, and was rendering searches/new
[15:42:10] makerops: rather than order/new and putting the logic in there
[15:43:27] mlitwiniuk: GeorgesLeYeti: and when you delete task "upload assets" and reladed from provided link? I have no troubles with assets in both Rails 3.2 and 4.0, so you must have sth messed up. Maybe try updating capistrano, but to ver < 3.0
[16:14:39] lessless: what tool can perform dictionary attack on rails password in textfile?
[16:16:06] crankharder: what's rails got to do with that?
[16:20:36] greengriminal: For some reason when I run my spec test I get the following: https://gist.github.com/anonymous/7321605 I understand that the method include? is trying to be set on NilClass.
[16:21:47] elaptics: greengriminal: you're passing in nil to params by default
[16:21:55] elaptics: greengriminal: I think you want params = {}
[16:22:46] elaptics: greengriminal: or you want to return early with your else clause out of that method if params is nil
[16:25:04] greengriminal: elaptics: See my update
[16:28:06] elaptics: greengriminal: I think you want {} not [] if it's a rails params hash you're passing in
[16:28:49] greengriminal: elaptics: Did change it to use {}
[16:29:31] elaptics: greengriminal: you have just deleted your comment?
[16:30:29] greengriminal: elaptics: check now
[16:32:40] elaptics: greengriminal: are you just passing in a 'c' or an 'r'?
[16:33:04] elaptics: greengriminal: I'm sure that method could be cleaned up loads - what would an example param being passed in look like?
[16:33:43] greengriminal: elaptics: Literally I am just passing either 'c' or 'r'. But this is something being sent over from the front-end.
[16:33:56] greengriminal: I've tested this and will most likely refactor this shortly
[16:34:46] Kamuela: good afternoon, s2013
[16:35:31] elaptics: greengriminal: it would be better to pass something more descriptive or useful in to reduce some of those conditionals
[16:35:51] elaptics: greengriminal: that said, it can be simplified a bit as is
[16:37:54] s2013: good afternoon Kamuela
[16:38:43] Kamuela: s2013: saw your hostname and took a shot in the dark you were in nyc haha
[16:38:54] s2013: yes sir i am
[16:40:33] elaptics: greengriminal: added a comment to your gist to show it simplified with most of the conditionals removed
[16:40:58] greengriminal: elaptics: Will take a look now (y)
[16:40:59] elaptics: greengriminal: to my mind you can remove the final one if you just pass in something appropriate (and sanitized to only safe values)
[16:42:19] greengriminal: elaptics: Looks clean and that is a good idea
[16:46:03] platzhirsch: I want to do a redirect in the controller and only change one parameter, what's the shortest way for doing that? I don't want to rewrite controller, action, etc.
[16:47:45] workmad3: platzhirsch: you want to redirect to the same action but with a changed parameter?
[16:47:51] platzhirsch: workmad3: that's right
[16:47:53] workmad3: platzhirsch: why?
[16:48:12] platzhirsch: workmad3: because if a wrong parameter was chosen I want to fix this automatically
[16:48:28] platzhirsch: picking the latest correct parameter
[16:48:28] workmad3: platzhirsch: right... but you're in the correct action, you know what the parameter should be
[16:48:52] tubbo: yeah can't you just @my_param = params[:my_param] || 'the default value'
[16:48:53] workmad3: platzhirsch: so why go through an entire new request/response cycle? why not just adjust the param in memory
[16:49:01] platzhirsch: workmad3: ah ok, well it works if I just pick the right one, but them the URL does not display the one I took
[16:49:15] helpa: platzhirsch: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[16:49:15] tubbo: platzhirsch: !gist your controller & routes
[16:49:58] workmad3: platzhirsch: slightly annoying, but not a large issue ;)
[16:50:07] platzhirsch: tubbo: that is what I currently do :) and it works logic wise
[16:50:21] platzhirsch: I don't want to fix the URL in JavaScript
[16:50:38] workmad3: platzhirsch: I don't tend to worry about wrong URLs for URL hackers
[16:51:55] workmad3: platzhirsch: or are you saying that there's a way you can end up with bad URL params that need correcting through completely correct use of the UI?
[16:52:08] workmad3: platzhirsch: because if so, I'd look to fix *that*
[16:52:26] platzhirsch: workmad3: yes, that's a bit the case
[16:53:07] platzhirsch: you are right, I will look into that, that sounds a lot better
[16:53:41] bobbobbins: i've been working on what seems like it should be a very easy problem for about a week now, trying various methods, but i can't seem to figure it out...all the code is here: https://gist.github.com/bobbobbins/9807888c2f0e9ba9595a
[16:54:14] bobbobbins: start_time and end_time need to display on the form in mm:ss format, but be stored in the db as an int of the number of seconds, currently the validation fails...and i think its not saving to the db either(but i need to get past the validation to verify)
[16:55:10] bobbobbins: any help is greatly appreciated
[17:01:57] optimus55: anyone know a good gui tool for postgres on osx?
[17:02:12] optimus55: pgadmin 3 for some reason refuses to open/install
[17:02:14] jarr0dsz: www.navicat.com optimus55
[17:02:28] jarr0dsz: ah ok sequal pro perhaps
[17:02:29] optimus55: jarr0dsz: anything free/open source?
[17:03:47] optimus55: jarr0dsz: is sequel pro good for postgres as well?
[17:04:00] jarr0dsz: nope just checked its mysql only
[17:04:36] jarr0dsz: navicat.com there is navicat premium
[17:04:42] jarr0dsz: that supports postgresql also but not cheap
[17:04:56] pitzips: I'm using test unit. Is there a proper way to stub methods during an integration test?
[17:06:11] ndee: http://pastebin.com/wXuaSiTb <-- I have that in my application controller, and when I call my CompaniesController, which inherits the application controller, I dont redirected to the login form.
[17:06:40] ndee: oops, sorry
[17:07:00] ndee: https://gist.github.com/anonymous/59a4c1efa816a80783c1 <-- that is
[17:10:43] smathy: pitzips, a lot of people use stubbing libs like mocha
[17:13:13] BrazenBraden: Little question.. when generating a migration and you want to columns to reference the another table, the same table, can that be done with a t.belongs_to? or should I just make them integers and then specify the relationship in the model itself? https://gist.github.com/brazenbraden/c924a3a8836ba41cd56a
[17:13:53] pitzips: smathy: I currently use 'rr' for stubbing in my unit tests. Normally I don't need to, but finding a unique case where I must stub . My question is more so, is stubbing proper during integration tests vs unit tests? If proper, why can I not find any examples.
[17:14:48] workmad3: pitzips: there's one golden rule with mocking and stubbing - don't mock/stub the thing you're testing
[17:15:42] workmad3: pitzips: with most rails apps (and a lot of apps in general), once you're writing integration tests or component tests, the thing being tested becomes the entire system
[17:16:07] workmad3: pitzips: in large apps that may not be the case, and so it makes sense to mock out some subsystem or component not relevant to the current integration
[17:16:45] workmad3: pitzips: but mostly... no, you don't want to stub things out during integration tests :)
[17:17:46] pitzips: workmad3: understood completely. my unique case (which I may be approaching wrong in tests) is that I generate a fraud "score" for each user to determine if I should let the user purchase. I use Faker to generate that user info, which in turn affects the fraud "score" - I'd like to stub the #score method on user so that it's taking out of the equation.
[17:20:58] s2013: i still dont know what .touch does
[17:21:09] s2013: can someone explain when id use .touch?
[17:21:38] s2013: is it to update? i dont get it
[17:21:49] bricker`1A: s2013: it changes the updated_at timestamp to now
[17:23:31] kevdev: Afternoon everyone
[17:23:37] s2013: oh. but why would you use it if you arent updating anything
[17:24:18] gwillen: s2013: one reason is if you're updating a value, and you might or might not be setting it to the same value it already has, but you want the timestamp updated anyway
[17:24:29] gwillen: s2013: if you don't use .touch, I believe rails will not update the timestamp if you set a value to the same value
[17:24:48] s2013: i thought rails updated timestamps automatically
[17:24:52] rhizome: because you're sorting by time based on activity in associated models
[17:25:12] msimkins: s2013: only if it actually updates :)
[17:25:15] kevdev: Not too sure what's going on, I've checked everything I can possibly think of, and been googling for 2 days straight =( I have an activerecord object, and whenever I try to display one of its attributes I get wrong number of arguments 0 for 1....but it displays the object itself just fine...anyone have a clue why it would be doing that? Rails 3.2 Ruby 1.9.3
[17:25:40] s2013: kevdev, paste your code at gist.github.com
[17:26:25] pitzips: s2013: it's also not only for updated_at... let's say a user updates their name, and you have a field that is 'name_updated_at'
[17:26:55] BrazenBraden: so about that migration "belonging to" the same table many times?
[17:27:28] s2013: ok got it
[17:28:04] kevdev: https://gist.github.com/anonymous/7322780
[17:28:47] zelrik: kevdev, do you have a method called .from in your model?
[17:28:50] smathy: pitzips, if I write integration tests (which I don't do very often), I will often stub out any interaction with an external system, like a payment gateway, or email.
[17:29:17] kevdev: I don't have a method no, but shouldnt I be able to grab that attribute by just using the object variable?
[17:29:34] zelrik: I wonder if there is a default method called from
[17:29:37] smathy: pitzips, I'd see nothing wrong with stubbing out your score method to control the flow through your app.
[17:29:41] zelrik: I dont think there is but..
[17:29:44] kevdev: hmmmm I never thought of that
[17:29:52] zelrik: try @filter['from']
[17:29:53] pitzips: smathy: ok, right on - thanks!
[17:29:59] kevdev: I guess I could have defined that method
[17:30:02] kevdev: and see if it works
[17:30:04] kevdev: lemme try that out
[17:30:11] kevdev: cant believe I didnt think of that -,- ty lol
[17:30:29] zelrik: kevdev, hey
[17:30:35] zelrik: @filter is a collection
[17:30:45] zelrik: you forgot a .first
[17:30:53] kevdev: wowwwwwwwwwwwww
[17:30:54] zelrik: or whatever
[17:31:11] kevdev: if I beat my head on a problem for too long I overlook the easiest possible answers
[17:31:22] zelrik: it s a shallow bug
[17:31:37] zelrik: you should always think about easy mistakes first
[17:31:56] kevdev: Nailed it
[17:32:12] kevdev: sighhhh, sorry to waste your time on something so simple lol
[17:32:18] kevdev: Much appreciated though
[17:33:25] zelrik: I was recommended to use find or find_by_id
[17:33:27] zelrik: instead of where
[17:33:32] zelrik: not sure what s the best
[17:33:48] kevdev: I wasnt sure if you could use a range using find
[17:33:57] zelrik: I like where because the lack of record doesnt break things
[17:34:07] kevdev: Yeah thats why I use it
[17:34:20] smathy: find_by_id is the same
[17:34:33] smathy: ...doesn't raise an exception if the record doesn't exist.
[17:34:47] zelrik: I know I dont use find
[17:34:55] zelrik: because it s breaks too easily
[17:35:34] kevdev: You have to admit though, the functionality has CERTAINLY improved over the years
[17:35:59] smathy: Some people advice find_by_id over where because you get a single object back, instead of a collection that you then need to do a .first on.
[17:36:21] zelrik: smathy, yeah that might avoid bugs like the one kevdev just had
[17:37:19] kevdev: smathy, right, my key unfortunately isnt an ID however
[17:37:36] kevdev: and im searching using between
[17:37:38] zelrik: I dont use debug generally
[17:37:50] zelrik: I make a custom debugger
[17:37:58] smathy: kevdev, yeah, I was just commenting on zelrik's comment about what people have recommended to him.
[17:38:02] s2013: what would the ideal way of creating automated reporting tool
[17:38:05] kevdev: Ahh, gotcha
[17:38:07] s2013: would you create a model called report or something
[17:38:15] s2013: like im looking at the best practices
[17:38:30] s2013: thing is user can set which unit they want to get report on for example
[17:38:45] kevdev: s2013 thats a pretty broad question lol
[17:38:58] smathy: s2013, you mean for things like audit tracking of changes?
[17:38:58] kevdev: Do you want reports to be displayed on screen? PDF?
[17:39:07] s2013: basically emailing reports
[17:39:18] s2013: we are already creating the reports in pdf, so thats not an issue
[17:39:32] smathy: s2013, so you're asking how to send an email?
[17:39:33] kevdev: you just want like a cron job to email out the reports on creation?
[17:39:33] zelrik: I guess you want a report class
[17:39:41] s2013: no smathy
[17:39:44] zelrik: well a model
[17:39:57] zelrik: and then create a mailer associated with it
[17:40:06] s2013: zelrik, ok so a model called report that belongs to the unit?
[17:40:10] kevdev: yeah, that was going to be my suggestion to you as well
[17:40:18] s2013: yeah thats what i was thinking as well
[17:40:41] s2013: so the report would belong to a unit and it would have users who subbed to it
[17:41:03] s2013: and then daily run through the entire list and send that releveant pdf to the user
[17:56:03] brendan6: Does anybody ever run into the issue where Unicorn *sometimes* doesn't restart with a sig USR2? Most of the time it restarts fine but every now and then I'll do a deploy and notice the process is not restarting (verifying with a ps aux | grep unicorn) and not noticing the (old) show up. Even manually running `sudo service unicorn_application restart` will not restart.
[17:56:45] FooBarWidget: brendan6: that's what you get with signals. they're inherently racy and brittle
[17:57:02] fbernier: how do I disable config.threadsafe! in rails4 ?
[17:57:11] FooBarWidget: you should send the signal, run some commands to check whether it worked, and retry if it didn't
[17:57:51] FooBarWidget: alternatively you could use something like passenger. its mechanisms don't rely so much on unix signals
[17:57:51] brendan6: FooBarWidget: I've tried doing a `kill -s USR2 <pid>` and it still wont restart. Only stop+start gets it to pick up code changes
[17:57:59] FooBarWidget: and it handles the corner cases for you
[17:58:42] brendan6: FooBarWidget: Might give passenger a try not that 4x is out, also considering switching to puma
[17:58:54] toretore: brendan6: there's a magic signal that will make unicorn restart every time
[17:59:49] brendan6: must be sig RAINBOW
[18:00:28] toretore: always works for me
[18:00:48] brendan6: toretore: yes, stop + start. Not crazy how I get "Something went wrong" pages though
[18:01:24] toretore: but it's so fast and reliable
[18:06:38] lethjakman: has anyone had the problem of rspec breaking your tests?
[18:06:44] lethjakman: er sorry, guard.
[18:06:50] lethjakman: it works outside of guard but not inside of guard.
[18:06:52] lethjakman: and I've stopped spring
[18:07:39] lethjakman: actually....rspec is breaking if I run it on every file....but not individual files.
[18:11:11] brendan6: lethjakman: Try commenting out the line require 'rspec/autorun' at the top of your spec_helper and restart guard
[18:12:04] brendan6: toretore: I think the solution is to use SIGHUP, ignore zero downtime since its buggy and cause a little delay for some users right after deployment
[18:15:37] toretore: brendan6: that's what i do.. or SIGTERM i guess it is
[18:15:44] toretore: whatever upstart sends
[18:16:07] toretore: it's usually less than a second
[18:18:23] tubbo: ^ i think it's SIGINT
[18:18:33] AlwaysBCoding: how can I query through active record to find if one attribute OR another attribute is nil???
[18:18:36] tubbo: toretore / brendan6 - http://unicorn.bogomips.org/SIGNALS.html
[18:18:39] tubbo: ^^ bookmarkable :D
[18:18:51] tubbo: so HUP will restart, INT will gracefully shutdown
[18:18:53] AlwaysBCoding: example NbaMatchup.where(home_team_id: nil) OR (away_team_id: nil)
[18:19:08] tubbo: oh wow WINCH is kinda cool
[18:19:16] tubbo: kills all workers but keeps master runnning
[18:19:45] brendan6: tubbo: Yea I've gone through that before. Problem was with USR2 and zero-downtime not ALWAYS (usually but not always) restarting
[18:21:19] tubbo: brendan6: well from reading the docs i'd say you're using the wrong signal. should be HUP with preload_app: false.
[18:21:25] tubbo: brendan6: usually worked for me when i used unicorn.
[18:21:37] brendan6: tubbo: I've been using USR2 with preload_app true
[18:21:55] brendan6: tubbo: https://gist.github.com/HuffMoody/7323188
[18:22:02] tubbo: brendan6: well from what i read in SIGNALS.html on the unicorn docs, that would not be the correct way to go...
[18:25:00] lethjakman: brendan6: that helped...what did that do?
[18:25:03] toretore: "The signal specified by the kill signal stanza is sent to the process group of the main process. (such that all processes belonging to the jobs main process are killed). By default this signal is SIGTERM."
[18:25:26] toretore: the proper way to gracefully restart unicorn is USR2 - WINCH - QUIT
[18:26:59] toretore: QUIT is the graceful shutdown signal
[18:27:08] bennyzr: anybody use authlogic?
[18:27:13] helpa: How to ask good questions and get great answers: http://www.mikeash.com/getting_answers.html
[18:27:17] spygame: hey guys, do you guys prefer using turbolinks or do you think they are useful? any drawbacks or cons if i use them ?
[18:27:22] helpa: Nope. No one. Ever. In the history of the world.
[18:27:22] lethjakman: bennyzr: I scrapped it and used my own
[18:27:40] toretore: one of those
[18:27:41] brendan6: lethjakman: http://stackoverflow.com/questions/18391211/whats-rspec-autorun-for Guard doesn't need it because it does that already
[18:27:46] elaptics: toretore: that's not true, DHH thinks it's useful
[18:27:57] toretore: spygame: what benefits do they provide?
[18:28:03] elaptics: everyone else, not so much
[18:28:05] bricker: spygame: A lot of your javascript will break. Google Analytics doesn't work out of the box (last time I checked, which was a while ago).
[18:28:45] bennyzr: lethjakman: having trouble with rails 4.01. any clues on how to use my own?
[18:29:02] helpa: bennyzr: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[18:29:02] toretore: bennyzr: !gist your code
[18:29:23] spygame: bricker, is that the usual case ?
[18:29:59] toretore: spygame: if you don't understand what turbolinks does and how to make your js work with it, you shouldn't be using it
[18:30:02] spygame: toretore, reducing your javascript code and still updating page contents asynchronously
[18:30:23] toretore: it's not asynchronous
[18:30:27] khuutantai: can someone please help me solve this case , it may sound stupid but im new to ruby , the gem dependency state that it need rails (~>3.0.0) , i have rails 4.0.0 but bundle still can not resolve dependency
[18:30:41] toretore: it just loads the page and inserts it into the body
[18:30:49] brendan6: khuutantai: which gem?
[18:30:54] bennyzr: toretore: helpa: code is not necessary. It doesn't work on a brand new project. All controller tests error with NameError: undefined local variable or method `activate_authlogic' for ...
[18:31:05] toretore: CODE IS NECESSARY
[18:31:06] khuutantai: spree-blogging-spree
[18:31:15] toretore: YOU MUST GIVE US CODE
[18:31:29] khuutantai: https://github.com/stefansenk/spree-blogging-spree it's on github
[18:31:46] tbuehlmann: khuutantai, ~>3.0.0 means >=3.0.0 and < 3.1
[18:32:05] tbuehlmann: so 4.0.0 won't do
[18:32:20] spygame: toretore, so pushState is not asynchronous as well ?
[18:32:34] khuutantai: just checked on bundle page
[18:32:40] khuutantai: sorry for that stupid question :(
[18:32:50] drocsid: Is there an 'interactive shell' for ruby on rails. For example I have my app built already and I want to create another instance of a class and call a method, can I do this?
[18:33:01] brendan6: spygame: pushState simply changes the history, has nothing to do with async javascript execution
[18:33:02] khuutantai: rails console
[18:33:05] tbuehlmann: no problem, it wasn't stupid at all
[18:33:14] drocsid: khuutantai: rails console
[18:33:40] brendan6: spygame: Don't use it, it will make your life easier
[18:33:51] brendan6: spygame: referring to turbolinks
[18:34:04] khuutantai: first contribution yay!!!
[18:34:23] bennyzr: here you go: https://gist.github.com/bmsolutions/06dfc847dc6425cace65
[18:34:33] toretore: tbuehlmann, khuutantai: ~> 3.0.0 means between 3.0.0 and 3.1.0
[18:35:07] toretore: spygame: here's a tip to save you from lots of frustration: don't use turbolinks
[18:35:30] khuutantai: thanks toretore
[18:35:58] spygame: toretore, thanks man, appreciate it
[18:36:00] lethjakman: bennyzr: has_secure_password
[18:36:05] rhizome: bennyzr: authlogic doesn't work on a new rails 4 project?
[18:36:13] tbuehlmann: toretore, as I said, it's >= 3.0.0 and < 3.1, not <= 3.1
[18:36:19] lethjakman: bennyzr: you just need a password_digest field in the database
[18:36:43] bennyzr: lethjakman: oh!
[18:36:54] toretore: tbuehlmann: oh, sorry, thought you said < 4
[18:37:06] rhizome: bennyzr: then again, the first line here: https://github.com/binarylogic/authlogic
[18:37:22] elaptics: bennyzr: according to the repo arylogic/authlogic it doesn't mention it working with rails 4
[18:37:37] elaptics: bennyzr: oops broken link, see rhizome :)
[18:38:03] rhizome: rtfm, in other words
[18:38:34] elaptics: and see the huge number of open issues, several of which refer to rails 4
[18:38:41] EminenceHC: I am trying to change an instance variable to a string using @ivar.collect{|x| "#{x}"} It seems like I can only do it in the view. How come I can't do @ivar.collect{|x| "#{x}"} = @something
[18:38:48] rhizome: "ohhhhhhh"
[18:39:03] optimus55: I'm tring to debug a new account creation in rails but i'm new. How to i halt execution in the controller and dump the contents of a variable? logger.info doesnt' seem to give me output anywhere :(
[18:39:08] rhizome: EminenceHC: huh?
[18:39:16] bennyzr: <elaptics: you're right. I didn't notice that.
[18:39:25] rhizome: s/notice/read/
[18:39:32] EminenceHC: rhizome: I forgot to say the instance variable is an array
[18:39:47] toretore: bennyzr: here's how to write your own authentication: https://gist.github.com/toretore/954909
[18:40:00] elaptics: EminenceHC: you want everything in the array to become a string?
[18:40:16] EminenceHC: elaptics: yes
[18:40:19] toretore: EminenceHC: real code in gist
[18:40:26] rhizome: EminenceHC: join
[18:40:26] EminenceHC: toretore: ok
[18:40:30] elaptics: EminenceHC: array.map(&:to_s)
[18:41:11] elaptics: rhizome: not pretty but gets the job done :)
[18:41:37] elaptics: and that's all you're going to get without us seeing some real code
[18:41:42] bennyzr: toretore: wow! thanks. Now I need to digest that.
[18:42:06] toretore: bennyzr: note: "Don't simply copy and paste this without understanding everything it does. It's
[18:42:06] toretore: a starting point and proof of concept more than anything else."
[18:42:37] toretore: but it's simple enough that everyone can and should understand how it works
[18:42:58] bennyzr: toretore: got it.
[18:44:06] EminenceHC: Here we go https://gist.github.com/EminenceHC/7323916 my ultimate goal is to be able to compare @correct array and @actual array and find the common values.
[18:45:02] rhizome: EminenceHC: textbook xy problem
[18:45:21] BrazenBraden: darn xchat takes too long to register my nick so my auto-join channel doesnt work :/
[18:45:24] rhizome: ary1 & ary2
[18:45:29] rhizome: EminenceHC: ^^
[18:45:39] optimus55: does anyone have an idea to halt execution and show the contents of a variable at that time?
[18:45:50] optimus55: I'm trying to debug ad controller and not having much success
[18:45:52] EminenceHC: rhizome: what do you mean?
[18:45:52] rhizome: optimus55: use pry
[18:45:56] BrazenBraden: optimus55: look at the 'debugger' gem
[18:46:22] rhizome: EminenceHC: i mean http://ruby-doc.org/core-2.0.0/Array.html#method-i-26
[18:46:49] toretore: optimus55: logger.debug something
[18:47:18] tbuehlmann: or raise something
[18:47:21] rhizome: i don't even know what that gist is about
[18:47:52] elaptics: EminenceHC: what is it, that this is doing/supposed to do?
[18:48:10] toretore: usually, code makes the intention much clearer
[18:48:18] toretore: but not in this case :)
[18:48:24] jarr0dsz: hi guys anyone uses rails 4 live _ SSE?
[18:48:37] optimus55: BrazenBraden: thanks installing now. does it only output to the development log or server terminal?
[18:48:38] EminenceHC: It is for a quiz. Array of correct answers being compared to the actual answers someone has in their result set.
[18:48:46] jarr0dsz: im trying for some time now to get it to publish to a certain user only like source = new EventSource('/queue/' + gon.user_id); but that failed
[18:48:49] BrazenBraden: optimus55: <script>alert(msg);</script>
[18:49:04] jarr0dsz: anyone has implemented SSE with private eventsource?
[18:49:32] toretore: jarr0dsz: each sse connection it "private"
[18:49:34] BrazenBraden: optimus55: lol no idea. i just see it always included by default when I create a new project.. I watched a tutorial on it.. seems to be terminal based.
[18:49:37] rhizome: EminenceHC: you mean like multiple choice?
[18:49:47] EminenceHC: rhizome: yes, exactly
[18:49:49] BrazenBraden: optimus55: there is either railscast or peepcode cast on it
[18:50:12] jarr0dsz: i have done like so https://gist.github.com/anonymous/d6a8a32e0868798decaf then send message to /queue/1 but this seems to fail
[18:50:22] jarr0dsz: toretore i mean send data on a per user base
[18:50:50] rhizome: EminenceHC: have the form submit ids of answers
[18:51:00] jarr0dsz: i just redis to push to the channel so i push to /queue/2 for user 2 /queue/1 for user 1 still it seems it just sends data across all /queue/* eventsources
[18:51:11] toretore: jarr0dsz: then you must know in the controller the id of the user who's connected
[18:51:38] rhizome: @quiz.answers.where(:id => array_of_answer_ids).count # == number of correct answers
[18:51:39] toretore: i don't really know how rails 4's sse implementation works
[18:51:41] EminenceHC: rhizome: The form is submitting the answers into a serialized hash. I have converted that to an array to try and compare it to the array of the actual test's answers.
[18:51:41] elaptics: EminenceHC: all of this logic shouldn't be in the controller, you should deal with it in the model
[18:51:51] rhizome: EminenceHC: well, stop it.
[18:52:13] jarr0dsz: toretore since the checks are done in javascript that would not be good enough any user could change the ID + each user will recieve all the app data on that eventsource
[18:52:17] elaptics: EminenceHC: it's really hard to follow what is going on with all the various variable names, etc and seemingly pointless instance variables and local variables
[18:52:31] toretore: jarr0dsz: hence why i said "in the controller"
[18:53:10] toretore: EminenceHC: how do you compare an answer to the correct one?
[18:53:17] mjc_: anyone going to rubyconf?
[18:53:39] BrazenBraden: can someone /msg me quick.. wanna see if xchat throws up a notification :)
[18:53:57] EminenceHC: toretore: The test has a correct answer param. So I am grabbing all answers where :correct == true
[18:54:23] Guest83494: How can I create a postgre database?
[18:54:30] BrazenBraden: great.. pms work.. now, can someone please throw my name into chat randomly so it is "highlighted"?
[18:54:34] toretore: what is in the "correct answer param"?
[18:54:47] EminenceHC: toretore: its a boolean, true or false
[18:54:58] Guest83494: Right when running rake db:create:all
[18:55:00] toretore: how is it determined whether it's true or false?
[18:55:04] agent_white: Guest83494: https://www.digitalocean.com/community/articles/how-to-setup-ruby-on-rails-with-postgres
[18:55:07] Guest83494: I get an error that validation keeps failing
[18:55:21] EminenceHC: toretore: the person who creates the test checks it next to the answer
[18:55:34] toretore: so it's manual?
[18:55:45] toretore: done by a person?
[18:56:19] EminenceHC: toretore: The person who creates the test sets all that. Then the student takes it and it gets logged to the result set. Where their answers are stored in a serialized hash.
[18:57:03] toretore: jarr0dsz: presumably you have authentication in your app, and your sse connection is also authenticated in the same way. thus you can check inside the controller which user the message is intended for and only write it to the stream if it matches currenct_user or whatever
[18:57:08] elaptics: BrazenBraden: like this?
[18:57:19] BrazenBraden: elaptics: perfect, thanks
[18:57:35] toretore: EminenceHC: i still have absolutely no idea how all of this is supposed to work
[18:57:55] jarr0dsz: toretore it seems i need to use source.addEventListener('1', function(e) { the addEventListener and set that to the specific user i guess
[18:58:03] jarr0dsz: already have the rest in place final issue ;p
[18:58:04] toretore: EminenceHC: you have to explain better, with a gist
[18:58:24] Guest83494: agent_white: Thanks for the link
[18:58:27] Guest83494: su - postgres
[18:58:32] Guest83494: that requires a password
[18:58:38] Guest83494: which password would this be?
[18:58:42] Guest83494: I've just installed postgres
[18:58:42] agent_white: Guest83494: That would be -your- password.
[18:58:45] toretore: jarr0dsz: no, that's client side filtering
[18:58:47] agent_white: If you are authorized for sudo
[18:58:54] Guest83494: noob question
[18:59:02] agent_white: Guest83494: sudo su -
[18:59:09] agent_white: Otherwise, it's the root pw :)
[18:59:41] agent_white: I would also highly recommend poking through https://wiki.archlinux.org/index.php/PostgreSQL :)
[18:59:47] jarr0dsz: toretore ah got it , the events method in controller, your right
[19:00:19] jarr0dsz: on postgresql, would it a lot of work to upgrade from mysql to postgresql?
[19:00:48] smathy: "upgrade" :)
[19:00:48] jarr0dsz: i still have it on my todo but don't feel like spending several hours on it, i have almost all regular AR to get my data only a few hard sql join statements
[19:00:52] agent_white: You mean in Rails? Just change the adapte!
[19:01:00] jarr0dsz: well its is an upgrade since its much more refined ;p
[19:01:13] toretore: jarr0dsz: presumably rails will create a controller instance for each connection in which you will have access to the session and thus the current_user. in this way the controller instance will know which user is connected to it and whether or not it should receive the message
[19:01:27] smathy: jarr0dsz, not hard at all as long as you're not using any of the MySQL extensions in MyISAM (which if you are, you're dead to me anyway).
[19:01:44] toretore: jarr0dsz: why are you "upgrading"?
[19:02:41] jarr0dsz: toretore plan to use geocoding lateron from postgresql
[19:03:33] toretore: ok, that's a sorta valid reason
[19:05:02] smathy: functional indexes are also nice
[19:05:16] smathy: ...much better than extraneous columns and triggers.
[19:05:28] Guest83494: agent_white Awesome, that second link's really good :)
[19:06:29] agent_white: Guest83494: Good to hear :) I use that Arch wiki for _everything_ Linux related, damned near :)
[19:07:10] jarr0dsz: ok lets just try it ;) changing to postgres
[19:07:35] agent_white: Just remember to re-create your user and privilidges... (!)
[19:10:13] Guest83494: agent_white: Argh, thought I'd cracked this
[19:10:37] Guest83494: created a superuser, edited the db YAML, but when running rake db:setup
[19:10:44] Guest83494: FATAL: Peer authentication failed for user "postgresql"
[19:10:54] agent_white: Have you created the postgresql user?
[19:10:55] Guest83494: but my username in my YAML is 'root' so what's going on?
[19:11:00] agent_white: Change it there!
[19:11:11] Guest83494: in the YAML?
[19:11:13] agent_white: Change the username in the YAML to match the db user that you will login with.
[19:11:36] nettoweb: guys, whats the problem with this method: https://gist.github.com/osnysantos/797cb284668998be2624 I'm using console to test, but get this: NameError: undefined local variable or method `session' for #<Class:0x105f659b8>
[19:11:40] Guest83494: okay, but I changed it root, or so I thought
[19:11:44] agent_white: Yep, in config/database.tyml
[19:12:17] agent_white: Guest83494: You won't want it to be root! Basically, you want to make the postgresql user and set the password, and enter that same UN/PW into the YAML :)
[19:12:28] melvinram: Is there a way to get the current time without the minutes? I could use the info in the Time.now to create a new Time object using just hour but it seems like would be a faster, cleaner way to do this.
[19:13:29] gerep: Hi all. I'm updating from Rails 3.1.10 to 3.2.0. The application has a lib/nested_changes.rb (https://gist.github.com/gerep/7324348) to check if an object was changed, is it still required to have this library?
[19:14:34] Guest83494: agent_white: I do get that..not sure what's going wrong..I'll create another user :)
[19:15:13] Guest83494: agent_white: Right, here's something that's weird
[19:15:19] Guest83494: su - postgres
[19:15:22] Guest83494: my password fails authentication
[19:15:29] Guest83494: my sudo password
[19:15:32] Guest83494: what#s going on there?
[19:15:36] Guest83494: I swear it's the right one
[19:16:10] agent_white: Guest83494: That was my bad, I said it wrong. "su -" will give you a root shell, and the pw it asks for is the root password.
[19:16:27] agent_white: Instead, use "sudo su", then "su postgresql"
[19:16:33] agent_white: That will make you the postgresql user :)
[19:17:09] Guest83494: right! Okay, I am now a postgresql user yay
[19:18:01] Guest83494: but as a postgresql user, this happens:
[19:18:09] Guest83494: postgres@ubuntu:~$ create role myapp with createdb login password 'password1'
[19:18:13] Guest83494: No command 'create' found, did you mean: Command 'mcreate' from package 'lustre-utils' (universe) Command 'pcreate' from package 'pbuilder-scripts' (universe)
[19:18:15] Guest83494: create: command not found
[19:19:00] agent_white: Guest83494: Gonna give you a pastbin of a little GoogleDoc I made for myself :)
[19:19:55] Guest83494: thanks so much! I feel like a bit of a retard ????
[19:20:47] foucist: how do i treat an undefined variable as false ?
[19:20:55] bricker`work: foucist: defined?(variable)
[19:20:55] foucist: without rescue
[19:21:02] agent_white: Guest83494: Pfft! I began a tutorial for Rails that said "choose your db", and I ended up spending a few hours figuring out postgres :P
[19:21:28] toretore: variable = false; if variable
[19:21:33] Guest83494: Ah good haha. Makes me feel a bit better :)
[19:23:03] agent_white: Guest89494: https://gist.github.com/jakenotjacob/7324610
[19:23:24] agent_white: Guest89494: Let me know if that works for you :)
[19:23:28] Apane: Hey guys, how to install rails 4.0.1 with homebrew on mac?
[19:23:48] toretore: Apane: install rbenv or rvm first
[19:23:54] toretore: then gem install rails
[19:24:46] Apane: thanks toretore
[19:27:05] BrazenBraden: can you do f.submit do
[19:27:14] BrazenBraden: or just f.button do
[19:27:22] s2013: [{"name"=>"gtk", "sha"=>"sadfasasdfdfasdf", "commits"=>[{"branch"=>"gtk", "message"=>"asdf", "sha"=>"0443e7asdfasd96asdfa34abf1f20e2"}, }]
[19:27:36] s2013: thats a ruby string right? or what would that be considered
[19:27:38] s2013: i know its not json
[19:27:40] s2013: or is it?
[19:27:49] BrazenBraden: s2013: its not json
[19:28:05] s2013: so what is that considered? just a ruby hash?
[19:28:11] BrazenBraden: s2013: json is like {"name":"gtk", etc etc}
[19:28:36] BrazenBraden: s2013: me thinks a hash
[19:29:36] s2013: hmm alright
[19:30:38] BrazenBraden: s2013: commit.branch = gtk; commit.message = asdf;
[19:31:06] s2013: currently its like commit["branch" etc
[19:31:08] BrazenBraden: i could be wrong
[19:31:15] s2013: commit["branch"]
[19:31:22] BrazenBraden: you can pull vars out a hash both ways i believe
[19:31:36] BrazenBraden: array or hash notation
[19:31:38] maletor: Stumped them: http://stackoverflow.com/questions/19779074/strong-parameters-permit-array-of-arrays
[19:31:41] s2013: basically there are 4 different names which creates 4 select. i need to turn it into one select as optgroup
[19:32:14] BrazenBraden: s2013: is that a param string?
[19:33:49] agent_white: Anyone free to take a peek at an issue I'm having with routes?
[19:33:51] agent_white: http://pastie.org/8457886
[19:33:54] Guest83494: agent_white: Thanks, I'm afk but I'll give that a go!
[19:34:05] s2013: https://gist.github.com/ss2k/64ee30edf52ebf505c5d thats how it looks BrazenBraden
[19:34:17] s2013: you are doing r3ia agent_white ?
[19:34:34] agent_white: s2013: Yep :P I'm at a section where quite a bit went haywire.
[19:34:37] BrazenBraden: s2013: any particular reason for chosing form_tag over form_for?
[19:35:04] s2013: BrazenBraden, not my code. im rewriting it
[19:35:11] kara_sweets: whats the best way to reset a cache after expiring?
[19:35:53] BrazenBraden: s2013: is that form using nested attributes?
[19:36:09] s2013: uh.. no clue. hold on
[19:36:21] s2013: the codebase is a mess.
[19:37:13] BrazenBraden: maybe easier to re-write it from scratch?
[19:37:51] s2013: BrazenBraden, its like 20,000 lines of code
[19:38:07] BrazenBraden: why you re-doing it?
[19:38:33] s2013: actually i think its something like 28,000 lines of code or something
[19:38:37] s2013: redoing the form?
[19:38:43] BrazenBraden: only the form?
[19:38:43] lxsameer: hi guys what is the type for "date time" in scaffold generator command line ?
[19:38:48] BrazenBraden: well thats less work lol
[19:38:57] s2013: well im adding features, refactoring some of the code, etc.
[19:39:07] s2013: cause they dont like the current form
[19:39:27] s2013: our avg response time was something like 5000ms or something
[19:39:39] s2013: after i started refactoring stuff i got it down to about 500ms
[19:40:05] s2013: basically the other dev added tons of features in short span of time and never went back to refactor the code
[19:40:11] s2013: and we have 0% test coverage
[19:41:19] s2013: yeah.. :\
[19:44:36] sedrickcz: hi guys, i have model image: https://gist.github.com/sedrickcz/f9e016877d0f337e4e5a and model order: https://gist.github.com/sedrickcz/ac38abe1c5c223c6abe7 and the are connected through: https://gist.github.com/sedrickcz/aca8e50b8461b3abc769 and I need set model_type="Order" before or after save. Any advice? Thank you
[19:46:54] BrazenBraden: sedrickcz: put all the gists into one.. you can add mulitple "files" to a gist
[19:47:33] AntelopeSalad: a weeks ago someone gave a neat tip to auto-login the first devise user in your db, does anyone have a gist of how to do that? i'm not really sure where the sign_in call should happen
[19:47:37] AntelopeSalad: *a few weeks ago
[19:47:54] BrazenBraden: AntelopeSalad: sounds like a before_filter to me
[19:48:08] AntelopeSalad: BrazenBraden: a before_filter in the application controller right?
[19:48:11] BrazenBraden: put it int ApplicationController
[19:48:16] BrazenBraden: AntelopeSalad: yuea
[19:49:15] sedrickcz: BrazenBraden: ok .) https://gist.github.com/sedrickcz/7325017
[19:49:27] cpruitt: kara_sweets: I don't really understand your question. Can you ask it with some more detail?
[19:49:42] BrazenBraden: sedrickcz: lol not exactly what i meant but ok
[19:51:21] BrazenBraden: sedrickcz: looks like you missing a "has_many :orders, through: :image_models" in your Image model
[19:51:25] AntelopeSalad: BrazenBraden: sweet, this works perfectly
[19:51:37] BrazenBraden: AntelopeSalad: cool :)
[19:52:07] BrazenBraden: sedrickcz: think you also need a "belongs_to :order" in your ImageModel class
[19:52:19] kara_sweets: cpruitt: I'm caching a large data set , when i expire the cache i imagine a sorry user will visit the page and by doing so reset the cache. in which case it'll take a whole shit load of time (maybe a minute) for the page to load
[19:52:30] kara_sweets: cpruitt: is there a way to expire the cache, and re set it in the background
[19:53:55] BrazenBraden: sedrickcz: wait... im confused by your naming conventions
[19:54:23] BrazenBraden: sedrickcz: IMAGE has_many ORDERS through IMAGEMODEL?
[19:54:36] spiderface: JUST BECAUSE I AM A GIRL DOESNT MEAN I LIKE THEM. I LIKE HEAVY METAL AND COUNTRY YOU GOT A PROBLEM WITH THAT TAKE IT UP WITH MY FISTS
[19:54:54] BrazenBraden: spiderface: cool story bro
[19:55:02] kara_sweets: spiderface: ya can you tell it again
[19:55:16] kara_sweets: lol jk, heavy metal for the win |m?
[19:56:29] rhizome: spiderface: how old r u
[19:57:21] Valentinial: Can anyone tell me why the menu drop down (after you shrink the screen to a small size) will not work after you use a link within it? https://www.dropbox.com/s/umb9gx0u3ac1zp6/hardy.zip
[19:57:46] pothibo: st. anger.
[19:58:11] rhizome: Valentinial: a zip file? try again.
[19:59:02] s2013: BrazenBraden, any clue how i can turn the form into a grouped_collection_select ?
[19:59:59] s2013: or would i need to use groupe_options_for_select
[20:00:08] BrazenBraden: s2013: cant say I have worked with them much :( but have you tried looking at something like Simple_Form? They have a great "f.association :blah" which is quite clever.. might be able to help?
[20:00:26] s2013: yeah i use simple form generally
[20:00:27] cpruitt: kara_sweets: Why are you caching a raw data set that large? Why not cash individual results queried against the data set?
[20:00:32] gerep: Guys. I have a model with a attribute (:file) that's not in the database. If I use attr_accessible it returns "can't write unknown attribute `file`" and if I remove it it returns can't mass assign protected attribute, how can I "fix" this?
[20:00:32] Valentinial: rhizome: what was a better format? the menu uses several files in the the rails site and i didnt know how to paste them all about
[20:00:47] helpa: Valentinial: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[20:00:47] universa1: Valentinial: !gist
[20:01:09] rhizome: Valentinial: it may be a bad question for IRC, then
[20:01:14] rhizome: it happens
[20:01:24] bricker`work: gerep: How have you defined the attribute?
[20:01:44] Valentinial: I had a link to the site yesterday but no one answered i thought maybe a link was bad so i zipped it . I can provide a working link
[20:01:52] gerep: bricker`work attr_accessible :file. I was using rails 3.1.10 but now I've updated to 3.2.0
[20:02:29] NemesisD: i've got something really confusing going on. i have a validates_uniqueness_of :email, :case_insensitive => true, collation is case insensitive, i have an invalid model saying email is already taken, but Customer.where(:email => c.email).count # => 1
[20:03:15] rhizome: NemesisD: wouldn't that be your existing record?
[20:03:31] NemesisD: rhizome: exactly
[20:03:41] NemesisD: but that record is showing as invalid
[20:04:27] Valentinial: Can anyone tell me why the menu drop down (after you shrink the screen to a small size) will not work after you use a link within it? http://184.168.111.214:3333/users
[20:04:49] cpruitt: kara_sweets: http://edgeguides.rubyonrails.org/caching_with_rails.html#fragment-caching - Refer to the note about Russian Doll Caching at the end of the section. Not sure what your'e working with, but that might be of interest to you.
[20:06:26] Radar: spiderface: hi
[20:06:34] Radar: +b *!*@96.232.23.191
[20:06:39] Radar: Radar kicked spiderface:
[20:06:46] Radar: cite: http://logs.ryanbigg.com/p/spiderface
[20:08:12] s2013: how big are the logs by now
[20:08:51] Radar: 1.5mil or so
[20:09:10] Radar: 1,427,195
[20:09:20] tubbo: Radar: http://logs.ryanbigg.com/RubyOnRails?date=2013-11-05#1427208 fucking mental!
[20:10:19] tubbo: Radar: i rather like the dichotomy of 2013-09-14's logs
[20:10:26] tubbo: java, java, php, starcraft
[20:11:19] BrazenBraden: aaarrrggg.. why is devise still signing in on email when i have told it to use username :/
[20:12:31] s2013: restart it?
[20:21:33] Valentinial: Has anyone had issues with rails4, foundation4 doing anything strange (i realize thats ambiguous) but has it been working without issues mostly?
[20:21:59] tubbo: Valentinial: yes
[20:22:04] tubbo: completely without issues
[20:22:18] jarr0dsz: so i have installed postgresql locally on osx but with bundle install it fails to install pg Could not find gem 'pq (>= 0)
[20:22:27] jarr0dsz: is there anything i missing? gem install pg with compile options goes ok
[20:22:28] tubbo: only issue i've had WRT rails 4 was this pesky sprockets bug where .js.em files won't be discovered but .em files will (EmberScript)
[20:22:36] tubbo: jarr0dsz: typo
[20:22:53] tubbo: jarr0dsz: use a better font
[20:23:03] jarr0dsz: argh :S time to stop for today
[20:23:58] Valentinial: would there be a reason why with foundation4/rails4 that the JS that works the toggle stop working after you clicked a link in the menu? but works perfect if you just refresh the page
[20:24:08] bricker`work: Valentinial: turbolinks.
[20:24:16] bricker`work: The answer is always turbolinks.
[20:24:26] tubbo: Valentinial: most likely turbolinks. don't use it
[20:24:59] Valentinial: oh yes.. that does some kind of on demand loading by loading parts of the page and then ajaxing out the rest or something right
[20:25:59] tubbo: Valentinial: it's similar to pjax. essentially instead of allowing the browser to refresh the page, it makes an ajax call to rails to receive a layout-free html response and insert it into <body>
[20:26:12] tubbo: Valentinial: so this way you don't reload your JS/CSS assets each time
[20:26:23] Valentinial: tubbo: ok will remove and retry, ya makes sense
[20:26:49] tubbo: Valentinial: also.. "For those using turbolinks, you will need to modify the application layout to include all assets in the header. Foundation includes javascript in the body by default."
[20:26:52] tubbo: http://railscasts.com/episodes/417-foundation?view=comments
[20:28:10] tubbo: lol first page google results of 'turbolinks and "zurb foundation"' is 100% errors and troubleshooting
[20:28:12] tubbo: fuck turbolinks
[20:28:49] Fire-Dragon-DoL: is turbolinks so bad?
[20:29:51] bricker`work: Fire-Dragon-DoL: it's okay if you start an app with it. You just have to be conscious about it when writing your javascript. It's a headache if you try to add it to an existing application with a bunch of javascript already working.
[20:29:53] tubbo: Fire-Dragon-DoL: i don't use it, you tell me :)
[20:29:57] Valentinial: tubbo: works fine after removing turbolinks. foundation:install seems to have removed the artifacts in the layout file but gemfile and app.js still had references
[20:30:18] Valentinial: tubbo: thanks for quote
[20:30:55] Valentinial: tubbo: i went all thru those comments yesterday on railscast... i cant believe i missed that.....
[20:37:28] Fire-Dragon-DoL: mh ok as I imagined
[20:37:34] Fire-Dragon-DoL: porting is hard, but beginning may be ok
[20:40:44] pwz2000: Does anyone know how request.uri works? I am trying to set it here @askout = (request.uri =~ /askout/) . I am trying to link it to the /views/messages/askout.html.erb file. I get a NoMethodError undefined method `uri' when using it.
[20:42:58] tubbo: Fire-Dragon-DoL: imho (and this is just my opinion of course), turbolinks is just a shim for a problem as yet to be solved in a correct manner. i don't believe turbolinks is the way to go, instead i believe the front-end can be built better entirely in javascript.
[20:43:15] tubbo: rather than the "mixture" of JS and regular HTML returned from the server, which is what 37signals doe
[20:43:25] FooBarWidget: anybody having experience deploying rails + docker to production?
[20:43:41] slash_nick: Isn't there a replacement for turbolinks in the works? wiselinks?
[20:44:46] tubbo: FooBarWidget: that sounds really interesting :)
[20:45:04] FooBarWidget: I'm just wondering how people would do it
[20:45:09] FooBarWidget: there are two alternatives
[20:45:20] FooBarWidget: either you build the container in development and upload it to the server and start it
[20:45:43] FooBarWidget: or you let the server build the container, i.e. you're treating docker as a kind of lightweight VM inside which you do the provisioning
[20:45:48] pwz2000: oops misspelling
[20:46:07] FooBarWidget: I think the latter is a better idea, even with today's bandwidths uploading a 1 GB image is not a good idea
[20:46:22] Fire-Dragon-DoL: tubbo: I agree with that, turbolinks is to lower the price of the final product anyway: building something (for example) in angularjs requires much more knowledge than just put turbolinks there and move some script tags around
[20:46:28] tubbo: FooBarWidget: i would think that the former would be a more useful option...given the container does not change between docker and my own machine.
[20:46:50] tubbo: FooBarWidget: but then again, a 1GB upload is pretty trivial. we transfer in the 10s and 100s of GBs here daily.
[20:47:00] tubbo: FooBarWidget: all locally, in our own datacenter & colo :)
[20:47:16] FooBarWidget: depends on your connection I guess. I often work from home and I upload at 250 KB/sec
[20:47:26] tubbo: yeah, if you're actually uploading to a production web server...you might want to do the latter.
[20:47:31] tubbo: just so you don't have to transfer GBs
[20:47:37] FooBarWidget: the container shouldn't change as long as your build steps are reproducible
[20:47:42] Fire-Dragon-DoL: FooBarWidget: talk about yourself, I have 0.5 Mbit of upload <.<
[20:49:29] FooBarWidget: I remember a time when 60 KB/sec upload was godly
[20:49:48] FooBarWidget: I had 16 KB/sec upload back then. sharing a video took a day
[20:50:20] FooBarWidget: I had 33.6k :p
[20:50:34] tubbo: omg you can still buy 56k modems
[20:51:00] FooBarWidget: 56k modems may one day make a comeback
[20:51:11] tubbo: FooBarWidget: bullshit
[20:51:26] FooBarWidget: telcos are being draconian with their data limits. this country's 4G plans have a 1 GB data limit -_-
[20:51:39] FooBarWidget: on the other hand, telcos are now starting to offer "unlimited" speech
[20:51:54] lethjakman: FooBarWidget: lol....I remember those days.
[20:52:05] FooBarWidget: see where I'm going?
[20:52:13] tubbo: FooBarWidget: you really think the telco is too stupid to figure that one out? :P
[20:52:31] tubbo: all you need is a way to detect modem sounds on the phone line and have a script to kill the service once you hear that
[20:52:34] FooBarWidget: the plans are made by management
[20:52:58] FooBarWidget: I don't think the technical guys care to warn their management about the dangers of people using speech for data
[20:53:05] FooBarWidget: I don't think management understands anyway
[20:53:12] tubbo: you're not giving them enough credit :)
[20:53:24] tubbo: these people are *not* stupid.
[20:53:32] toretore: i had isdn x 2 @ 128 Kb. beat that suckers!
[20:53:46] tubbo: haha toretore you must've been rich
[20:53:51] tubbo: toretore: did you have that on your yacht?
[20:54:09] jarr0dsz: so after some struggles finally got posgres compiled and working now my queries are acting up ;) like @online = Profile.where.not(:complete => 'IS NULL').where.not("updated_at >= ?", 2.minutes.ago)
[20:54:12] toretore: both yacht and mansion
[20:54:23] FooBarWidget: I'm fighting Dockerfile
[20:54:36] FooBarWidget: it doesn't let me add files outside the current directory
[20:54:43] toretore: telcos *are* stupid because they're digging their own grave. someone's going to come along and put them in it soon
[20:54:45] FooBarWidget: I just want to share a file between multiple Dockerfiles
[20:55:02] jarr0dsz: are there any AR specific documentions on how to merge queries to postgres and why they could break? ERROR: invalid input syntax for type boolean: "IS NULL"
[20:55:14] toretore: they're not responding to customer demand because they control the pipes
[20:56:47] tubbo: toretore: and the lines. that's why comcast has so much leeway, it's less about their market share and more about the fact that they were the guys who laid down the fiber/cable lines in the first place.
[20:57:00] tubbo: at least around here, comcast puts down all the lines. all of them. verizon LICENSES fios from comcast.
[20:57:14] tubbo: disclaimer: i live in philly which is owned by comcast :P
[20:57:34] tubbo: jarr0dsz: that query doesn't make snese.
[20:57:49] tubbo: jarr0dsz: also it's written wrong
[20:58:05] jarr0dsz: seems some boolean issues i have to fix tubbo guess some dirty old queries will survice now ;p
[20:58:54] jarr0dsz: im using 0 and 1 for boolean in my queries which it does not accept it seems
[20:59:06] tubbo: jarr0dsz: why? just use true and false
[20:59:58] FooBarWidget: tubbo: so you guys are using docker in production already?
[21:00:00] tubbo: Profile.not(complete: nil).not("updated_at >= ?", 2.minutes.ago)
[21:00:43] tubbo: FooBarWidget: no, we've been considering the use of docker for QA testing here at first
[21:00:48] jarr0dsz: yes i corrected terrible wrong query that i havent been seeing before a long time
[21:01:04] FooBarWidget: I'm investigating ways to integrate docker with passenger
[21:01:13] FooBarWidget: or somehow creating a system to allow easy deployments
[21:01:29] tubbo: FooBarWidget: upgrades are kind of a pain in the ass because we ship actual products, so we're somewhat unsure about the state of the machine when we hand off an upgrade.
[21:01:44] tubbo: FooBarWidget: would be easier if we could keep the DB on one container, the app on another, and then just switch 'em out.
[21:01:56] tubbo: and we use passenger, fwiw :)
[21:02:09] jarr0dsz: all works fine now thank you tubbo
[21:02:40] jarr0dsz: would you have suggestion how i could check my existing AR queries on any queries that would fail? beside using boolean true, false, and beside checking each single query in my whole app
[21:02:53] jarr0dsz: guess there is no smart way to scan incompatible / bad AR queries smartly
[21:03:06] tubbo: jarr0dsz: write tests :)
[21:03:10] zelrik_: is there a way to combine js files in the assets pipeline
[21:03:32] zelrik_: well more like making a single call to load several js files
[21:03:34] tubbo: zelrik_: manifests
[21:03:41] tubbo: zelrik_: yeah that's what a manifest is
[21:03:41] jarr0dsz: zelrik_ create a new mycustomone.js for example and include each file seperatly in your manifest
[21:03:53] jarr0dsz: no auto include in the manifest but manual enter each line which js asset to include for that manifest
[21:03:58] zelrik_: and that ll work in a gem right?
[21:04:05] zelrik_: I ll give it a shot
[21:04:17] jarr0dsz: should not make difference if is a gem or regular app i think
[21:07:25] zelrik_: actually I dont need it
[21:07:44] zelrik_: I just created a gem to include js files
[21:07:50] zelrik_: ACTION is proud
[21:09:19] zelrik_: the gem does not seem to work without the html so I guess I ll make a helper for it
[21:20:13] zelrik_: actually I wonder what s the best way to create a helper
[21:22:43] Valentinial: From earlier with using turbolinks with foundation4 in rails4. if i put turbolinks back in the app and move the javascript tag into the header and out of the body, then the menu doesnt work at all
[21:23:42] Valentinial: I also added jquery-turbolinks gem which is supposed to help with loading this type of thing
[21:25:05] Valentinial: based on this http://stackoverflow.com/questions/18533070/zurb-foundation-is-making-my-assets-to-load-twice
[21:25:39] Valentinial: also comments on the railscast for foundation has a guy saying hte same thing after the other guy suggests moving it into header
[21:27:14] tubbo: Valentinial: did you google for 'turbolinks AND "zurb foundation"' ?
[21:27:31] tubbo: Valentinial: you should've seen an article about getting the topbar to work with turbolinks. read it.
[21:27:39] tubbo: i don't know what it says but it's probably helpful :)
[21:27:42] Valentinial: googled yes will recheck
[21:27:48] tubbo: it was like the 4th one down
[21:29:19] tubbo: hey rails 2.3.x junkies...any of you ever get shoulda-context to work with rails' original test/unit?
[21:29:23] makerops: what's the best way to update N instances of another model, upon create of a model?
[21:29:32] pwz2000: Question. I am getting a 'First argument in form cannot contain nil or be empty' that points to the line '<%= form_for @message, :url => user_messages_path(@user) do |f| %>'. I have @messages defined in the controller. What else would I be missing? What I have been trying to do is duplicate the new message (inbox) form and have it called "askout". With this I will have two layouts of composing a message to a user. The /new.html.rb
[21:29:32] pwz2000: compose box shows fine. With the same exact code the /askout.html.rb gives the argument error since @message is nil. https://gist.github.com/pwz2k/7326553
[21:29:37] makerops: (from a form)
[21:30:37] elaptics: makerops: you want to edit several instances at once?
[21:31:03] Radar: pwz2000: @mesage is nil
[21:31:04] Radar: @message*
[21:31:45] makerops: elaptics, yes, ie I have an order form, and 5 hidden values that are the IDs of the line items
[21:31:59] makerops: I want to update those 5 items before_create of the order
[21:32:30] pwz2000: Radar: I have that defined under new with @message = Message.new. Not understanding why it would be nil
[21:32:34] elaptics: makerops: railscasts has a few episodes on the subject http://railscasts.com/episodes?utf8=???&search=edit+multiple
[21:32:41] Radar: pwz2000: Show us the controller with the action and the template please
[21:32:44] pwz2000: My code is 100% the same from the file I copied.
[21:33:56] Radar: pwz2000: where's the code?
[21:33:58] AntelopeSalad: hey guys, i have some working code but it feels like i'm doing it seriously wrong -- does this seem reasonable to do? https://gist.github.com/anonymous/7326720
[21:34:12] makerops: elaptics, cool thanks
[21:34:16] Radar: pwz2000: how is the askout template being rendered?
[21:34:36] AntelopeSalad: the idea is i'm creating a comment through a modal dialog box in a polymorphic association , and that gist is the create method for the comment controller
[21:35:16] pwz2000: Radar: I am typing it in myself, not coming from another page. So atm not rendering it but that shouldn't make a difference.
[21:35:31] makerops: elaptics, is there one that shows how to do it from another model/controller
[21:35:42] Radar: pwz2000: what
[21:35:45] makerops: ie, I want to update the order_id, on all the products, from the order controrller
[21:35:46] elaptics: AntelopeSalad: do you have several things with comments as a nested resource?
[21:35:50] Radar: pwz2000: I don't understand what you mean by "typing it in"
[21:36:05] Radar: pwz2000: Where is the action for the askout template? Where is @message being set to anything?
[21:36:06] AntelopeSalad: elaptics: nothing is nested, i just have 2 models (but will have more) that are capable of being commented on
[21:36:31] elaptics: AntelopeSalad: so they're all just posting data to the comment controller?
[21:36:57] elaptics: AntelopeSalad: can't you put something in the form to tell you what it's related to?
[21:37:12] elaptics: makerops: I'm not sure what you mean
[21:37:26] AntelopeSalad: elaptics: yes, the form declaration looks like form_for [:dashboard, Comment.new], remote: true do ... end
[21:37:53] elaptics: AntelopeSalad: and how does the user know what they're commenting on?
[21:38:10] elaptics: AntelopeSalad: from your code it looks like you're relying on the referer to determine it?
[21:38:27] AntelopeSalad: elaptics: yes, because the way i have it setup.. you can't goto /comments/new
[21:38:33] Radar: pwz2000: You see what I'm saying now?
[21:38:51] AntelopeSalad: instead you would goto /projects/24/edit , and then there's a comment list along with a create comment button
[21:39:14] elaptics: AntelopeSalad: the referrer might not be guaranteed to be there. Can you pass a parameter or something to it which would definitively identify it as the resource?
[21:39:14] AntelopeSalad: so the user would be creating comments on the polymorphic association's view
[21:39:37] AntelopeSalad: the referer is because i'm displaying the form in a modal popup (twitter bootstrap)
[21:39:59] AntelopeSalad: if i don't use the refer then the request path ends up being the path of the comment controller
[21:40:03] elaptics: AntelopeSalad: how are you rendering the modal?
[21:40:35] AntelopeSalad: i mean the comment form's url
[21:40:41] elaptics: AntelopeSalad: I mean, is the modal doing an ajax request to load the new comment form
[21:40:47] AntelopeSalad: i'm rendering it when pressing a create comment link
[21:41:01] AntelopeSalad: the form fields for the comment is being included, it's not being rendered via ajax
[21:41:14] AntelopeSalad: it's just appended to the bottom of the view
[21:41:29] AntelopeSalad: does that make sense?
[21:41:41] elaptics: AntelopeSalad: ok, so you can easily add a hidden field to the form which identifies the resource page you're currently on?
[21:41:50] AntelopeSalad: yeah absolutely
[21:42:15] AntelopeSalad: then i wouldn't need to get the resource name and id through those dirty ways right?
[21:42:36] elaptics: AntelopeSalad: I'd probably do that rather than the referrer, but otherwise the resource.singularize, etc is what I'd do using that param
[21:42:55] AntelopeSalad: also i'm merging those 3 params into the comments_params because i didn't want to send them through the form initially
[21:43:00] elaptics: AntelopeSalad: I'd also validate it as something that can be turned into a class - like a whitelist
[21:43:10] AntelopeSalad: yeah i have the validation setup already
[21:43:24] AntelopeSalad: i have a POLYMORPHIC_ON array in the comment model that has a whitelist of types
[21:43:44] elaptics: AntelopeSalad: I'd possibly create the comment through the created resource, rather than setting the individual attributes directly
[21:44:03] AntelopeSalad: elaptics: do you have an example of that? that sounds like the proper way to do it
[21:44:06] elaptics: AntelopeSalad: since they're really an implementation detail that your domain shouldn't be dealing with
[21:44:52] elaptics: AntelopeSalad: well assuming that resource is the param that you've done singularize.constantize, etc on then just create the comment via it
[21:45:05] elaptics: AntelopeSalad: e.g resource.comments.create!(....)
[21:45:13] AntelopeSalad: hmm interesting
[21:45:41] elaptics: then just pass the comment params in and merge in the current_account with :account - again not setting the id directly
[21:45:44] AntelopeSalad: i wouldn't need to merge the commentable_type/id, it would be filled in by rails?
[21:45:46] jrhorn424: What's the idiom for inspecting the methods of an object and that objects' direct ancestor only? so `class Foo < Bar; end`, I want to see methods only from Foo and Bar.
[21:45:53] Valentinial: tubbo: i think i read the one you indicated already but it was the same stuff which was not working, however i just found another post that says to load foundation in the body of the layout instead of in the app.js. <script>
[21:45:54] Valentinial: $(document).foundation();
[21:45:54] Valentinial: </script> this does make everything work. but should it
[21:45:55] elaptics: AntelopeSalad: exactly - that's AR's job
[21:46:05] AntelopeSalad: ok that sounds amazing, let me see if that works
[21:46:45] elaptics: AntelopeSalad: same idea applies to validations, I see lots of people doing validates_presence_of :foo_id rather than validates_presence_of :foo
[21:47:31] AntelopeSalad: elaptics: it says undefined method create hmm
[21:47:52] elaptics: AntelopeSalad: gist all the code and stacktrace
[21:49:54] pwz2000: Radar: Yes I have it now. Thanks
[21:49:56] AntelopeSalad: elaptics: is the controller method and the trace enough?
[21:50:41] elaptics: AntelopeSalad: possibly, let's see those first
[21:51:12] AntelopeSalad: i think i see a potential problem, it's trying to call "Foo".create
[21:51:12] AntelopeSalad: i could be wrong tho , here's the gist https://gist.github.com/anonymous/7326970
[21:51:26] droptone: what wysiwyg editor do you guys recommend? mercury? bootsy?
[21:51:29] droptone: this is for rails 3.2.x
[21:51:33] AntelopeSalad: i think i need to constanize or whatever that resource variable
[21:51:54] Valentinial: hmm i didnt think people used wysiwyg editors with rails apps? now i'm listening...
[21:52:13] droptone: well we're deving a site where the users are to be able to have their own blog and update content
[21:52:17] elaptics: AntelopeSalad: yes you do
[21:52:48] elaptics: AntelopeSalad: resource.singularize.constantize
[21:53:33] elaptics: AntelopeSalad: ultimately depends what you're passing in to convert it to the string class name, and then you #constantize that
[21:53:37] AntelopeSalad: hmm that didn't work either, it didn't put the capital letter
[21:53:59] elaptics: AntelopeSalad: are you still doing this with the referrer?
[21:54:13] AntelopeSalad: yeah, the form way will take some time to implement later
[21:54:26] AntelopeSalad: maybe i should just hardcode it for now?
[21:54:31] AntelopeSalad: with a specific model
[21:54:41] elaptics: AntelopeSalad: so the stacktrace says "Lead" - do you have a Lead model?
[21:55:00] AntelopeSalad: yes, but keep in mind that stack trace is before we constantized it
[21:55:00] nettoweb: : guys, I cant use paperclip to host my static files on heroku?
[21:55:03] elaptics: AntelopeSalad: oh, the other thing is you're missing #comments on it
[21:55:15] elaptics: resource.constantize.comments.create!
[21:55:42] elaptics: nettoweb: heroku doesn't have a file system you can save files to
[21:55:59] elaptics: nettoweb: it's designed such that you should use some kind of cloud storage like s3
[21:56:06] Valentinial: nettoweb: i think heroku tells you to use amazon s3 or something for that, some amazon thing
[21:56:10] elaptics: nettoweb: you can use paperclip to upload the files there
[21:56:41] AntelopeSalad: elaptics: i tried hard coding it and now i get an undefined method 'comments' for <Class: ...>
[21:56:50] AntelopeSalad: i did Lead.comments.create
[21:57:00] elaptics: AntelopeSalad: so don't you have has_many :comments in your Lead model?
[21:57:17] elaptics: AntelopeSalad: oh wait it's polymorphic, yes?
[21:57:22] AntelopeSalad: i need to do commentable right?
[21:57:27] elaptics: AntelopeSalad: what have you called it?
[21:57:36] elaptics: AntelopeSalad: ah that'\ll be it then
[21:57:38] AntelopeSalad: it's has_many :comments, as: :commentable
[21:58:09] AntelopeSalad: same error with commentable
[21:59:02] elaptics: AntelopeSalad: gist your model
[21:59:28] AntelopeSalad: the lead model?
[21:59:28] elaptics: AntelopeSalad: comment and lead please
[22:00:10] bricker`work: `Lead.comments.create`? `comments` is an instance method, not a class method.
[22:01:04] elaptics: bricker`work: haha, you are right. My brain is too tired now :)
[22:01:23] Apane: what's happening here guys? https://gist.github.com/anonymous/62ba0c84567add9b3a3d
[22:01:44] elaptics: AntelopeSalad: bricker`work is right, we're forgetting to load the "parent" first
[22:01:47] Apane: and how do we get it working, doesn't look right ot me
[22:02:13] AntelopeSalad: elaptics: https://gist.github.com/anonymous/7327128
[22:02:13] elaptics: AntelopeSalad: so you need to resource.constantize.find(id_of_parent_here).comments.create
[22:02:19] AntelopeSalad: i trimmed out everything that's not necessary
[22:03:50] elaptics: AntelopeSalad: so despite my missing that, it's kinda the reason I've been suggesting embedding this stuff in the form or being able to fetch this stuff from the url via a nested resource
[22:04:17] AntelopeSalad: yep Lead.find(id).comments.create works
[22:04:39] elaptics: AntelopeSalad: since you have the form ready on the page to be put into the modal, just add a couple of hidden fields for the id of the parent and the class name you're going to need
[22:05:00] elaptics: AntelopeSalad: then just grab those in the controller instead of the referrer stuff and you're done
[22:05:14] AntelopeSalad: i have the controller name already as a data attrib in my body, so i should be able to get the class name from that
[22:05:48] elaptics: AntelopeSalad: if you're already using the object on the page then you have exactly what you need already
[22:05:50] Radar: pwz2000: good :)
[22:05:51] AntelopeSalad: wait, what do you mean by grab them in the controller? you mean as a strong param?
[22:06:18] AntelopeSalad: and is there a rails-way to get the parent id?
[22:06:21] elaptics: AntelopeSalad: can you gist your controller and template for the edit page where this modal is?
[22:06:23] zeknox: whats the best way to call an 'action' that is in a different controller, I have the 'action' clear_logs in my reports controller and want to call it from my email controller
[22:06:36] Valentinial: ok i figured it out it was the app.js order of the requires.
[22:06:38] AntelopeSalad: elaptics: the entire comments controller?
[22:06:38] Valentinial: tubbo: thanks
[22:06:53] AntelopeSalad: or the lead (parent) controller?
[22:06:54] elaptics: zeknox: what do you mean, "call" it?
[22:06:58] nettoweb: elaptics: thanks
[22:07:06] zeknox: elaptics: need to invoke the code in clear_logs
[22:07:21] zeknox: elaptics: don't want to rewrite the same code in a different controller
[22:07:26] elaptics: AntelopeSalad: the controller that's rendering the template which contains the modal you're trying to display
[22:07:42] AntelopeSalad: ok, that would be the lead one then
[22:07:51] elaptics: zeknox: put the shared code in a module
[22:07:57] AntelopeSalad: although for editing a comment, i do use the comment's controller but that's not done through a modal
[22:08:04] AntelopeSalad: it's just a standard dashboard crud page
[22:08:26] elaptics: AntelopeSalad: I just want to see the template and what you've got in the controller that's available to the template
[22:09:19] AntelopeSalad: yeah, i'm preparing the gist now, one moment
[22:09:27] momomomomo: Anyone else deployed with puma on Jruby? I'm getting what seems like java issues
[22:09:47] momomomomo: Gist of the trace is here https://gist.github.com/momer/7327220
[22:10:18] elaptics: zeknox: if it's rails 4 then you have controller concerns which would probably be the ideal place
[22:10:19] zeknox: elaptics: what about making def clear_logs into self.clear_logs within the controller?
[22:11:09] AntelopeSalad: elaptics: https://gist.github.com/anonymous/7327234
[22:11:25] AntelopeSalad: that setup is using cancan for authorization too
[22:11:30] elaptics: zeknox: then it won't work as an action
[22:11:37] smathy: momomomomo, "The signal USR1 is in use by the JVM and will not work correctly on this platform"
[22:12:16] zeknox: elaptics: but it would still run the code, just wouldn't render the view?
[22:12:17] smathy: Ie. the JVM won't pass USR1 through to Puma, which means it never gets stopped, which is why the socket is still in use and you get the IOError.
[22:12:33] momomomomo: smathy: I'm using the https://github.com/puma/puma/blob/master/lib/puma/capistrano.rb recipes - any ideas on how to avoid that?
[22:12:55] smathy: momomomomo, don't use jruby.
[22:13:03] momomomomo: puma was made for deployment on jruby, though
[22:13:31] AntelopeSalad: elaptics: i planned to use that same modal create partial in the other models that are commentable
[22:13:32] tubbo: momomomomo: lies
[22:13:58] tubbo: momomomomo: considering it was made by the same guy who made rubinius... :)
[22:14:02] smathy: momomomomo, I'm totally guessing based on the error message you're getting, I'm not familiar with either.
[22:14:15] smathy: ...well, "guessing" is an understatement ;)
[22:14:26] tubbo: i think the correct term is "giving bad advice"
[22:14:57] elaptics: AntelopeSalad: yep, so just pass in @lead as a local variable into the partial where you're rendering it, and in the form_for add hidden fields using that object to get its id and class name
[22:14:59] smathy: "advice"? I thought I was conducting experiments, aren't you all bots?
[22:15:00] tubbo: but yeah, i bet you just can't send signals to Puma on JRuby
[22:15:06] tubbo: smathy: beep boop blorp
[22:15:15] smathy: Excellent. Back to work bot.
[22:15:42] AntelopeSalad: then i could do @lead.commentable.type as a hidden input?
[22:15:48] AntelopeSalad: or whatever the chain ends up being
[22:15:49] elaptics: zeknox: that's just a bad idea generally, can you gist your current code
[22:17:01] zeknox: elaptics: I want to run this code from a different controller: https://gist.github.com/zeknox/7327313
[22:17:49] elaptics: AntelopeSalad: well assuming you'd passed it in as a local variable called parent then in the form_for block you'd just do hidden_field(:parent_id, parent.id) and hidden_field(:parent_type, parent.class)
[22:18:33] elaptics: AntelopeSalad: in your comments controller that'll result in params[:parent_id] and params[:parent_type] being available so you can constantize the parent type and use it to find the parent_id
[22:19:12] AntelopeSalad: ok one sec, let me do the form grunt work now -- i think i have it setup
[22:20:59] elaptics: zeknox: so I would definitely just generalize that to a method in a concern and include it into the relevant controllers and then just put that method in the controller
[22:21:05] AntelopeSalad: elaptics: the ids for the hidden fields are: comment_commentable_type and id
[22:21:11] AntelopeSalad: they are being populated successfully
[22:23:01] elaptics: zeknox: either that or move it into it's own class or module and just run it in any controllers that need to use it
[22:24:03] elaptics: zeknox: e.g. ClearCampaignLog.new(campaign_id).clear
[22:25:33] zeknox: elaptics: haven't learned about modules yet, but may be what i should do
[22:26:30] elaptics: zeknox: the more I think about it, the more I'd be inclined to just make a class for it in /lib
[22:27:00] AntelopeSalad: elaptics: it's all working, does this controller method look good to you? https://gist.github.com/anonymous/7327443
[22:28:18] elaptics: AntelopeSalad: yes, except that you should just do #merge(account: current_account) - don't use the id fields directly let AR take care of it
[22:28:43] AntelopeSalad: it seems to crash when you specify an invalid type too
[22:28:55] AntelopeSalad: i fixed that in my validation code, but it stinks that i need to duplicate that code twice
[22:29:52] Radar: What code twice? What did I miss?
[22:29:54] elaptics: well it will because it can't find a class with that name - that's why you want to just whitelist valid types so you only try to constantize classes that a. exist and b. are models that you actually want comments on
[22:30:16] elaptics: AntelopeSalad: in case anyone tries to interfere with the params in the form on the page
[22:30:44] AntelopeSalad: yeah i have the whitelist in a validation rule on the model
[22:30:44] AntelopeSalad: but that won't work for checking the form param
[22:31:12] elaptics: AntelopeSalad: one other thing. I'd move the commentable_type and commentable_id outside of the comments hash itself - you don't want to be mass assigning those in any way
[22:31:56] AntelopeSalad: https://gist.github.com/anonymous/7327527
[22:32:12] AntelopeSalad: that is the duplicate code, i would need to basically reimplement the commentable_type_exists in the controller?
[22:32:23] elaptics: AntelopeSalad: I'd put the acceptable types in a class constant - probably in the comment model and refer to that wherever you need it
[22:32:35] AntelopeSalad: that's what i have
[22:33:40] AntelopeSalad: also if i don't white commentable_type and commentable_id then how will the controller be able to use those values in the create method?
[22:33:40] AntelopeSalad: (as strong params)
[22:33:45] elaptics: AntelopeSalad: tbh they're pointless validations
[22:34:06] AntelopeSalad: i wanted to make sure my data is sound
[22:34:17] AntelopeSalad: otherwise someone could monkey around and add a Foo type
[22:34:26] elaptics: AntelopeSalad: because we've moved it around so that AR is taking care of it by creating the comment through the association
[22:34:42] elaptics: AntelopeSalad: there is no (and shouldn't be) any mass assignment of those ids
[22:35:04] elaptics: it's implementation detail that really your app logic shouldn't be aware of
[22:35:07] AntelopeSalad: elaptics: ok, so i can remove those validations
[22:35:35] elaptics: yeah because they won't get run until it's already crashed out :)
[22:35:43] AntelopeSalad: but i'm confused about the mass assignment tho
[22:35:43] AntelopeSalad: i thought rails would strip those 2 params out if i didn't white list them?
[22:35:53] AntelopeSalad: but if they are stripped then how can i create a comment when it needs the type/id to construct the comment from the parent?
[22:35:54] elaptics: AntelopeSalad: you want to do the include? check in the controller before you attempt to constantize it
[22:36:46] AntelopeSalad: but i still need to params.permit the type/id? but that is "mass assignment" right?
[22:36:55] lethjakman: what should I replace .all with?
[22:36:55] elaptics: AntelopeSalad: yes, rails will be stripping them out, which is what you want. That's why we're creating the comment through the parent - that's not mass assignment that's AR taking care of it. You don't need to care how - it just works :)
[22:37:25] AntelopeSalad: elaptics: yeah but i can't make the comment through the parent
[22:37:31] elaptics: AntelopeSalad: no, you effectively need to forget that _type and _id even exist
[22:37:37] AntelopeSalad: -unless- i have the Lead and 42 data from the form
[22:37:55] pwz2000: Radar: Check my post on Stack. I submitted that post from my PC prior to coming here. I didn't know it submitted since it froze until I got a email notification. I am going to delete the entire thread as I don't think it would be helpful + you helped me from here already. UNLESS you want me to award you the points on Stack
[22:37:55] elaptics: AntelopeSalad: right, you're passing that data along to the controller to use
[22:38:27] AntelopeSalad: but aren't i passing it with permit?
[22:38:30] elaptics: AntelopeSalad: in your modal form you want to pass those things as parameters, they don't need to be within the comments hash
[22:38:51] elaptics: AntelopeSalad: just like :id is often passed in a url which you access via params[:id]
[22:39:05] elaptics: AntelopeSalad: you'd pass those things in at that "top level" in params
[22:39:11] droptone: any of you guys use phusion passenger with a multisite rails environment?
[22:39:13] AntelopeSalad: so i should use :comments_commentable_id instead?
[22:39:19] elaptics: AntelopeSalad: that's why I said use hidden_field, not f.hidden_field
[22:39:23] AntelopeSalad: (that is the id of the form field)
[22:39:24] helpa: droptone: Don't ask "does anyone use <thing>?". It's better to just state your problem and if anyone has used <thing> they will most likely answer.
[22:39:24] Radar: droptone: !used
[22:39:30] Radar: droptone: Yes I have done that before.
[22:39:45] droptone: if so, passenger always only looks in teh default, global gemset for gems. How do I go about getting passenger to look in the proper gemset for a given project?
[22:40:05] AntelopeSalad: elaptics: now you've confused the crap out of me haha, how does that stop someone from tampering with the data in the end?
[22:40:08] zelrik: I need to understand what I did today Oo
[22:40:14] Radar: droptone: You can specify a PassengerRuby environment variable per VirtualHost as far as I know.
[22:40:38] smathy: Radar, droptone, you can in passenger 4
[22:40:43] elaptics: AntelopeSalad: it doesn't and you can't prevent that, but in the controller you can choose to throw it away if it's not in your POLYMORPHIC_ON whitelist
[22:41:08] AntelopeSalad: elaptics: sec, i'm preparing a new short gist to make some changes
[22:41:09] droptone: can you, ok.
[22:42:05] AntelopeSalad: ok i just did a test
[22:42:27] AntelopeSalad: elaptics: i absolutely have to permit commentable_type and commentable_id in the strong params
[22:42:57] AntelopeSalad: if i remove them and change the params to use the id value instead of the name, the id gets stripped too
[22:43:19] elaptics: AntelopeSalad: you definitely don't. Gist me what you've got - the whole shebang
[22:45:13] AntelopeSalad: elaptics: https://gist.github.com/anonymous/7327693
[22:45:30] AntelopeSalad: i have not moved the validation yet to the controller
[22:45:59] zelrik: is there a good read to understand engines
[22:46:22] droptone: Radar: I appreciate the help. Turns out you have to run passenger-config --ruby-command and passenger will produce output to add to your vhost file, then cycle httpd and you're good to go.
[22:47:19] smathy: zelrik, you read http://guides.rubyonrails.org/engines.html ?
[22:47:31] elaptics: AntelopeSalad: so drop the f. off the hidden_field tags and you can then drop the comment part out of the params hash in the controller
[22:47:51] zelrik: smathy, I ll read that thanks
[22:48:03] elaptics: AntelopeSalad: :comment_commentable_type is wrong anyway :) it'd be params[:comment][:commentable_type]
[22:48:12] smathy: zelrik, np.
[22:48:12] AntelopeSalad: yeah there's an id and name
[22:48:19] AntelopeSalad: the id was that
[22:48:20] elaptics: AntelopeSalad: dropping the f. means that it'd just be params[:commentable_type]
[22:48:42] AntelopeSalad: ok, i dropped the f.
[22:48:52] AntelopeSalad: then what should my comments_param method look like?
[22:49:03] AntelopeSalad: you mentioned to drop the :comment but i'm not sure how that will still work tho
[22:49:20] elaptics: AntelopeSalad: when you're just using the standard hidden_fields, you don't need the 2nd param to be the value hash, just pass the value as the 2nd parameter
[22:49:37] elaptics: AntelopeSalad: let me just fork your gist
[22:49:55] AntelopeSalad: when you said drop the comment
[22:50:07] AntelopeSalad: you just mean literally remove comment_ from the param name in the create method
[22:50:33] AntelopeSalad: leave the strong params method alone?
[22:50:55] elaptics: AntelopeSalad: yes, https://gist.github.com/andyh/7327750
[22:52:10] AntelopeSalad: elaptics: now i get an undefined method constantize and it also tries to create a new lead judging by the params in the console log
[22:52:31] AntelopeSalad: the parameter value in the log doesn't even make sense now haha
[22:52:40] elaptics: AntelopeSalad: gist the parameters in the log
[22:53:04] AntelopeSalad: it's stuffing the entire lead model as the commentable_type
[22:53:27] AntelopeSalad: maybe it's not .class but should be something else?
[22:53:34] elaptics: AntelopeSalad: you probably need to stick #to_s on it
[22:54:34] AntelopeSalad: any idea why it worked previously?
[22:54:41] AntelopeSalad: the f. did something to control it i guess?
[22:54:55] tubbo: anyone know why an ivar i set in setup {} isn't carrying over to my tests?
[22:55:08] helpa: tubbo: 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.
[22:55:08] Radar: tubbo: !code
[22:55:51] elaptics: AntelopeSalad: the f. is just putting it within the comment part of the params. Can't see what else it would be doing
[22:56:22] tubbo: Radar: https://gist.github.com/tubbo/e3e5be5a7be2864b9a1d @event is nil in the test.
[22:56:39] AntelopeSalad: elaptics: i removed the value: from the hidden inputs and it's almost working but not quite
[22:56:51] tubbo: updated with the implementation
[22:56:58] elaptics: AntelopeSalad: have you copied my gist code?
[22:57:08] tubbo: it's failing on 'undefined method "status" for nil:nilClass
[22:57:09] AntelopeSalad: elaptics: https://gist.github.com/anonymous/7327870 , that is the parameters being sent to rails in the log
[22:57:32] blackmesa: Hi all. If I use jbuilder for my view, how can I refer to that data for a javascript function inside my view? In my *.json.jbuilder Ive used json.array!(@companies) do ..... as an example
[22:57:36] Radar: tubbo: very peculiar. Does it work with any other instance variable name?
[22:57:48] Radar: blackmesa: what javascript function?
[22:57:49] tubbo: Radar: nope, no instance vars are carried over from setup into test.
[22:58:01] elaptics: AntelopeSalad: can you gist the whole modal form code you currently have?
[22:58:14] AntelopeSalad: elaptics: yeah sec
[22:58:33] blackmesa: Radar: a js function inside my view which uses data: [{....}]
[22:58:55] blackmesa: I want to put that json array there
[22:59:13] AntelopeSalad: elaptics: https://gist.github.com/anonymous/7327892
[22:59:41] Radar: tubbo: still very strange works fine for me
[22:59:42] AntelopeSalad: that code results in the previous gist's params being sent to the controller
[22:59:46] tubbo: Radar: that's fucked up :O
[22:59:52] Radar: tubbo: https://gist.github.com/radar/7327905
[23:00:14] Radar: blackmesa: I would need to see more code and be able to tinker with it myself to figure that one out, sorry.
[23:00:22] tubbo: Radar: you using rails 2.3.9 in that example?
[23:00:26] Radar: tubbo: lol no
[23:00:31] tubbo: that's what we are using (unfortunately)
[23:00:37] Radar: I use a Rails version that was created in the last 3 months
[23:00:42] Radar: let me try it
[23:00:47] Radar: Not hard to setup really
[23:01:10] elaptics: AntelopeSalad: doh, sorry we want to use hidden_field_tag, not hidden_field
[23:01:58] AntelopeSalad: elaptics: ah, good eye
[23:02:20] elaptics: AntelopeSalad: eventually :)
[23:02:22] AntelopeSalad: it works now, and i think i see the benefit of doing it this way now
[23:02:30] Radar: tubbo: eeeexcept activesupport 2.3.9 tries to require iconv.
[23:02:44] tubbo: Radar: use ruby 1.8.7
[23:02:53] AntelopeSalad: now if someone monkey's around with the form, it will never EVER use the monkey'd version of commentable_type/id?
[23:02:54] tubbo: Radar: yep. that's what i get paid to work with.
[23:03:01] Radar: tubbo: I hope you get paid big
[23:03:05] AntelopeSalad: (when it actually saves the model)
[23:03:07] Radar: installing the iconv gem first
[23:03:16] Radar: uninitialized constant ActiveSupport::TestCase (NameError)
[23:03:22] tubbo: Radar: it's not bad. pretty stress-free actually because there's only so fast i can move. so i just hang out most of the day and help people here.
[23:03:22] MrPunkin: Do .js.erb templates get cached somewhere in production mode by default?
[23:03:23] AntelopeSalad: all i need to do now is validate the type/id as sent outside of the comment hash and i'm golden?
[23:03:31] Radar: tubbo: I noticed :)
[23:03:34] MrPunkin: like when rendered as a JS response that is
[23:03:41] Radar: I get undefined method for nilClass too now... good start
[23:03:55] elaptics: AntelopeSalad: the only other thing that's not addressed here directly is whether the current user is allowed to do this with the parent resource and its subsequent comments, but that's down to how you deal with cancan, etc
[23:04:02] Radar: brb archaeology
[23:04:18] AntelopeSalad: elaptics: that was an issue with the previous implementation too or no?
[23:04:20] s2013: grouped_options_for_select for that how do i show a specific key as hte default one? its using hash
[23:04:26] elaptics: AntelopeSalad: yeah, you need to just make sure that the passed type is one you actually want to deal with
[23:04:45] elaptics: AntelopeSalad: yes, the problem was there previously too
[23:05:03] AntelopeSalad: elaptics: oh so maybe i can have a new validate class method on comment? and pass in "Lead" specifically in the lead controller and make sure it's in my white list array?
[23:05:32] elaptics: AntelopeSalad: a lot of the time you tend to just scope things via the current user, e.g. if the user can only access leads they have created
[23:05:34] Radar: tubbo: It appears that in 2.3 you need to define a setup *method*, not call the setup method.
[23:06:09] elaptics: AntelopeSalad: you're almost pre-empting my next refactoring step there :)
[23:06:11] Radar: tubbo: that's at least what I can ascertain from all this: https://github.com/rails/rails/blob/2-3-stable/activesupport/lib/active_support/testing/setup_and_teardown.rb#L57-L84
[23:06:20] Radar: tubbo: and when I defined a setup method in my code it worjked
[23:06:23] Radar: with no j
[23:06:31] tubbo: Radar: haha
[23:07:07] Radar: https://gist.github.com/radar/dae038378396faec33a4
[23:07:10] Radar: Fairly easy to reproduce the problem
[23:07:16] Radar: My favourite kind of IRC help ;)
[23:07:25] AntelopeSalad: elaptics: i have not gotten into doing fine grained permissions yet
[23:07:25] AntelopeSalad: so far i just have an admin managing all
[23:07:25] AntelopeSalad: also what would you have done differently in that refactoring step?
[23:07:25] AntelopeSalad: "almost" makes me really curious heh
[23:07:28] elaptics: AntelopeSalad: what I would do is move that whole comment creation step into a class method on the comment model passing in the type and id, then in the method do the validation checks and if they pass create and return the comment instance otherwise raise an exception
[23:07:49] banisterfiend: keep getting this error when using pow, anyone have an idea? http://cl.ly/image/3s1c390h172J the app i'm trying to ruby is on ruby 1.9.3, so i have no idea why it's looking at ruby 2.0 gems :/
[23:07:49] tubbo: Radar: ughhhhhhhh we ARE using mocha.
[23:07:50] tubbo: bastards.
[23:08:08] s2013: grouped_options_for_select does that automatically sort the keys?
[23:08:24] AntelopeSalad: elaptics: and then i'd probably not use the responders gem's shortened syntax?
[23:08:34] tubbo: Radar: omg i actually do have to `def setup` instead of `setup {}`...guess i forgot that
[23:08:57] Radar: tubbo: yup
[23:09:03] elaptics: AntelopeSalad: no, you can still use the responder stuff
[23:09:06] AntelopeSalad: i would just do if some_new_method then poly_redirect OK FLASH else poly_redirect FAIL FLASH?
[23:09:06] Radar: tubbo: but on Rails 4 you use a setup block instead
[23:09:12] tubbo: Radar: yeah, rails 3+ added that iirc.
[23:09:12] AntelopeSalad: and some_new_method would return true or false?
[23:09:15] Radar: tubbo: and in the testing guide it says to use a setup block
[23:09:22] elaptics: AntelopeSalad: @comment = Comment.create_from_parent(....
[23:09:33] tubbo: Radar: that is, of course, if you're not using a reasonable test framework such as oh i don't know maybe RSpec?
[23:11:38] AntelopeSalad: elaptics: your create from parent method would have 3 args right?
[23:11:38] AntelopeSalad: the type, id and the expected type?
[23:11:38] AntelopeSalad: so in this example "Lead" would be the expected type
[23:12:18] elaptics: AntelopeSalad: no 4, it'd be parent_type, parent_id, comment params and current_account
[23:12:54] AntelopeSalad: elaptics: hmm what about the expected type?
[23:13:00] elaptics: AntelopeSalad: 3 if you want to go back to hidden_field and combine those two things into a parent hash in params
[23:13:03] AntelopeSalad: or would you assume if it's in the white list array then it's good?
[23:13:08] elaptics: AntelopeSalad: that's dealt with inside the method
[23:13:44] elaptics: AntelopeSalad: and yeah, the first thing the method would do is check the type against the whitelist array and throw an exception if it's not in there
[23:14:07] AntelopeSalad: that wouldn't stop someone from sending a Photo type through the lead form tho
[23:14:10] AntelopeSalad: but i guess that doesn't matter?
[23:15:04] elaptics: AntelopeSalad: right, you can't stop them from fiddling with the form, that's why you check and throw a wobbler if they send something they shouldn't - the right thing to do is blow up, if they were using the app properly that wouldn't occur
[23:15:33] AntelopeSalad: yeah i'm ok with it exploding if they are messing around trying to break it on purpose
[23:16:10] AntelopeSalad: now i see why you need comment_params/current_account, duh
[23:17:02] elaptics: AntelopeSalad: they're fairly essential :)
[23:17:09] AntelopeSalad: thanks a lot btw
[23:17:19] AntelopeSalad: this new way of doing it is so much cleaner it's not even funny
[23:17:32] AntelopeSalad: and i learned how to create something through a parent, that's neat
[23:17:39] elaptics: np - we got there in the end :)
[23:18:17] workmad3: repository patterns ftw!
[23:18:23] AntelopeSalad: the fine grained cancan permissions seems like something i'll research another day
[23:18:57] AntelopeSalad: i vaguely remember a polymorphic segment in his readme, but i didn't read it yet
[23:19:50] workmad3: AntelopeSalad: also have a look @ Authority
[23:20:42] Valentinial: Is there a default rails variable (other than adding your own to routes) that goes to the home/root directory? home_path or root_path or something? similiar to users_path, products_path
[23:20:57] AntelopeSalad: workmad3: do you prefer it over cancan?
[23:21:13] workmad3: Valentinial: you mean 'root_path'
[23:21:16] bricker`work: Valentinial: root_path is what gets created when you specify `root to: 'home#index'`
[23:21:21] elaptics: AntelopeSalad: yeah, you can actually get cancan to load the parent up if you used nested resources instead of the way we've just done this
[23:21:29] Valentinial: yes that thank you
[23:21:47] AntelopeSalad: elaptics: do you know offhand if i can get this all to work without nested resources?
[23:22:04] elaptics: AntelopeSalad: with cancan?
[23:22:14] AntelopeSalad: with either or, i'm open for alternatives to cancan if it's superior
[23:22:47] workmad3: AntelopeSalad: I've not played with it much, but I think I do prefer the way it provides separate authorizors for different models (especially as it means you don't need to load in a mass of unnecessary authorization rules that aren't relevant to what you're trying to achieve)
[23:23:42] blackmesa: Radar: I want to access the json object not from a route, but through a variable inside my view
[23:23:47] elaptics: AntelopeSalad: I've mostly been using cancan on recent projects, I plan to use pundit on future projects though I haven't actually used it in anger yet
[23:24:50] blackmesa: when I create a json array from index.json.jbuilder, can I access the json array through a variable in my index.html?
[23:25:00] elaptics: cancan can get a bit unwieldy as the app grows, though there are ways to ease that a bit
[23:25:28] blackmesa: without the need to call it .json in my url
[23:26:10] elaptics: AntelopeSalad: as for whether you can use cancan without nested resources, definitely yes, you'll just have to "manually" authorize it rather than just relying on load_and_authorize
[23:28:16] Radar: blackmesa: Again: i would need to see some actual code myself in order to be able to figure this one out. It's not something that I can easily understand just by having it described to me.
[23:28:18] helpa: blackmesa: Do not beg / plead with people to help you. This includes asking questions like "Any ideas?" after posting your original question.
[23:28:18] Radar: blackmesa: !rule10
[23:28:20] helpa: blackmesa: If you're not getting an answer here perhaps try asking on http://stackoverflow.com Use the tag "ruby-on-rails"
[23:28:20] Radar: blackmesa: !so
[23:29:12] elaptics: AntelopeSalad: you'd do something along these lines https://github.com/ryanb/cancan/wiki/Authorizing-controller-actions
[23:29:42] MrPunkin: Anyone care to tell me where I can find where my /controller/action.js stuff is being cached? Seems to be Rack::Cache or something but its not even hitting my production logs when it requests the js file (that is dynamic based on an ERB template)
[23:29:53] AntelopeSalad: elaptics: thanks, i'll bookmark that for tomorrow
[23:30:35] elaptics: AntelopeSalad: bookmark this one too https://github.com/ryanb/cancan/wiki/Nested-Resources
[23:30:50] elaptics: AntelopeSalad: there's some mentions about polymorphic associations
[23:31:30] AntelopeSalad: elaptics: btw does this seem like a decent refactor or am i way off base? https://gist.github.com/anonymous/7328261
[23:31:32] dukedave: So, I've got two models which have no relation other than a time stamp, and I'd like to get a list of them all in time stamp order. I can do, '(Foo.all + Bar.all).sort_by(&:updated_at)', but I was wondering if there's a (reasonable) way to get the sort done by the (SQL) DB?
[23:32:20] AntelopeSalad: i just realized i didn't use the controller's parent variable names when calling the method but that's an easy fix, is the logic ok tho?
[23:33:01] elaptics: AntelopeSalad: I was about to pick you up on that :)
[23:33:44] AntelopeSalad: i figured it was necessary to make sure it was valid in the model method before creating or failing by returning false
[23:33:48] elaptics: AntelopeSalad: I understand where you're going but you've got way too many conditionals :)
[23:34:03] AntelopeSalad: yeah that's what i noticed, not really sure how to work around that tho
[23:34:27] elaptics: AntelopeSalad: 1 sec, forking your gist
[23:35:49] Valentinial: how do you set root_path to the same page as the "localhost:3000" page the one with the default rails start page
[23:36:43] AntelopeSalad: elaptics: i almost feel like the first bit could be a private method in its own?
[23:37:12] Valentinial: i see all over how to set it to a specific controller but for now i just want the main '/' root with the default page
[23:37:30] elaptics: AntelopeSalad: boom https://gist.github.com/andyh/7328284
[23:38:07] elaptics: AntelopeSalad: not totally sure about raising a record not found but whatever :)
[23:38:07] AntelopeSalad: from 100 conditionals down to none
[23:39:08] AntelopeSalad: that would end up just being a 404 in production right?
[23:39:15] elaptics: AntelopeSalad: exactly
[23:39:36] AntelopeSalad: if someone is messing around then they deserve that
[23:39:47] AntelopeSalad: i have a semi-friendly 404 page too, so it's not too harsh
[23:40:18] elaptics: AntelopeSalad: I'd possibly be inclined to raise something other than record not found because it's not strictly the case, but we want the ultimate effect of a 404 or maybe a 500
[23:41:02] elaptics: AntelopeSalad: if it's an ajax request then they're not going to see owt unless you are dealing with that in javascript. it's just going to sit there otherwise
[23:41:27] elaptics: AntelopeSalad: but if they've messed about with it - they totally deserve to sit there wasting their time :)
[23:41:31] AntelopeSalad: i haven't hooked up the js yet
[23:41:41] AntelopeSalad: it just prepends "foo" to the list of comments
[23:41:55] AntelopeSalad: no flash messages yet
[23:42:28] AntelopeSalad: i could just do an ajax on success/error/complete setup and react accordingly?
[23:42:41] elaptics: AntelopeSalad: yep
[23:42:57] elaptics: and on that note, I ought to get some sleep
[23:43:06] AntelopeSalad: thanks again, now we've really gone from start to finish
[23:43:11] AntelopeSalad: the end result is really great
[23:43:13] workmad3: elaptics,AntelopeSalad: may I humbly submit this https://gist.github.com/workmad3/7328366
[23:43:27] smathy: No, you must do it boldly.
[23:43:29] workmad3: so that you stop having to maintain that list of POLYMORPHIC_ON classes
[23:44:02] AntelopeSalad: workmad3: line 2 of comment.rb will crash if parent_type is invalid
[23:44:20] workmad3: AntelopeSalad: ah, true :)
[23:44:30] AntelopeSalad: that is where i got the idea to have that whitelist array
[23:45:03] AntelopeSalad: you got my hopes up though haha
[23:45:08] elaptics: workmad3: what's your thoughts about raising RecordNotFound? if you've been following the conversation?
[23:45:10] AntelopeSalad: i thought we were going to witness a refactor battle
[23:45:30] workmad3: AntelopeSalad: fixed
[23:45:35] elaptics: workmad3: I'm thinking raising something to result in a 500 is better
[23:45:47] workmad3: elaptics: no, a client error is fine there
[23:46:17] workmad3: elaptics: I might consider introducing my own error, but RecordNotFound is good enough too, IMO :)
[23:46:23] AntelopeSalad: hmm your solution removes the whitelist array but honestly that looks really complicated
[23:46:26] optobear: AntelopeSalad: this will give you nil rather than raising an error - http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-safe_constantize
[23:46:46] AntelopeSalad: i feel like i would need to comment your code so understand what it does 2 weeks from now
[23:47:12] workmad3: AntelopeSalad: the only bit that's really different is the 'reflect_on_association(:comment)' bit
[23:47:15] elaptics: AntelopeSalad: once you're more proficient with ruby workmad3's code makes total sense
[23:47:43] AntelopeSalad: should i use safe_constantize given optobear's link and then remove the rescue bit?
[23:48:23] workmad3: AntelopeSalad: you could do, and then have an 'if parent' line
[23:48:50] optobear: AntelopeSalad: this may work - https://gist.github.com/benmacleod/7328421
[23:49:19] workmad3: AntelopeSalad: and trust me... you're more likely to forget to add a new commentable type to POLYMORPHIC_ON and then spend hours wondering why you're getting a record not found on records that exist ;)
[23:49:30] AntelopeSalad: i think you're right
[23:49:39] optobear: AntelopeSalad: +1 workmad3
[23:49:49] workmad3: optobear: that looks nice :)
[23:50:09] elaptics: yes, and that's one argument for raising your own exception which would point you straight to the source
[23:50:20] optobear: i prefer "refactor collaboration" :)
[23:50:53] workmad3: AntelopeSalad: feel free to add a comment to the line to aid in recall though
[23:50:55] AntelopeSalad: optobear's last solution seems to work
[23:51:06] AntelopeSalad: a valid type submitted fine, and an invalid one just didn't do anything
[23:51:14] AntelopeSalad: (since it's being submit with remote: true)
[23:51:15] elaptics: or even better, write a good commit message :)
[23:51:21] workmad3: AntelopeSalad: I'll admit that line isn't the clearest it could be... but it does reduce future maintenance work too, so you're not likely to need it much
[23:51:47] workmad3: elaptics: true :) good commit message and then 'git blame' the file :)
[23:51:55] AntelopeSalad: really appreciate it guys
[23:52:20] elaptics: workmad3: that's my default workflow now - learnt the hard way :D
[23:52:23] AntelopeSalad: i feel like the implementation has gone from retarded to very nice to amazing
[23:53:54] workmad3: AntelopeSalad: about the only other thing I'd suggest is a s/parent/commentable/ in that code
[23:54:26] workmad3: and maybe 'Comment.create_on_commentable' rather than 'Comment.create_from_commentable' on top of that
[23:55:17] elaptics: AntelopeSalad: , there may be a little tidy up that can be done when you're more sorted with cancan, if you're stick with cancan