« Back to channel list

#RubyOnRails - 02 February 2014

« Back 1 day Forward 1 day »
[00:00:09] RubyPanther: AntelopeSalad: that probably assumes average load, whereas I said "low load"
[00:00:27] RubyPanther: also, listed requirements are likely to be the minimum that they want to have to support ;)
[00:01:00] rushed: Mr920: back tick or system... there are others as well, but make sure that's what you mean to be doing
[00:02:32] dopie: tarted GET "/assets/images/main-bg.jpg" for 127.0.0.1 at 2014-02-01 19:02:16 -0500
[00:02:33] dopie: Served asset /images/main-bg.jpg - 404 Not Found (9ms)
[00:05:00] RubyPanther: AntelopeSalad: note also that a $20 linode VPS comes with 1G now
[00:05:56] RubyPanther: If your web store isn't worth $20/m, you either have "low traffic" or should throw in the towel :o
[00:13:12] dachi_: there's really a bug with sass and rails
[00:13:29] rushed: dachi_: probably several~
[00:14:59] Mosselman: Would I take a big performance hit if I were to save all the params on certain controller actions into a model called `Action` along with some other data like `controller_name, action_name, etc`?
[00:15:43] crazyvipa: Afternoon everyone. I have an extremely odd problem, and I can't trace it to anything. We run multiple servers and only this one app is having a problem. We're using Action Caching with layout: false. However, once and a while, the app ignores(?) the layout: false and caches the entire page. The result is: the entire layout displays twice (2 headers and 2 footers). Any ideas? (Passenger 4, Rails 3.2.14, Dalli/Mem
[00:15:44] crazyvipa: cached) I'm really at a loss here, any help would be awesome. All of our other apps do not do this
[00:16:00] rushed: Mosselman: depends, how long is this piece of string?
[00:16:39] crazyvipa: --- another note: I've moved from jRuby to Ruby 1.9.3 in the event that was the cause, but it decided to happen again. And it does not happen immediately, it seems random
[00:16:41] Mosselman: rushed: a serialize on all params, so it depends on the action really, but some will be very large.
[00:16:47] Mosselman: as in wiki-pages, etc.
[00:29:17] s2013: Could not authenticate you from LinkedIn because "Invalid credentials". <-- anyone ever got this error before?
[00:30:19] amh345: anyone used Dalli for memcaching?
[00:31:23] rhizome: you misspelled "NE1"
[00:32:05] amh345: I'm giving it a quick overlook before i dig in. i want to use it for some brutally slow stats pages. I'm assuming if you're checking a stat that is still being created (current day) the caching isn't of use, no? because it's the day wouldn't be done?
[00:33:02] rushed: s2013: no, but it sounds like it's doing you a favor :P
[00:33:17] amh345: my stats are so insanely slow. like 30 seconds per day. it's destroying my servers CPU too. ultimotely i need to the entire approach rebuilt....AGAIN. but for the time being. i'd like to do some caching.. i think.
[00:33:32] amh345: rhizome: too much reddit for you!
[00:34:33] crazyvipa: amh345: I'd look into your queries first. Possibly missing some useful keys. Caching is useful for something that is going to be seen more than once. I use fragment caching when I know the data could be changed often.
[00:35:04] s2013: https://gist.github.com/ss2k/538b871954849dbd13db this is my code
[00:35:25] s2013: facebook works fine but when i try to sign up through linkedin i get an error
[00:35:50] amh345: crazyvipa: agree 100%. i just have time s of now to have these stats rebut. they are insanely complex and i normally have someone much more experienced work on them. unfortunately that persons availability is not happening right now. which sucks. but it is what it is.
[00:36:11] amh345: so for now. i figure if i can cache long term stats.. for the month kind of thing. it will help.
[00:36:15] amh345: ..i think?
[00:36:38] amh345: these stat pages are hit multiple times every hour.
[00:36:48] rhizome: amh345: by who/what?
[00:36:54] rhizome: and do they really need to be live?
[00:37:05] amh345: yeah. man oh man have i tried to not make them live.
[00:37:21] rhizome: each client has different stats?
[00:37:23] amh345: "these guys are day traders. they're use to checking stats every 5 minutes"
[00:38:00] amh345: yeah, all different stats.
[00:38:19] amh345: there's about 40 different sets of stats right now.
[00:38:27] amh345: and it's growing too fast. :/
[00:38:53] amh345: i honestly never thought my achilles heel would be friggin stats.
[00:39:21] BrianJ: where it says "files to reference" does that mean I need to download them and put them in my assets dir https://github.com/jhollingworth/bootstrap-wysihtml5#files-to-reference
[00:40:21] amh345: so yeah. i posted a job listing on CL (yay!!!) and someone i spoke to said "why not cache them?" and i figured.. hell. it's the only approach we haven't tried yet.
[00:40:48] rhizome: amh345: so you want to cut down number of queries. the dalli page is not encouraging for code quality
[00:42:00] amh345: is it messy? since i can't get this code to be more efficient for the time being. i figure maybe just caching the results would be the way.
[00:42:08] amh345: i mean. anything before today doesn't change in the stats.
[00:42:39] rhizome: i just see those icons. anyway, everything seems to refer to dalli, so there you go
[00:42:53] amh345: right now it's roughly 30 seconds a day. it takes 15 minutes to pull a month. and if you want more than a month? too bad. amazon could only increase my load balancer to a max of 17 minutes.
[00:43:23] rhizome: hah, well my first recommendation would be to get the f off aws if you need performance
[00:43:32] amh345: I'm really pissed about this whole thing tbh. i've spent thousands of my own money trying to make this happen. and it sucks balls everytime.
[00:44:23] amh345: i kind of like aws. well the "cloud". i don't really have experience with many other cloud providers. but my system with them is getting quite involved.
[00:44:36] rhizome: oh, i'm talking colo
[00:44:49] amh345: azure were pestering me for awhile. but they couldn't get a good time to call. so f that.
[00:44:54] rhizome: depends on your spend tho
[00:44:57] amh345: i don't think cool would work in my instance.
[00:45:14] amh345: my problem is i get massive boosts in minutes. and than it drops off.
[00:45:23] amh345: which was i get to schedule .
[00:45:35] amh345: and i can very quickly drop other instances in if i need them.
[00:46:00] rhizome: can they do like "last 49 days" or is it month/3m/6m/1y like finance.yahoo or whatever?
[00:46:07] amh345: i had a site the other day. running on one server. i started to get hammered and ramped up to 6 servers in under 5 mins. in my cool experience.. that wasn't possible.
[00:46:30] crazyvipa: amh345: Run a roll up script like we do here. Have a roll up table that stores the results and pull from that versus raw data on every query. We have affiliate marketing, and we track each and every hit (millions of records) to our system. Every day, we roll up the total amounts and query from this
[00:46:40] amh345: it's exactly like that. they can search any time frame. jan 4- jan 22 for example.
[00:46:58] amh345: luckily we're not doing by hour. yet. I'm going to kill myself if we get to searching by hour.
[00:47:13] rhizome: crazyvipa is talking about denormalization, which is a classical reporting strategy
[00:47:54] amh345: crazyvipa: the rollup idea is a good one.. and in the back of my mind. i have a daily stat that sends out to other providers and for that i have a cron that builds to another table. and it works pretty well.
[00:48:45] amh345: I'm partially tempted to see what i can do with google analytics. i've had major problems with them collecting proper numbers before. but it might be worth a shot.
[00:49:13] crazyvipa: it'll improve performance a lot for you, and immediately at that... just running the initial queries might make you cry... just make some coffee and you're good to go
[00:49:13] amh345: the part that pissed me off is the stat is the only thing i've contracted out. and it's the ONLY thing that's causing me problems.
[00:49:42] amh345: if there is a daily rollup. the slowest stat would be current day. nd that's 30 seconds. i can deal ith that.
[00:50:30] crazyvipa: Question: Are you using MySQL ? If so, run an EXPLAIN <sqL> on the server with a normal query that is run
[00:50:31] amh345: the problem is the stats collect data from around 6(?) tables. and then they need to be grouped and then sub grouped and so on. friggin summaries. all that crap.
[00:50:33] rhizome: how large are your stats objects?
[00:51:15] amh345: the stats themselves (as in stat table) are only 6 cols of data. and a few million rows. but that table alone queries quick.
[00:51:17] crazyvipa: The problem might lie right there honestly... creating the right indexes will go from a 1M+ records read, to 10k
[00:51:34] rhizome: good point
[00:51:51] amh345: it's the other tables. counting customers. then counting customer orders. then grouping what they ordered. then grouping the products. then getting all the summaries.
[00:52:12] amh345: my 1 million records will sum up super fast.
[00:52:16] amh345: it's the other tables.
[00:52:22] amh345: and indexing is done.
[00:52:24] rhizome: you should be doing as much as possible in sql and ruby as little as possible
[00:52:50] amh345: honestly. it's a bad design overall. but after I've had many people look over it. the end result is.. there really isn't another way to set this up.
[00:53:35] amh345: rhizome: originally i had plain ol sql doing the queries. and it was nice and quick. but then i needed to make a change and add a grouping. so the person i hired rewrote it all the "Rails way" which bogged it down to shit.
[00:53:49] rhizome: yep. but you can group in sql :)
[00:53:52] amh345: but what both of you are saying is totally correct.
[00:54:02] ivanskie: guys, is nokogiri, interchangable with hpricot?
[00:54:04] amh345: rhizome: you available for freelance? like right now?
[00:54:33] rhizome: i would love to, but i'm on a crappy hair-on-fire gig at the moment
[00:54:44] amh345: i hear ya.
[00:54:54] crazyvipa: Then the problem lies within the other tables. If you can show some example queries, I can probably let you know if indexes are right. Just because "indexes are set" doesn't mean its optimized @ all. Make sure, if you are searching by DATE and by a CUSTID, have an index, [:cust_id, :datetimefield] -- versus [:cust_id] and [:datetimefield]
[00:55:19] amh345: that's why i posted my CL ad. the people that responded were probably all wtf. i called them back immediately. "are you available right now? for the next 10 hours solid?"
[00:55:29] ivanskie: rather... can I remove hpricot requirement and replace it with nokogiri, without changing any code?
[00:56:00] rhizome: ivanskie: not sure if it'd be drop-in
[00:56:10] rhizome: easy enough to find out :)
[00:56:17] hephaestus_rg: i don't think hpricot has css selectors
[00:56:30] hephaestus_rg: (as an alternative to xpath)
[00:56:39] ivanskie: there's a gem im trying to use, that has requirement for hpricot.
[00:56:40] rhizome: if noko is a superset that might not be a problem
[00:56:53] ivanskie: but its just an access library for an api.. through xml
[00:57:12] hephaestus_rg: you could just do it and see if it breaks?
[00:57:13] rhizome: good luck with all...that
[00:57:42] amh345: crazyvipa: ill go through the model and post some gists.
[01:03:05] amh345: crazyvipa: here is the model i had written. https://gist.github.com/mr-bios/2d9045052b825acc0bc8
[01:03:22] DarkGhost: https://gist.github.com/bmax/8760875 I have a join table.. an dwhen they add a question how come subjecT_id doesn't get added to QuestioNsubjects?
[01:03:55] amh345: that is the bulk of the query slow down.
[01:04:28] s2013: you have a typo DarkGhost
[01:04:37] s2013: has_many :questions, :through => :QuestionsSubject
[01:04:50] s2013: also your spelling
[01:04:54] s2013: capitalization
[01:04:58] DarkGhost: oh I fixed htat to
[01:05:00] DarkGhost: QuestionSubjects
[01:05:22] pontiki: seems like a clear case of using HM:T for a HaBTM
[01:05:36] rhizome: amh345: orders_for seems a prime candidate for optimization
[01:05:49] pontiki: what fields are on your join table questions_subjects, DarkGhost ?
[01:06:02] pontiki: and what are you planning to use it for other than joining?
[01:06:07] DarkGhost: its a reference to question_id and subjecT_id
[01:06:24] s2013: pontiki, are you familiar with omniauth by any chance
[01:06:33] pontiki: not yet, s2013
[01:06:53] pontiki: DarkGhost: then stop trying to reimplement the very fine and useful HaBTM
[01:07:40] amh345: rhizome: what kind of optimization? since i didn't write this my brain hurts trying to figure out some of it.
[01:08:25] DarkGhost: pontiki what is HaBTM? Someone told me to use join table
[01:08:53] ohwhoa: HaBTM = has_and_belongs_to_many
[01:09:03] gringocl: http://guides.rubyonrails.org/association_basics.html#the-has-and-belongs-to-many-association
[01:09:16] pontiki: DarkGhost: I am user someone told you. But you should do you own research. and thanks, ohwhoa
[01:09:24] pontiki: and gringocl
[01:09:43] pontiki: s/user/sure/
[01:09:57] pontiki: it's got all the same letters!
[01:10:50] asteros: hey all, does anybody know if add_template_helper in the mailers are deprecated?
[01:11:08] dachi_: is there a bug with compass / sass too??
[01:11:13] dachi_: rails 4.1
[01:12:12] asteros: hey all, does anybody know if add_template_helper in the mailers is deprecated?
[01:12:25] pontiki: ask again, maybe someone will answer this time
[01:12:29] DarkGhost: i hate this
[01:12:32] DarkGhost: so i just made this whole hting for nothing
[01:12:38] DarkGhost: so i dont need a join table?
[01:12:45] pontiki: you still need a join table
[01:12:50] pontiki: you do not need a join *model*
[01:12:51] asteros: sorry - my IRC client was bugging and i wasn't sure if it was sent out
[01:12:52] DarkGhost: how do I destroy a model
[01:13:31] rhizome: amh345: actually...do you see a lot of queries coming out of these methods at all?
[01:13:49] pontiki: before you destroy anything, DarkGhost, just change your Subject and Question models
[01:13:53] USvER: Anyone experianced with grape? Have question about Nested Resources..
[01:13:57] agent_white: DarkGhost: http://lmgtfy.com/?q=how+to+destroy+model+in+rails
[01:14:09] pontiki: if your join table is called *exactly* "questions_subjects" it will be fine
[01:14:48] crazyvipa: amh345: Sorry, grabbed some food real quick. In any case... are theme methods chained? (I Hope so) For the most part it looks like you search on campaign and a date (created_at) -- I'd start there. [:customer id, :campaign_id, :created_at] would be the most obvious index to use.
[01:15:34] crazyvipa: If you're running a dev environment, trail your dev logs and get the actual SQL Queries. Login to your mysql via command line and run a few EXPLAINs ( http://dev.mysql.com/doc/refman/5.0/en/using-explain.html )
[01:16:24] crazyvipa: You're going to almost certainly find a few "USING FILE SORT" --- which is going to be cause -- and you'll need to figure out where each key should be.
[01:16:29] amh345: hmm. ill check out the indexes.
[01:17:07] crazyvipa: After you figure that all out, you can use fragment caching to store some of the crap that can save some time
[01:17:35] amh345: for caching i was figuring i could cache everything before "today"
[01:17:48] crazyvipa: that'd be harder than its worth honestly
[01:17:51] amh345: as i don't think i can cache and build upon "today". i might be wrong though. still digging in.
[01:17:55] crazyvipa: cache expires and eventuall falls out
[01:18:52] crazyvipa: if you need to cache anything, id just whip up a rollup model -- it'd turn a large # of records into vew few, depending on what you're going to roll up (daily, hourly, monthly etc)
[01:19:18] amh345: rollup is extremely tempting.
[01:19:27] crazyvipa: Its the right answer to all of this honestly.
[01:19:34] crazyvipa: this other stuff is just a quick fix.
[01:19:39] amh345: i could probably knock something out in a few hours... or so.
[01:19:51] amh345: i mean, there's always that one bloody piece that is a pain.
[01:20:13] amh345: rollup would only work on previous days though.
[01:20:14] crazyvipa: Our traffic table is ~74 million records, our roll up is ~1m ... queries to that take miliseconds
[01:20:22] amh345: since i couldn't be doing a rollup every minute.
[01:20:41] crazyvipa: We lag our "today" behind by 25 minutes
[01:21:03] crazyvipa: so "today" is just today... minus 25 minutes, cron job a script to roll it all up every 1/4 hr
[01:21:46] crazyvipa: you could knock it down to even every 5 minutes if needed honestly... just depends on how time-sensitive everything is.
[01:22:30] amh345: id have to find the right timeframe.
[01:22:31] crazyvipa: we run our sync to our nosql db (elasticsearch), Which btw, is another options for you to use)-- every 5 minutes to ensure faceted search counts are correct and all data is intact
[01:22:54] crazyvipa: http://www.elasticsearch.org/
[01:23:10] amh345: the data is critical. per se. it's just there o people feel things are going well. that's it. no decisions are made on a minute by minute basis.
[01:23:24] AntelopeSalad: crazyvipa: are you planning to use karmi's new es gem?
[01:23:46] amh345: alright guys. you've all given me a lot to think about.
[01:23:54] amh345: much appreciated.
[01:23:55] crazyvipa: yes, we are still on Tire atm. Our road map states Q3 is moving to elastic rails gem
[01:24:00] crazyvipa: np amh, and good luck
[01:24:39] crazyvipa: Tire was great, lots of flaws though. Really excited to move to the new gem honestly
[01:24:42] AntelopeSalad: nice, i'm going to make the switch soon
[01:24:54] DarkGhost: pontiki change the models to what
[01:24:57] DarkGhost: hasmany and belongs to?
[01:25:21] AntelopeSalad: crazyvipa: is any of your facet navigation stuff open source?
[01:25:32] AntelopeSalad: i rolled my own but it's pretty ugly haha
[01:26:01] crazyvipa: Sorry. no :( It's owned by the company I work for, though I might eventually rewrite a bit.
[01:26:24] crazyvipa: We did our own as well, but all in all, its hacky, messy, and I'm not happy with it at all. Can't wait to dive into it
[01:27:15] AntelopeSalad: do you have it setup where it's pretty much all manual facet creation code for whatever you want to render?
[01:27:28] crazyvipa: lol, exactly.
[01:27:50] AntelopeSalad: yeah me too, i face palm everytime i look at my code but that's the only way i was able to get it working
[01:28:08] crazyvipa: well, at least I know im not the only one face palming at that code
[01:28:23] AntelopeSalad: i remember karmi once saying he has some ideas to make facet navigation easier with the new gem
[01:28:27] crazyvipa: i keep thinking "nothing to see here, move on, just move on"
[01:28:30] brycesenz: Hi all. I'm having an odd migration/db:prepare error. I'd appreciate any help - https://gist.github.com/anonymous/79fad3bb69ebcda3e218
[01:28:31] AntelopeSalad: but i'm not sure how far off those features are
[01:28:32] crazyvipa: that would... be amazing
[01:28:43] crazyvipa: it looks like the gem is moving, but moving slowly
[01:28:55] AntelopeSalad: yeah i'm just happy it's out tbh, i was waiting for it to come out for months
[01:28:57] crazyvipa: kinda thankful we're waiting till q3, should be more stable and featureful by then
[01:30:47] AntelopeSalad: so with your huge setup, you're just using a background worker to keep your AR db and ES in sync?
[01:31:29] crazyvipa: well, yes & no. the sync is just verifying data
[01:31:54] crazyvipa: i rewrote tires callbacks to kinda do the sync, but in a delayed job mannor
[01:32:27] AntelopeSalad: yeah i think he mentioned to do that in the docs
[01:33:04] crazyvipa: it works better for the admins is all, sometimes the sync gets messy when a user is slammin buttons lol
[01:33:24] pontiki: DarkGhost: https://gist.github.com/tamouse/8761756
[01:34:09] AntelopeSalad: i'm guessing you don't just mass import everything on a regular basis right?
[01:34:39] AntelopeSalad: with facets, i wasn't sure how to keep related names up to date without just forcing a mass import on occasion
[01:34:40] DarkGhost: ok thanks pontiki then what was I doing
[01:34:42] DarkGhost: with the join table?>
[01:34:50] DarkGhost: if :subjects is a checkbox with that .create still work pontiki?
[01:35:04] pontiki: DarkGhost: do you understand the difference between a join *table* and a join *model* ?
[01:36:06] DarkGhost: a ssmall grasp... do I have to create a table questions_sbuejcts ?
[01:36:29] pontiki: DarkGhost: do you already have one?
[01:36:34] DarkGhost: no I have QuestionsSubjects
[01:36:39] DarkGhost: when I made a new model it created it
[01:36:43] s2013: Radar, are you here?
[01:37:02] DarkGhost: oh it was named
[01:37:04] DarkGhost: question_subjects
[01:37:12] DarkGhost: FROM "question_subjects"
[01:37:24] pontiki: what is in your schema.rb file?
[01:37:25] DarkGhost: i need to drop that and the model
[01:37:44] pontiki: [20140201|1914.08] < pontiki> if your join table is called *exactly* "questions_subjects" it will be fine
[01:38:02] DarkGhost: http://privatepaste.com/527d6549ee
[01:38:30] brycesenz: pontiki - I want to buy you a beer just reading this.
[01:38:45] pontiki: make it a cider
[01:38:58] pontiki: DarkGhost: have you worked a full rails tutorial yet?
[01:39:01] DarkGhost: well its not named exactly that!
[01:39:17] pontiki: then stop whatever you are doing and do so
[01:39:20] brycesenz: done. seriously - if you have a buy-me-a-cider button, i'll get on it now.
[01:39:33] DarkGhost: you have one in particular?
[01:39:50] pontiki: rails.railstutorial.com
[01:40:31] crazyvipa: Hartl's tuts are awesome. Worth every penny. It's how i got into RoR in the first place
[01:40:34] pontiki: and re-read and re-re-read the guides
[01:40:49] pontiki: the text is free
[01:41:31] crazyvipa: Videos are better, imho. The book was a good reference after the fact -- but does a great walkthrough
[01:41:32] DarkGhost: want to help me get this one working real quick tho? all I need is a table named questions_subjects and I think it willwork
[01:41:50] brycesenz: DarkGhost - yeah man, I'm stoked that you're getting into Rails, and it's great that you're enthusiastic, but it feels like you're maybe trying to run before you can walk a bit. Those guides/walkthroughs will help you a lot.
[01:42:11] DarkGhost: well I figured I know php well I could just jump into rails
[01:42:12] DarkGhost: but not at all
[01:42:12] pontiki: the table *must* be named 'questions_subjects'
[01:42:17] DarkGhost: http://ruby.railstutorial.org/
[01:42:36] DarkGhost: yes I know pontiki i just don't know how to drop this old table and make a new one named questions_subjects.. I know making a model makes a table as well
[01:42:40] DarkGhost: Im use to using phpmyadmin
[01:42:43] pontiki: php is comparable to ruby, NOT rails
[01:42:59] DarkGhost: did you mean ruby.railstutorial.com ?
[01:43:04] pontiki: probably :)
[01:43:13] DarkGhost: ill read through it
[01:43:19] crazyvipa: Dark: The only thing PHP helped with me in Rails, was understanding the terms devs use
[01:43:22] DarkGhost: i just really want to see this question subjects thing working
[01:43:23] AntelopeSalad: DarkGhost: previous programming experience and being familiar with patterns that rails uses will help but it will be close to impossible to just jump in
[01:43:29] crazyvipa: Model, View, Controller, Asset, Database, etc
[01:43:47] pontiki: symfony is comparable to rails
[01:43:50] AntelopeSalad: there's just too much stuff that's rails specific knowledge but then once you know it, you'll wonder how you spent your life without them
[01:44:21] crazyvipa: Anyways -- I'm going to shout out a repeat Q I had earlier, seems people are getting on now.
[01:44:23] crazyvipa: I have an extremely odd problem, and I can't trace it to anything. We run multiple servers and only this one app is having a problem. We're using Action Caching with layout: false. However, once and a while, the app ignores(?) the layout: false and caches the entire page. The result is: the entire layout displays twice (2 headers and 2 footers). Any ideas? (Passenger 4, Rails 3.2.14, Dalli/Memcached) I've moved f
[01:44:23] crazyvipa: rom jRuby to Ruby 1.9.3 in the event that was the cause, but it decided to happen again. And it does not happen immediately, it seems random. I'm really at a loss here, any help would be awesome. All of our other apps do not do this
[01:45:11] tubbo: crazyvipa: what would make you think moving ruby versions was the cause?
[01:45:15] pontiki: i am unfamiliar with Action Cache
[01:45:35] crazyvipa: tubbo: That was the ONLY difference between our other servers.
[01:45:39] AntelopeSalad: that's one of the more obscure bugs i've ever seen
[01:46:31] crazyvipa: I've updated all the rails apps to the same version, memcache across the board is the same now, traffic is comparable, passenger is the same
[01:46:41] crazyvipa: ruby is now, across the board, 1.9.3
[01:46:49] tubbo: crazyvipa: oh wait so it's not the same app on each server?
[01:47:18] pontiki: oh i see, it's gotten pulled out for Rails 4
[01:47:40] crazyvipa: tubbo: correct, we have multiple apps :) This specific app is being run on 2 servers being load balanced by edgecast
[01:48:51] DarkGhost: can i just do this rails g migration CreateJoinTableQuestionSubjects question subject for a jointable
[01:49:33] DarkGhost: that will work with the HaBT
[01:49:41] DarkGhost: (before i read this book of course lol)
[01:49:51] pontiki: crazyvipa: so like i said, i'm not really familiar. I just read this warning on the README page: "Warning: If the format of the request is determined by the Accept HTTP header the Content-Type of the cached response could be wrong because no information about the MIME type is stored in the cache key. So, if you first ask for MIME type M in the Accept header, a cache entry is created, and then
[01:49:57] pontiki: perform a second request to the same resource asking for a different MIME type, you'd get the content cached for M." -- does that apply?
[01:50:39] crazyvipa: Honestly.... that could very well be it, holy shit.
[01:50:42] pontiki: DarkGhost: it's simple enough to just try it and see, isn't it? Generate the migration, then open the resulting file and look
[01:51:03] crazyvipa: We get, from time to time, hack attempts, requesting the home page is say... and Image
[01:51:27] crazyvipa: maybe it just so happens its trying to recache
[01:51:51] rhizome: maybe consider moving to russian doll caching in the future :)
[01:52:13] crazyvipa: rhizome: We do :) We use fragment caching. But, in case you are curious....
[01:52:20] brycesenz: Oh, ok, I think I found the source of my error - somehow, my schema_migrations table was completely lost. When is that table typically created in Rails, and how might it have been dropped?
[01:52:42] crazyvipa: Response times from UK To US: With action caching averaged 100ms
[01:52:58] crazyvipa: Without action caching (using fragment / russian doll), it hits 500-600ms
[01:54:07] AntelopeSalad: crazyvipa: have you ever messed around with varnish to avoid hitting rails entirely?
[01:54:38] Tokenizer: is there a cleaner way to do whati'm doing in that many lines in this paste? i.e. do it in one or two lines? http://pastie.org/private/qzyclndjj02gkd3wowtxa
[01:55:22] crazyvipa: AntelopeSalad: Nope, but I'm going to go google now and research it a bit -- as long as it can keep the user's state, that could be a very good place to start
[01:55:54] AntelopeSalad: crazyvipa: there was an excellent talk about it from the disqus guys, but it should be applicable to rails
[01:56:00] crazyvipa: This it? https://www.varnish-cache.org/
[01:56:03] rhizome: hadn't heard that about response times
[01:56:24] AntelopeSalad: crazyvipa: yeah
[01:56:56] crazyvipa: rhizome: It was seriously a surprising test result to say the least. To be honest, it was only about a 25% increase in performance... but with millions of requests, 25% is a lot.
[01:57:28] rhizome: Tokenizer: any particular reason you only want the body?
[01:58:00] tubbo: crazyvipa: you can also use redis-rails and rack-cache as an http cache similar to varnish
[01:58:03] tubbo: it's very easy to set up
[01:58:07] Tokenizer: rhizome: yes it's to be used as a proper for SunspotSolr
[01:58:43] AntelopeSalad: tubbo: with the varnish setup you never even touch rack tho
[01:59:00] AntelopeSalad: your app won't even know it got a hit
[01:59:13] rhizome: Tokenizer: but not indexing it directly by attribute?
[01:59:13] tubbo: crazyvipa: it's an http-level cache but exists at the rack app level. varnish, iirc, sits a little further up the stack if actually getting into Ruby is a big deal for you. it's never been too much of an issue for me. the great thing about using redis is you can use it for ALL client-side storage, so you can use it to store the session as well as the rails fragment cache.
[01:59:44] rhizome: Tokenizer: you want an array of arrays?
[02:00:00] tubbo: AntelopeSalad: like i said, it's never been a big deal for me. the ruby is not where my requests spend the bulk of their time, i've found.
[02:00:24] Tokenizer: rhizome: to be precise, here they have an example under "Setting up objects" right at the top almost https://github.com/outoftime/sunspot .... the example is for :comments.... they use a map, I want to do the same, but my property is the aggregation of children of children of an object
[02:00:28] tubbo: big two offenders are 1.) external services, 2.) the database
[02:00:56] AntelopeSalad: tubbo: depends on his traffic, disqus' traffic is a bit different than most people haha
[02:01:16] tubbo: AntelopeSalad: agreed. is that what we're talking about here?
[02:01:49] AntelopeSalad: nope, i don't know what his traffic is like, i just happened to come on when he was talking about ES
[02:02:19] AntelopeSalad: but the difference between varnish serving a request and going through rack is going to be massive, that is for sure
[02:02:26] rhizome: Tokenizer: so comments as a key on the Answer corpus
[02:02:29] tubbo: AntelopeSalad: not if that's not where your problem is.
[02:02:30] AntelopeSalad: even for a simple hello world with no io
[02:03:00] tubbo: if you have a simple hello world with rails obviously your problem is the ruby because it doesn't hit a database. so make it a static html app, problem solved. ;)
[02:03:10] Tokenizer: rhizome: comments as a key on Questions ....  where it comes from is "question.answer.comments"
[02:03:14] tubbo: all of these problems are solved in different ways given a certain "vantage point"
[02:03:35] tubbo: i build my apps with $TOOL because of $CONSTRAINTS.
[02:04:04] AntelopeSalad: tubbo: the talk i watched intelligently cached results so that they could be treated as static pages even tho they were not
[02:04:07] tubbo: AntelopeSalad: but varnish is problematic. it's an external service, which means you have to figure out how you're gonna get it on the box, keep it up when it crashes, configure it so it works for you, etc.
[02:04:17] rhizome: Tokenizer: gotcha, well you can answers.collect { |a| a.comments.collect(&:body) } with maybe a flatten in there if the array doesn't suit you
[02:04:18] s2013: tubbo, you ever used omniauth?
[02:04:34] Tokenizer: rhizome: ** collect... ya that'll do thanks
[02:04:44] tubbo: AntelopeSalad: so is redis, but it can be used for more than just a cache.
[02:04:45] rhizome: collect or map, they're the same
[02:04:51] tubbo: s2013: yep
[02:04:54] AntelopeSalad: tubbo: disquss is using it right now to serve 8 billion+ reqs a month and in theory it could be ran off 2 varnish servers, i'm not worried about varnish crashing :o
[02:05:07] tubbo: s2013: https://github.com/waxpoetic/forthcoming
[02:05:08] s2013: https://gist.github.com/ss2k/538b871954849dbd13db i keep getting Could not authenticate you from LinkedIn because "Invalid credentials".
[02:05:10] s2013: any clue?
[02:05:31] tubbo: AntelopeSalad: i would be. it's serving 8 billion requests. better have monit installed/configured for it, and better have nagios alerts for problematic events.
[02:05:43] tubbo: AntelopeSalad: hopefully, you'll never need them!
[02:05:55] AntelopeSalad: i'm sure they have good reporting tools, i don't work there to confirm but i'll give them the benefit of the doubt
[02:05:55] rhizome: Tokenizer: you can replace everything with that, btw. def something will return the array from that
[02:06:10] tubbo: s2013: i've actually never used devise w/omniauth, just bare omniauth. making a facebook app.
[02:06:24] s2013: my facebook login thing works, just not linked in
[02:06:27] s2013: and its frustrating as hell
[02:06:31] tubbo: i upload a track, you hit the button and it makes you like my page, then you can download my track :)
[02:06:41] tubbo: s2013: yeah i've never worked with linkedin tbh. they're ALL different..
[02:07:04] s2013: i was able to do linkedin without devise before as well but no clue why its not working with devise
[02:07:15] tubbo: AntelopeSalad: well given that neither of us know what the fuck we're talking about wrt disqus...let's assume they have a proper infrastructure team. i'm sure if they DO use varnish, they definitely have systems in place for failover.
[02:07:29] AntelopeSalad: there are all sorts of cute tricks you can do like cache an entire action/view for 5 seconds, set the correct http headers and then have varnish serve the page without ever touching rails
[02:07:58] tubbo: AntelopeSalad: just like you would if you required RabbitMQ. RabbitMQ is a *far* superior msg queue than Redis/Resque, but it's also harder to set up and is way more than what people need for 80% of cases.
[02:07:58] AntelopeSalad: of course it gets more complicated with users/cookies but you can get around that stuff too to some extent
[02:09:11] tubbo: varnish is a really good cache, don't get me wrong
[02:09:29] tubbo: it's pretty much the industry standard in that department, in use by practically everyone on that level...languages aside.
[02:09:54] AntelopeSalad: yeah, i'm not saying i would use it for a personal blog with 12 hits a month
[02:10:29] AntelopeSalad: but he was talking about a 75 million ES document setup at his place of work, i imagine we're dealing with some amount of decent traffic heh
[02:13:32] USvER: How do i set a variable on a class and then pass it as options to the block?
[02:14:10] USvER: Will do gist...
[02:15:38] Tokenizer: rhizome: thnks
[02:17:24] USvER: Can someone help me with this? https://gist.github.com/USvER/3fbb672e91af544529b3
[02:34:35] tubbo: USvER: does this work? https://gist.github.com/tubbo/24087b3a350581f493cc
[02:35:24] tubbo: USvER: but...i question why you want to do this. aren't there pattern matching capabilities in the route there?
[02:36:25] USvER: in the end i need to get this "put "/", :rabl => "v1/excursions" do"
[02:37:03] USvER: i'm new to ruby
[02:37:14] tubbo: USvER: ah okay, well you want to do `get(*options) do ... end` then, and return a [ '', {} ] from that options method.
[02:37:37] USvER: tubbo: ah ok
[02:37:43] tubbo: USvER: you might've been having trouble because you were trying to reference options on the class level, so you needed to define a class method instead of an instance method which is what you had.
[02:37:46] USvER: tubbo: testing
[02:39:16] nahtnam: Hey guys, I made the small mistake of using mysql, and would like to switch to postgres. I know how to update rails to use it, but I installed devise and its connected to mysql. How would I switch devise from mysql to pg?
[02:39:42] tubbo: nahtnam: you have to convert all the data over, first of all.
[02:40:11] nahtnam: tubbo: Thankfully, I have no data
[02:40:13] nahtnam: just dummy stuff
[02:40:22] nahtnam: I just want to migrate the db to pg.
[02:40:29] tubbo: nahtnam: oh good, just drop your database and recreate it. the migrations should set you up with the new db
[02:40:30] nahtnam: Would it be as simple as rake
[02:40:57] nahtnam: tubbo: Ok, so ill swap out the mysql gem with pg and then rake db:migrate?
[02:41:04] USvER: tubbo: uninitialized constant
[02:41:08] tubbo: nahtnam: yeah, you're all set up with rails to use pg right? so just `rake db:create db:migrate` and you'll be fine.
[02:41:15] helpa: USvER: To add a file to a Gist, click the "Edit" button then scroll down to the bottom of the page and click "Add another file...".
[02:41:15] tubbo: USvER: !addfile
[02:41:25] tubbo: USvER: add the whole error to your gist
[02:41:50] nahtnam: tubbo: Wow that makes life so easy :)
[02:41:54] nahtnam: With php is HELL
[02:41:56] tubbo: nahtnam: you need the pg gem in there :)
[02:42:03] nahtnam: tubbo: I know
[02:42:10] tubbo: nahtnam: oh, and you need to edit database.yml
[02:42:19] tubbo: but otherwise yeah you're good
[02:42:19] nahtnam: tubbo: Yep
[02:42:24] tubbo: this is why AR is nice :)
[02:42:55] nahtnam: tubbo: I know what to do :P I had to switch from sqlite to mysql, and now I have to switch from mysql to pg and was just wondering if the process was the same.
[02:43:07] tubbo: nahtnam: oh yeah, definitely.
[02:43:14] nahtnam: tubbo: Do you have a bitcoin address?
[02:43:21] nahtnam: I feel like being nice
[02:43:21] tubbo: lol i think so
[02:43:27] nahtnam: I just recently got 0.15 for free
[02:44:46] USvER: tubbo https://gist.github.com/USvER/3fbb672e91af544529b3
[02:46:37] USvER: tubbo i'm changed "options" to TEST because options is reserveed
[02:46:52] jackyalcine: AR removed the need for so many people to learn SQL D:
[02:48:02] USvER: jackyalcine and created a need for workarounds?
[02:48:03] tubbo: i'm not sure how you'd use AR effectively without knowing SQL...
[02:48:51] tubbo: USvER: uhh...you can't define methods in uppercase like that. ruby will think it's a constant.
[02:49:24] tubbo: USvER: you should probably learn a bit more about how ruby works before attempting to build APIs with it, fwiw.
[02:49:26] USvER: tubbo: =\ reserved words, constants =\ so much conventions
[02:51:05] tubbo: USvER: ruby's pretty easy to grasp once you know its conventions. i feel like they're very straightforward. give the ol' pickaxe a read to see how ruby works, and why it works the way it does.
[02:51:34] USvER: tubbo: ok, your code works :D
[02:51:40] tubbo: USvER: boom
[02:51:41] USvER: tubbo: thnk you
[02:52:05] USvER: tubbo: made my code dry :D
[02:53:09] USvER: tubbo: "*" before function means byRef?
[02:53:39] tubbo: USvER: look it up.
[02:53:43] tubbo: that's your homework.
[02:54:01] USvER: tubbo: i don't even know where to look
[02:54:08] helpa: USvER: http://rubycentral.com/book - Programming Ruby is a free online book on Ruby.
[02:54:08] tubbo: USvER: !pickaxe
[02:54:16] centrx: USvER, It is called the "splat operator"
[02:54:25] USvER: ah.... thanks
[02:54:33] tubbo: USvER: it's a little outdated but you'll get a smattering. and yeah, it's called the "splat"
[02:54:38] USvER: centrx: will learn it thanks
[02:57:15] tubbo: welp, guess i need to change my nickserv password now :P
[02:57:31] CarolinaY: be careful! :P
[02:58:21] tubbo: should've been changed a long time ago fwiw
[02:58:28] tubbo: that's an old, old password that i never cared about
[03:00:58] nahtnam: tubbo: Devise right now is doing this. <%= f.label :password %>. The result is <label for"...">Bla Bla</label>. Is there any command/function I could use to just paste the "bla bla" without the label tags?
[03:01:29] tubbo: nahtnam: did you generate devise:views?
[03:01:36] nahtnam: tubbo: Yep
[03:01:59] nahtnam: Im editing some files and the label tags are messing up some css
[03:02:43] tubbo: nahtnam: well, you can just get rid of the f.label lines..
[03:03:20] nahtnam: tubbo: Yes, but I still want to display "bla bla"
[03:03:28] pontiki: you can just display that
[03:03:32] tubbo: heh, yeah
[03:03:33] nahtnam: pontiki: How?
[03:03:40] tubbo: <p>bla bla</p>
[03:03:41] pontiki: do you know html?
[03:03:53] tubbo: nahtnam: might have to hard-code this one
[03:04:05] nahtnam: No, but I want it multilingual
[03:04:30] pontiki: then just <%= t('bla.blah') %>
[03:04:44] tubbo: nahtnam: ah i see, yeah ^^ you just need to know the right message to display.
[03:04:47] pontiki: and put the phrase in the locale file
[03:05:06] tubbo: there should be a config/locales/devise.en.yml you can look at
[03:05:13] nahtnam: pontiki: There is already a locale file generated by devise
[03:05:22] nahtnam: Oh BTW tubbo I sent you some
[03:05:58] nahtnam: There is already a local file and I just want to paste the data from it.
[03:06:29] pontiki: yes, just use the locale identifier
[03:07:05] tubbo: nahtnam: yeah, if your yaml is like devise: \n\t messages: \n\t\t whatever:...it would be represented in t() as 'devise.messages.whatever'
[03:08:30] nahtnam: tubbo: Wait now Im confused. There is no password thing in the locale file. Where is Devise getting <%= f.label :password %> from?
[03:09:42] pontiki: i think f.label autogenerates it
[03:09:53] pontiki: you can pass an alternative string for f.label
[03:09:54] nahtnam: Oh. Well I found this online. <%= f.object.class.human_attribute_name :remember_me %>
[03:09:56] nahtnam: It seems to work
[03:09:58] tubbo: nahtnam: right, so you'd just need to do <p>Password</p>
[03:10:05] nahtnam: <%= f.object.class.human_attribute_name :remember_me %> works
[03:10:16] nahtnam: I have to go somewhere right now
[03:10:22] nahtnam: Ill talk to you guys later
[03:10:22] tubbo: nahtnam: :password might...give it a shot. it's not *really* an attr on User though
[03:10:32] tubbo: wouldn't count on it
[03:10:54] pontiki: there's some magic involved in that
[03:11:22] jcutrell: Hey folks. Got a question about the nested_form gem - http://pastie.org/private/1qzxhleu6ei2gitxm8tbiq - wondering how I can go about having dynamic labels for the second and subsequently added nested fields.
[03:11:35] pontiki: devise models have these pseudo attributes of password and password_confirmation
[03:11:55] pontiki: what's stored in the table is password_encrypted
[03:12:13] jcutrell: The example I have there shows two instances of f.fields_for :people; this isn't working unfortunately.
[03:13:15] jcutrell: The attributes on the Person model are the same for the first and second instances, but the labels need to change (to indicate that you are adding a different person other than yourself)
[03:13:17] crazyvipa: jcutrell: What are you trying to accomplish ?? If they are creating an account, the 2nd one will not work
[03:13:32] USvER: tubbo: is it possible to mount same engine multiple times?
[03:14:41] jcutrell: crazyvipa: The basic idea is that the account represents a collection of people, but whoever the first person is that creates the account is transparently creating themselves as the first person on the account. The form needs to support adding a second person as well. The fields are the same, but the context is different.
[03:15:08] crazyvipa: jcutrell: Also, "people" can not be used twice. You'll need to give the has_many :people an alias / type. Such as has_many :family_members, through: :people, conditions: ['type = ?', 'Sister']
[03:15:20] jcutrell: The nested_form does this dynamic adding of a new nested instance perfectly fine
[03:15:41] jcutrell: People is agnostic - it's a person model. The account has_many :people
[03:15:52] USvER: tubbo: i want to use same engine as standalone api endpoint and as nested resource
[03:16:10] USvER: tubbo: is it possible?
[03:16:14] crazyvipa: Yes, but the account has the "owner" who has many "family members", correct ?
[03:16:33] jcutrell: The account just has_many people - the family member part is just semantics.
[03:16:40] jcutrell: No need to track what type of family member. :)
[03:17:10] jcutrell: The account owner is one of the many :people associated with a given account.
[03:17:40] jcutrell: In any case, all I need is to be able to check if the nested fields have been added, or if they are the ones that are visible on initial load,
[03:17:54] jcutrell: so I could add a little switch variable... but that sounds really gross.
[03:18:11] tubbo: USvER: i don't know
[03:18:15] tubbo: never tried it
[03:18:18] USvER: tubbo: If i do mount twice i get only one of the endpoints working =\
[03:18:27] tubbo: USvER: guess not :)
[03:18:28] crazyvipa: Ok, as far as I know, this isn't available (I used nested forms also). You'll need an alias to have multiple fields_for :people, short of writing code within the form which could turn ugly, tho maybe a use of a helper to determine labels name might work
[03:18:40] USvER: tubbo: =\
[03:19:39] tubbo: USvER: i think that has to do with mounting in rack itself.
[03:19:43] USvER: tubbo: that's sad... because it means douplicating the endpoint =\
[03:19:59] tubbo: USvER: well...let's just say there was a better way of doing what you're doing. :)
[03:20:21] tubbo: USvER: if so, then you wouldn't need to route the engine twice!
[03:20:21] USvER: tubbo: what is that?
[03:20:27] tubbo: i'm saying hypothetically
[03:20:51] tubbo: USvER: like for example, i don't think you can actually mount the same rack app twice.
[03:21:35] tubbo: USvER: you built this API in Grape, right? perhaps if you built the API with Rails controllers, it would be easier to route the same controller to two different endpoints.
[03:21:38] jcutrell: crazyvipa: Model-specific helper sounds like a good option.
[03:21:57] USvER: tubbo: so i have Assets, and have Post with Assets as subresource... Assets code would be almost the same
[03:22:17] tubbo: USvER: what's Assets?
[03:22:28] USvER: tubbo: files
[03:22:32] crazyvipa: jcutrell: After a few seconds of thought, I'm going to agree. That is the best option, and refactor later if needed
[03:23:18] USvER: tubbo: Images\PDFs\archives... user uploaded files
[03:23:29] tubbo: USvER: ok. seems like it might be better to make an AssetsController (be careful, not sure how this works if you use Sprockets!) and just route that beneath /posts as well as directly /assets.
[03:23:50] tubbo: so you'd have /assets and then you'd have /posts/1/assets
[03:24:02] USvER: tubbo: yes
[03:24:06] pontiki: jcutrell: when you build your person records, is there some identifier at that point to distinguish "owner" and "family member"?
[03:24:16] tubbo: USvER: seems like using a controller would be the best tool for the job.
[03:24:25] USvER: tubbo: will try it
[03:24:29] USvER: tubbo: thank you
[03:24:33] tubbo: no problem
[03:24:37] pontiki: jcutrell: does that distinction ever get made?
[03:24:40] jcutrell: Relatively unnecessary to have the distinction for the application /\ pontiki
[03:24:55] pontiki: then why do you need to distinguish them in the form?
[03:25:01] pontiki: i'm probably not getting this
[03:25:43] pontiki: when i have multiple nested objects, i just build them onto the main object, and let f.fields_for run through them
[03:25:47] jcutrell: pontiki: Usability reasons. When the user is signing up, they are doing so just after choosing something to register either themselves or their child for; if we show them a form only with fields for their own self, they likely will still be thinking about registering their child.
[03:26:01] jcutrell: So we need to offer more explicit options so they don't get confused about what the form is asking for.
[03:26:15] crazyvipa: pontiki: I don't know why he'd need the form to be any different either, which is why I assumed owner / family member relations, lol. I assume its due to UX rather than actual programming
[03:26:37] pontiki: then your application *does* have a reason to distinguish them
[03:27:17] jcutrell: They are distinguishable by their names naturally.
[03:27:27] pontiki: not to your application
[03:27:56] jcutrell: I'm not sure I understand why the application would need to distinguish them?
[03:28:17] pontiki: you just said it did, so the user will know when to put in their own info, and when to put in their child's info
[03:28:46] jcutrell: Right, it's simply a display issue; the fields are the same, and the classification is the same from a data perspective.
[03:38:48] kies: if im going to delete a model association, whats the best way to nullify any reference to the deleted model? before_destroy filter?
[03:40:16] tubbo: kies: has_many :associated_models, :dependent => :destroy
[03:40:23] iliketurtles: i am experiencing a super weird error that seems to have come up overnight: with bootstrap-sass and a rails 4.0.2 project, I have @import 'bootstrap' in my application.css.scss file. when I try to use a mixin, like @include scale(0); I see Sass::SyntaxError at / () isn't a valid CSS value.
[03:45:06] iliketurtles: anyone have any ideas on that? ^
[03:52:11] kies: sweet thanks tubbo
[03:52:31] kies: iliketurtles, is that a compass mixin?
[04:37:50] nahtnam: tubbo: You there?
[04:55:28] emeve89: will textmate 2 be always free?
[04:56:29] rushed: emeve89: the source for the current version is on github
[05:15:44] iliketurtles: kies: its from bootstrap-sass, so yes
[05:17:04] Radar: good morning everyone.
[05:17:55] kies: try importing compass first iliketurtles
[05:20:50] chrisbolton: Opinion? I'm creating a quick tictactoe app. User has_many games. Game has_one x_player && has_one o_player. Easy enough but how to track moves per game? My original thought was to keep them on the Game. Having something like a hstore column which stores an array of positions taken #=> x_player_moves = [1,5,9], o_player_moves = [2,4,8]
[05:21:08] iliketurtles: kies: i've never had to do that before -- just upgraded from boostrap-sass 3.0 to 3.1 and i dont see such instructions in their github
[05:21:27] iliketurtles: perhaps its a bug :\
[05:25:02] Radar: iliketurtles: Hello! Can you reproduce on a new app?
[05:25:26] iliketurtles: Radar: I'm going to make sure we get that embossed on your tombstone :P
[05:25:39] iliketurtles: (as it is a good suggestion).
[05:25:41] iliketurtles: going to try now
[05:26:17] Radar: Good debugging tactic. Reduces possibilities.
[05:32:59] iliketurtles: Radar: sadly no, can't reproduce in a brand new app; guess its something in my app
[05:33:55] iliketurtles: time to start removing shit :P
[05:35:51] iliketurtles: Radar: OH wait.
[05:35:56] iliketurtles: actually CAN reproduce in a new app. woot
[05:35:58] Radar: ACTION waits
[05:36:11] iliketurtles: will post it along with my issue on bootstrap-sass github
[05:37:22] nahtnam: Do you guys prefer mysql or pg and why?
[05:38:49] iliketurtles: nahtnam: a lot of people go with pg because of the platform they deploy on *coughherokucough* but in my experience with seasoned dev-ops engineers they prefer mysql for very large projects
[05:39:35] RubyPanther: in my experience that is nonsense
[05:39:46] iliketurtles: RubyPanther: which?
[05:39:48] nahtnam: I have the option between both
[05:39:54] RubyPanther: I love how the pg engineers are "people" and the mysql engineers are engineers
[05:40:10] iliketurtles: hah well didn't mean it that way -- i know plenty of large-scale apps that use postgres
[05:40:25] RubyPanther: in my experience people who care about RDBMS features use pg, and people who just need a persistent data store that uses SQL use mysql
[05:40:38] agent_white: Everyone is migrating to PG/etc. since they began to close the mysql source.
[05:41:01] nahtnam: agent_white: Oh kk
[05:41:20] RubyPanther: the latest pg has writable views and so you don't even need triggers/rules to use views as AR models
[05:41:22] nahtnam: Im a ui guy (im really newbie at terminal), so I just installed phppgadmin
[05:41:54] RubyPanther: and if you decide to go crazy inside the db, there is PL/Ruby language
[05:42:52] agent_white: nahtnam: Aye. It was relicensed from the GPL.
[05:43:00] RubyPanther: the really big mysql users like google don't use the version you can download, either, they use their own proprietary fork
[05:43:17] Radar: For once I agree with RubyPanther.
[05:43:29] nahtnam: I have spent around 3 years on mysql
[05:43:35] RubyPanther: Radar: every 13 months, like the Blue Moon
[05:43:42] Radar: pretty miuch
[05:43:51] nahtnam: How hard would it be to learn how to learn how to use pg?
[05:43:58] agent_white: nahtnam: If you
[05:44:06] agent_white: If you're familiar with neither, then not hard :)
[05:44:22] nahtnam: I have been using mysql for around 3 years now
[05:44:31] mmun: <3 hstore
[05:44:32] nahtnam: I am working on a new project in rails
[05:44:37] nahtnam: I need to decide
[05:44:49] agent_white: nahtnam: How often do you really use the DB internals?
[05:44:58] agent_white: If you're writing queries in Rails?
[05:45:04] nahtnam: agent_white: For this one project?
[05:45:13] nahtnam: Or how much I have used.
[05:45:32] agent_white: nahtnam: If you have to think about it, then it probably doesn't matter too much. I would just use PG and see how it goes.
[05:45:41] nahtnam: https://developers.google.com/cloud-sql/
[05:46:18] nahtnam: agent_white: Well for mysql there is phpmyadmin ui, which is really useful and lets me see if something has been inserted really quickly
[05:46:35] nahtnam: and then there is phppgadmin which quite frankly looks like shit
[05:46:44] nahtnam: But Ill try pg and see how it goes.
[05:46:53] nahtnam: I dont plan on using heroku
[05:47:03] nahtnam: I will be having my own vps hosted on google cloud
[05:47:06] agent_white: nahtnam: *shrug* There's plenty of UI tools if that's your concern.
[05:47:06] RubyPanther: nobody uses heroku lol
[05:47:47] nahtnam: agent_white: Anything that looks OK and is fast (unlike JIRA). Do you have any suggestions besides phppgadmin?
[05:48:32] RubyPanther: if you're not using db-specific features the only differences are setting up the db users and security, and RAND() vs RANDOM(), which is rarely used but sometimes for ordering
[05:49:24] nahtnam: So, final verdict. Pg or sql?
[05:49:26] elliotec: hey guys, i'm getting a 'param not found' error on a strong param i'm requiring. it can't find it, but i don't even know where to go to look for it and find out why
[05:49:28] nahtnam: I mean mysql
[05:49:31] agent_white: nahtnam: Unfortunately I don't use UI frontends for services, couldn't tell ya... only the general Nagios, which you may want to look into for your vps.
[05:49:59] nahtnam: RubyPanther: What do you think.
[05:50:19] nahtnam: agent_white: On my production servers I wont install any ui. Just on my local machine to help me speed up my process
[05:50:28] RubyPanther: other than nagios, I only use the cli :o
[05:52:37] RubyPanther: I think pgAdmin is what people are using now
[05:53:02] agent_white: Yeah shit, on their site: http://wiki.postgresql.org/wiki/Community_Guide_to_PostgreSQL_GUI_Tools
[05:53:20] agent_white: Pick and choose the eyecandy
[05:53:49] RubyPanther: when Oracle buys OSS, you can expect it to die
[05:55:07] agent_white: And then Oracle will begin putting us all on trains saying we are begin relocated...
[05:55:43] rushed: anyone know what sass's version of less's e() function (to pass a raw string through to the result) is?
[05:58:19] jackyalcine: you mean a mean of interpolation?
[05:58:34] jackyalcine: like $foo: 'bar'; $baz: #{$foo};
[06:00:14] nahtnam: After all this, I still might go with mysql.
[06:00:21] nahtnam: Some of my project may be open source
[06:00:37] nahtnam: I dont think many people use pg on their local computer
[06:00:51] centrx: I am doing so right now
[06:01:26] RubyPanther: "everybody" runs pg locally
[06:01:59] RubyPanther: next you'll claim linux doesn't run on the desktop ;)
[06:02:16] centrx: My experience is MySQL is buggy.
[06:02:30] agent_white: nahtnam: Again, MySQL is a poor choice due to Oracle's poor choices. It's becoming proprietarty, that is your reason to move on.
[06:02:45] nahtnam: agent_white: YOLO. PG it is...
[06:02:48] agent_white: proprietary even.
[06:03:02] nahtnam: WHY CANT MYSQL BE OPEN SOURCE
[06:03:16] agent_white: Oracle is fascist.
[06:03:29] centrx: MariaDB is open-source. That is the MySQL replacement
[06:03:36] agent_white: Only reasoning behind buying Sun and shitting all over everything.
[06:03:38] jackyalcine: nahtnam: a lot of people use postgresql
[06:04:01] dseitz: My major stay with PG is I didn't have to learn how to use MySQL
[06:04:11] jackyalcine: that's a win any day
[06:05:08] nahtnam: Ok, well I switched over to pg! :)
[06:05:14] nahtnam: How does this look? http://screencloud.net/v/4da9
[06:06:18] jackyalcine: nahtnam: I like it!
[06:06:28] nahtnam: jackyalcine: Thanks. Anythign I can improve?
[06:06:31] jackyalcine: not a big fan of the whole flat movement, but layering is key! :)
[06:06:57] nahtnam: jackyalcine: layering?
[06:07:06] jackyalcine: the text inside of the () could be put into tooltips of sorts
[06:07:28] RubyPanther: http://bugs.mysql.com/bug.php?id=69512 <--- comical
[06:08:03] RubyPanther: "please don't tell me you've re-released files with the same version number / file name but with different contents? .... You indeed have ... $trust--"
[06:08:16] nahtnam: jackyalcine Right. I totally forgot about that. Im not fully done. I have to center the titles and make them a dark gray. Ill add tooltips too.
[06:08:36] jackyalcine: You could kill the labels and use placeholders as well
[06:08:40] jackyalcine: but that's me
[06:08:52] jackyalcine: RubyPanther: lol, like who does that?!
[06:09:15] RubyPanther: Oracle. I think that's the full list...
[06:13:43] dseitz: Well there's other comical issue updates
[06:13:58] dseitz: My favorites were the one I get from MS support; and PHP's core team
[06:25:00] nahtnam: Enjoy the rest of your day/night! :)
[06:25:04] nahtnam: Good night! :)
[06:27:06] jackyalcine: he's so nice for coming back
[07:33:15] agent_white: ACTION waves
[07:33:47] hernanvicente: i'm looking for a gem to auto test my tests
[07:37:17] agent_white: My mom gave me the gem of my fingers
[07:38:05] hernanvicente: my rails version is 4.0.2, ruby 2.0.0 and i'm trying to test my models with unit test
[08:12:57] elliotec: use minitest
[08:13:07] elliotec: gem 'minitest-rails-capybara'
[08:13:49] elliotec: check out capybara docs, super helpful cheat sheets online that let you test user stories in pretty much plain english
[08:13:58] elliotec: if you use gem 'turn'
[08:14:01] elliotec: and 'launchy'
[08:14:08] elliotec: you've got a nice little test suite going
[08:14:25] elliotec: minitest is built into ruby
[08:15:01] tbuehlmann: hernanvicente left already
[08:16:36] elliotec: weird, the timestamp shows the question a half hour ago, but his question popped up like in real time
[08:19:31] rhizome: firefox web dev tools give me a sad
[08:25:18] elliotec: rhizome: you know about firebug- and chrome- right?
[08:25:59] jackyalcine: rhizome: firefox's web dev tools are pretty strong
[08:26:53] rhizome: jackyalcine: they bug me
[08:27:14] rhizome: can't please everyone, of course
[08:27:26] jackyalcine: it has an inbuilt responsive view mode
[08:27:33] jackyalcine: as well as strong debugging with firebug
[08:27:49] rhizome: just the element pane is a little 'wut' ...doesn't paint the page unless you toggle the thing on and off
[08:28:46] rhizome: and yeah, firebug is what i'm comparing....ff tools do have some extra things that are nice, but i can haul those up when needed rather than relying on it for everything
[08:31:33] elliotec: yeah i was a stalwart firefox user for some time, not entirely sure why or when i moved back to chrome/chromium (honestly I think it was the syncing of bookmarks across all devices) and realized how much more i liked chrome dev tools
[08:45:08] dirty-hippie: hi folks! how to hide 404 errors in development?
[08:45:54] rushed: dirty-hippie: cover your eyes
[08:46:25] waseem_: dirty-hippie: I'd advise against that.
[08:50:07] elliotec: dirty-hippie: why would you want to hide 404 errors in development?
[08:54:32] jackyalcine: dirty-hippie: you could add a 'catch-all' matcher to your routes
[08:54:48] jackyalcine: but like elliotec, waseem_ and rushed are saying; there's never a good reason to
[08:57:41] dirty-hippie: elliotec, because I do not want to copy all the images from the server :(
[08:59:29] elliotec: dirty-hippie: if your error is missing images, there would be broken image icons in the places they belong... thats an asset error that wouldn't have much to do with a 404 error
[09:00:29] elliotec: dirty-hippie: you might want to check out your routes and paths. images wont have much to do with 404
[09:00:53] elliotec: and certainly hiding that error wont help you in any way
[09:01:45] dirty-hippie: ok,.. actually what I want to achieve is that these 'missing asset' messages do not cover the really important info
[09:02:16] dirty-hippie: so the question is how to get them out of the `rails s` output
[09:05:00] jackyalcine: you want 'quiet_assets'
[09:05:12] jackyalcine: ACTION wonders if helpa searches rubygems
[09:14:26] elliotec: dirty-hippie: you must mean those 304 messages then? https://github.com/evrone/quiet_assets should do the trick as jackyalcine suggested
[09:15:40] dirty-hippie: thank you! checking right now
[09:25:37] certainty: moin Rails overlords
[09:25:55] Radar: o/ certainty
[09:35:15] dirty-hippie: looks like quiet_assets doesn't work: ActionController::RoutingError (No route matches [GET] "/uploads/place_image/2132/place_show_Carpaccio_sofievskaya_6.jpg"):
[09:35:31] dirty-hippie: and than goes a stackstrace
[09:35:37] dirty-hippie: sorry, backtrace
[09:35:49] jackyalcine: well, the file doesn't exist
[09:35:53] jackyalcine: it's going to let you know
[09:36:04] jackyalcine: hiding it wouldn't make 100% sense
[09:36:16] jackyalcine: are you doing the hiding purely for aesthestic reasons?
[09:38:27] dirty-hippie: yes - app output like a 10-15 screens lines of assets information which I do not need
[09:38:51] dirty-hippie: I rather prefer to observe controller/sql info
[09:41:47] certainty: can all easily done with grep
[09:43:02] certainty: without losing information i mean
[09:43:14] certainty: in case you're not on *nix, ok good luck :p
[09:52:01] defsdoor: I'm using rails-prawn (prawn pdf) to render pdfs using view templates etc.. I'd like the resulting PDF to be offered to the browser with a name different to the current request URL - can that be done ?
[09:55:11] defsdoor: aah ok - theres a filename option to prawn_document
[10:03:34] certainty: and one more time rtfm saved your day xD
[14:12:46] helpa: Nom nom. Thanks, Radar!
[14:12:46] Radar: !botsnack
[14:12:53] helpa: Please section your pasties using the syntax of "## section header". Alternatively, use https://gist.github.com's and click "Add Another File".
[14:13:00] Radar: THERE we go. Finally.
[14:13:07] Radar: jonoaustin: Your pastie is a bit hard to read without that sectioning.
[14:13:32] Radar: AntelopeSalad: Who: Maybe a way to go when a product is deleted is to bust all the caches for all the products.
[14:14:05] Radar: Delete all the keys in the Rails.cache backend that match spree/products/all-*
[14:14:07] Who: Radar: how about just use cache_key (the default) or updated_at and take a SHA1 of that? keep the previous one?
[14:14:17] Radar: Who: cache_key won't work for a collection
[14:14:23] AntelopeSalad: i think that might be the only way, since all of the individual ones are kept, the list should be quick to regen?
[14:14:29] Who: no cache_key for each record
[14:14:40] Who: it will be a string and then SHA1 of that
[14:14:43] Who: keep the previous SHA1
[14:14:46] Who: if that has changed
[14:14:47] Radar: Who: how do you mean?
[14:14:56] Radar: Can you show me it in code?
[14:15:20] Who: sure, just a second
[14:16:22] Who: new_sha = HexDigest::SHA1.digest(Holiday.all.map(&:cache_key).join); if new_sha != @prev_sha (update the cache)
[14:16:25] Who: something like that
[14:17:23] Who: though it would be slow compare to maximum in the usual cases
[14:17:25] Radar: Loading all the holidays though?
[14:17:33] Radar: yeah, would be pretty slow
[14:18:45] AntelopeSalad: what if you added the count as part of the key?
[14:19:16] Who: ah that could work
[14:19:23] Who: use the maximum for normal case
[14:19:26] Who: if count has changed
[14:19:33] Who: then regenerate
[14:19:38] Who: so you only regenerate if deleted
[14:20:03] AntelopeSalad: you could either use a counter_cache for that or maybe just keep the count outside of your db in redis so it's a quick lookup
[14:20:19] Radar: Don't know if that would work on Spree.
[14:20:39] Who: what would be the issue?
[14:20:40] Radar: If we're displaying 10 products per page, 30 products in total, you delete 1 product...
[14:20:49] Radar: There'd still be 10 products on page 1?
[14:21:21] AntelopeSalad: isn't that normal? since there's 29 products now
[14:21:21] Who: Radar: can't you just keep a combine count?
[14:21:44] Radar: AntelopeSalad: Yes, but if you delete a product from page 1, what is going to tell it to update?
[14:23:06] AntelopeSalad: i think it's worth just blowing the list's cache on delete and not deal with it haha
[14:23:14] jonoaustin: radar: thanks for that
[14:23:21] jonoaustin: any help with http://pastie.org/8691401 is appreciated
[14:24:13] AntelopeSalad: then re-evaluate when it becomes a problem, because aren't we talking about 2ms of time here to rebuild a list of 30 products down to 29 while the other 29 caches are still in tact?
[14:24:19] Radar: jonoaustin: I would have a helper with similar conditional logic to the controller that would determine which routing helper to use.
[14:24:34] Radar: AntelopeSalad: I agree that blowing the whole thing is best :)
[14:25:02] AntelopeSalad: so on delete you would just delete the key from the cache right?
[14:27:11] Who: also what if you delete a product and add a new one
[14:27:20] AntelopeSalad: then on the next page view, rails is going to determine it needs to pull out a list of 1,2,3,5,6 (because product 4 was deleted) products, it finds each one in the cache and quickly builds the new list
[14:29:15] AntelopeSalad: Who: the act of adding one will update the .maximum
[14:30:33] jonoaustin: radar: so that would look like a helper that creates a "custom helper path" after looking at the original request path?
[14:30:58] Radar: jonoaustin: It would look at the params, just the same way that the controller is
[14:33:44] Who: AntelopeSalad: ah so rebuild the entire thing
[14:33:47] Who: if maximum changes
[14:33:50] Who: or count changes
[14:35:37] jonoaustin: radar: am I better off restructing the routing? creating different methods in products controller etc... it seems very 'un-rails' what I am trying to do
[14:37:18] Radar: jonoaustin: well for starters your controller action is about 50% longer than it needs to be
[14:37:31] jonoaustin: radar: yes, it needs refactoring :)
[14:37:50] Radar: jonoaustin: https://gist.github.com/radar/8769321
[14:38:40] jonoaustin: radar: haha yes, this is a very good point
[14:39:01] jonoaustin: I feel like I have gone very anti-rails somewhere along the line with this implementation...
[14:41:04] zelrik: not sure why you need the respond_to
[14:41:12] zelrik: there is nothing in it
[14:41:19] Radar: jonoaustin: updated with helper: https://gist.github.com/radar/8769321
[14:41:48] Radar: jonoaustin: It's useful that your routes are named along the same lines as your models
[14:41:58] Radar: jonoaustin: http://ryanbigg.com/2012/03/polymorphic-routes/
[14:43:50] zelrik: I d refactor all those if statements
[14:43:52] zelrik: in a model
[14:44:49] zelrik: also there is a big mistake on line 17
[14:44:56] zelrik: it s @collection.products
[14:45:51] zelrik: it looks like all you need in the end is @products
[14:46:27] zelrik: so you should do something like @products = Product.my_custom_method(params)
[14:47:01] Radar: Yup, that's a way to do it
[14:47:05] jonoaustin: radar: thanks mate, testing it out now..
[14:47:16] pjackson: activerecord question (v4) - I want to use eager_load AND do a join to a different table and select some fields from that join using a separate named scope. Is this possible? I'd rather not write out all the joins by hand and then contruct the activemodel objects from the data i'm getting nicely via eager_load currently
[14:47:31] Radar: I'm assuming that jonoaustin wants to display some information about the thing the products are being scoped by... so I'm leaving it in the controller.
[14:47:44] zelrik: and if you really need store and collection later in the view you could just do @products.store or @products.collection
[14:47:50] jonoaustin: zelrik: yes I agree, that logic should move it controller.. it is just an array of products, regardless of how the user gets there
[14:48:01] zelrik: or some custom methods that have a fallback
[14:48:01] jonoaustin: sorry, move into model
[14:48:36] zelrik: some lines really bug me
[14:48:46] zelrik: @products = Product ... wat?
[14:49:50] jonoaustin: its my non-ruby brain at work
[14:50:30] jonoaustin: many of those calls could be chained
[14:51:37] zelrik: perhaps Product.all
[14:51:46] Radar: zelrik: @products = Product is intentional
[14:51:48] zelrik: if that s what you want
[14:51:58] Radar: zelrik: the view will do .each on it and that's when it will be loaded from the database
[14:52:15] jonoaustin: yep - it's render partial @products
[14:52:48] zelrik: I d still write Product.all
[14:52:56] zelrik: it wont be queried until it s used anyway
[14:54:39] Radar: For some reason I had it in my head that Product.all did do a query, but I just checked in the console with "Spree::Product.all; nil" and it didn't.
[14:54:46] jonoaustin: zelrik: in what instance? I need to paginate the result - chaining .paginate is the only way I can see to add all the methods like @products.next_page etc
[14:55:32] zelrik: let me refactor that stuff
[14:56:01] jonoaustin: love you guys
[14:56:26] jonoaustin: learn more in this channel in 5 mins than a day of reading
[14:56:46] zelrik: gah I am not used to that gist stuff
[14:56:52] zelrik: is there a way I can clone a giest
[14:57:48] zelrik: I ll do a new gist I guess
[14:57:49] jonoaustin: there should be a link to view raw version
[14:59:53] Radar: zelrik: fork button
[15:00:10] zelrik: well too late
[15:04:17] zelrik: https://gist.github.com/AlexCppns/8769646
[15:04:22] zelrik: that s how I d do it
[15:07:12] jonoaustin: zelrik: holy crap - that is awesome
[15:07:39] jonoaustin: will plug it in and make sure it passes
[15:08:15] zelrik: not sure that the 'if @products' at the last line is necessary
[15:09:41] zelrik: a controller action like this should be 2 lines at most
[15:09:50] zelrik: there is no reason to be more
[15:11:03] zelrik: I have seen fat controllers that are like 4000 lines
[15:11:08] zelrik: I hate that
[15:15:29] toretore: let's put all the lines in the model, it's cleaner that way
[15:21:37] zelrik: I dont like the find() method
[15:21:51] zelrik: it returns an error if there is no record
[15:23:15] Radar: zelrik: find_by instead
[15:23:22] Radar: zelrik: i.e. find_by(id: 1)
[15:24:13] zelrik: yeah I prefer that one
[15:24:51] zelrik: jonoaustin, find is quite strict, you might want to replace it by find_by
[15:25:48] loc22: Hi guys! Im new to rails and i want to know if you recommend some gem for logging or if it is better to do it myself? Thanks!
[16:05:29] pontiki: rails has a logger
[16:05:53] tewlz: maybe he means for production? Either way I think he's gone.
[16:06:09] pontiki: rails logger works in prod, too...
[16:06:10] tewlz: I use rubber to deploy and the default webtools comes to graylog2 which seems to work just swimmingly.
[16:07:41] tewlz: pontiki: right, I guess I just never considered using default logs as swimming through a sea of text can be time consuming. Do you use default logs to debug on production?
[16:08:05] tewlz: s/comes to/comes with
[16:08:29] pontiki: maybe depends on what you mean by debug
[16:09:17] pontiki: but i've also used new_relic, datadog, sumologic and such things to report and analyze production problems
[16:09:32] tewlz: as in, user reports 500 error around 9pm. I don't think I would go grepping through the logs to find that error
[16:09:44] pontiki: that's where sumologic is ace
[16:10:02] pontiki: it gathers up your log and lets you weed through it
[16:10:56] tewlz: I've never done any research on loggers as I've never been in charge of production monitoring. I'd be curious as to how graylog2 holds up via other loggers just because it's so easy to click and forget a rubber deploy
[16:11:37] pontiki: i haven't ever heard of rubber or graylog2, so i can't comment on that
[16:12:50] tewlz: pontiki: if you ever deploy your own rails manually or have had the 'pleasure' of writing your own cap deploys. Rubber is basically just a library of sane defaults + tons of extras for deploying rails onto staging/production servers
[16:14:07] tewlz: basically I can go from signing up for AWS to having a rails up and running in under 30 minutes with awesome webtools my choice of rails server my choice of web server and many other configs
[16:14:50] pontiki: i mostly use chef
[16:14:52] tewlz: I tpyically deploy with unicorn/nginx for example
[16:15:01] tewlz: I think rubber is based off capistrano
[16:15:23] pontiki: the place i'm working with now tends to use capistrano
[16:15:29] pontiki: got a link for rubber?
[16:15:43] pontiki: googling rubber gives me too many things i don't want to see
[16:18:58] AntelopeSalad: i looked at rubber once but ultimately went with chef too
[16:19:11] cusco: hey folks
[16:20:13] tewlz: pontiki: yeah one sec
[16:20:30] tewlz: pontiki: http://railscasts.com/episodes/347-rubber-and-amazon-ec2?view=comments
[16:20:47] tewlz: theres the railscast for it, scroll to 15 minutes to see the default webtools it deploys
[16:20:59] tewlz: pontiki: https://github.com/rubber/rubber
[16:22:39] tewlz: AntelopeSalad: any reason other than preference or you like to roll your own scripts?
[16:23:31] pontiki: chef has tons of recipes
[16:23:37] pontiki: you don't have to roll your own
[16:23:49] AntelopeSalad: i felt like chef was a better use of my time because it's not tied into cap and i can use it for anything, it has a massive community, it's super battle hardened and i liked its DSL
[16:27:13] AntelopeSalad: there are "cookbooks" for almost anything you can think of too, i didn't have to roll a single script myself
[16:27:39] AntelopeSalad: all i did was create a specific cookbook for my application that configures various components with the settings my app requires
[16:32:02] cusco: we installed a ror app, and it was working fine. Then I migrated some more websites to this webserver.. nothing fancy, installed some php libs.. apache had mod passenger and mod php... ... ... I can't figure why all the time I am to POST/PUT something in the web page application, it takes ages before the app log statrs producing lines ... it takes about 30 seconds hanging, can't figure why...
[16:36:03] pontiki: cusco: i don't know really, but it sounds like it is restarting the rails app?
[16:36:27] pontiki: i don't use passenger+apache so i can't really say
[16:36:50] pontiki: ACTION is an nginx+unicorn sort of gal...
[16:41:00] droptone: question: I have written a search function within my model, as seen here: http://www.jorgecoca.com/buils-search-form-ruby-rails/
[16:41:24] droptone: my question is, I want a dropdown form to let the users select the query
[16:43:04] droptone: how do I go about reating a dropdownform that sets a query variable?
[17:08:57] boboc: Hello, guys how can i create a server socket in Rails so the client could connect to the server using a TCP connection? i saw Ruby has this class TCPServer but how can i configure a rails app to accept TCP connections using an ip and a port?
[17:09:28] tbuehlmann: boboc, why exactly do you need a tcp server?
[17:10:23] boboc: tbuehlmann: because the server needs to store the location of some cars which would need to be connected to the rails app using TCP and send the latitude/longitude
[17:11:06] tbuehlmann: and that has to be via an tcp connection?
[17:11:07] boboc: and that location would be sent by the server to another place so the car location is updated on the map
[17:11:21] boboc: there should be a chat available to, so yes it would need to be TCP
[17:11:23] Scient: this sounds wrong
[17:11:27] Scient: rails is not for this stuff
[17:11:52] Scient: rails is for HTTP connections, not TCP connections
[17:12:05] Scient: how would this look? you open a TCP connection when accepting a HTTP connection?
[17:12:22] boboc: i know, but ruby has the TCPServer class which offers exactly this
[17:12:23] Scient: how would your other end connect to the rails app over TCP?
[17:12:31] Scient: yes, then write it in plain ruby
[17:12:33] Scient: not with rails
[17:13:06] Scient: and i would also seriously consider reactor for this, especially if the tcp connections are long-living
[17:13:42] nidet: Anyone looking to share a room on RailsConf?
[17:13:44] boboc: Scient: i don't know this is why i've asked here because i'm not sure if this is possible with Rails, i know a little about rails, i know how the routing system works, i know how a rails app works and i'm not sure how someone could connect using a TCP connection
[17:13:46] toretore: HOW ARE YOU?
[17:13:57] nidet: fine thanks and you?
[17:14:21] toretore: DO YOU LIKE DOLLS I LIKE DOLLS DO YOU WANT TO SHARE ROOM
[17:14:26] Scient: boboc: rails is a HTTP framework
[17:14:49] toretore: boboc: do this in a separate process outside rails
[17:14:54] nidet: anyone looking to book a room near the sheraton for railsconf?
[17:15:05] droptone: ok, here's the deal, hopefully someone can help me. I'm tryin to implement two search forms, one to allow users to search artist_profiles by genre, and one to allow them to search by name.
[17:15:11] droptone: I've created a gist with the relevant code:
[17:15:12] droptone: https://gist.github.com/anonymous/a3760b37e33044501b22
[17:15:53] droptone: To start with, let's do the searchname form. How do I set that search form to send the parameters to the artist_profiles_public controller as shown in the code, and set the parameter sent as :searchname?
[17:16:33] boboc: toretore: i thought i could use this in rails so i could benefit the orm active record
[17:16:54] toretore: you could still use ar i guess but what's the point
[17:17:07] hashpuppy: i created app/foo/file.rb i can require 'file' from rails console, but not from SomeController? I get file not found when I try it within the controller. why is that?
[17:17:19] toretore: droptone: GET /artist_profiles?name=penis
[17:17:24] toretore: droptone: GET /artist_profiles?genre=penis
[17:17:37] droptone: the controller is artist_profiles_public
[17:17:51] toretore: whatever, just send it a param
[17:18:02] toretore: and let it filter the results
[17:18:06] droptone: ok, to test results?
[17:18:10] droptone: let me give it a go, thank you.
[17:18:54] toretore: GET /profiles => all profiles; GET /profiles?name=butt => profiles where name matches butt
[17:19:38] toretore: <form action="/profiles"><input name="name"> will make GET
[17:20:29] droptone: interesting toretore, thank you.
[17:20:32] droptone: let me try this out.
[17:41:39] zkay11: Is adding anything regarding wait or sleep not preferred in a capybara test? I can't get an ajax event to add something to a form field and then have it added to the ActionMailer::Base.deliveries array without sleep, or some kind of wait_for_ajax method
[17:41:41] zkay11: https://gist.github.com/zkay/8771496
[17:41:59] pontiki: man those are expensive rooms
[17:47:41] ner0x: So what's the standard way to validate activerecord email attributes?
[17:47:56] ner0x: I'm sure there's a bot command for this. :) (Yes, I did google search)
[17:56:06] pontiki: a bot command?
[17:56:53] cusco: I'm also seeing that browser request always takes 30(ish) seconds to get the status code (302), and besides the RoR app processing the log also afther these 30 seconds, so does apache !
[17:57:40] cusco: the browser request is a POST, but in this case the RoR app logs it as a PUT. only these PUT requests take about 30 seconds extra
[17:57:47] cusco: can't figure out why :(
[17:58:36] pontiki: ner0x: look here, maybe: http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validates
[17:59:48] pmurias: how does rails load code from the app directory?
[17:59:56] ner0x: pontiki: Thank you. Saw that example.. always say the validates_email_format_of gem. Interested although I believe the i18n support is broken.
[18:02:14] pontiki: i just use the regexp shown
[18:05:14] ner0x: pontiki: Good enough for me.
[18:11:53] jglauche: I'm on rails 3.2 and I'm getting some strange routes. I have a resource :addresses set up and my edit route looks like this:
[18:11:56] jglauche: edit_addresses GET /addresses/edit(.:format) addresses#edit
[18:12:03] jglauche: it doesn't accept an id parameter
[18:14:08] Radar: jglauche: because you're using "resource" and not "resources"
[18:14:09] elsurudo: do you have "resources :addresses", or "resource :addresses"
[18:14:52] elsurudo: that'll do it
[18:15:25] jglauche: what a pitfall..
[18:15:50] AntelopeSalad: i got destroyed by that once
[18:15:58] elsurudo: it's one of the downsides of the "magic" of rails. one letter makes a huge difference
[18:16:22] elsurudo: in another language/framework, you'd probably expect to get an error, and only of of the two would do anything
[18:19:49] pontiki: yup. time to give up on rails.
[18:20:36] jglauche: well. I thought so long ago while refusing to ugprade my rails 2.3 applications.
[18:21:18] centrx: This Just In: Programming language requires spelling method names properly.
[18:22:06] jglauche: thanks to the rails_upgrade plugin I'm back on track. and some of the stuff crys for manual ugprading anyway.
[18:23:58] jglauche: lets see how I think of it once I get to my admin application which started in rails 1.1 times.
[18:25:04] AntelopeSalad: jglauche: just curious, is your plan to go from 2.3 to 3.2 to 4.x?
[18:25:22] jglauche: AntelopeSalad: 3.2 for now from 2.3
[18:26:24] jglauche: AntelopeSalad: could upgrade to 4.0 if I find a plugin that accepts deprecated find_by_ calls
[18:26:55] jglauche: or something that converts the simple ones
[18:27:10] pontiki: they still work in 4.0, don't they? i thought they were just deprecated
[18:27:28] AntelopeSalad: i never upgraded before (started with 4.0), it always interests me to hear people talk about upgrading really old code bases tho
[18:27:36] jglauche: do they? there were marked as deprecated since 3.0/3.1, no?
[18:27:50] pontiki: i am pretty sure...
[18:27:53] jglauche: AntelopeSalad: my problem is basically security upgrades
[18:28:04] pontiki: i have a 4.0 app that still uses them, though i'm converting what i run across
[18:28:05] AntelopeSalad: all of the new strong params?
[18:28:19] pontiki: i think they're removed in 4.1
[18:28:24] jglauche: AntelopeSalad: there's one company who provides support for a huge amount of money though
[18:28:27] pontiki: but i'm not sure of that, either
[18:29:42] jglauche: so if that works, I see no big problem upgrading to 4.0
[19:10:09] platzhirsch: I am using memcached, yet the webserver allocates more and more memory, I thought this is delegated. Could this be something else? I think Page Caching is no more in Rails 4.
[19:11:38] Radar: platzhirsch: what you just said doesn't make any sense.
[19:11:52] Radar: It's almost like you think memcached SAVES memory
[19:12:09] platzhirsch: Radar: Yeah, wanted to keep it short. No :) I did caching so far in :memory_store
[19:12:23] platzhirsch: and I wanted to delegate that to memcached so I can make use of its LRU caching strategy
[19:15:27] platzhirsch: so I guess it's not caching what consumes the memory
[19:26:07] brycesenz: Hi all. I'd love some advice on how to solve an minor issue - We have a documents table that holds records which correspond to our legal terms and conditions (so 2 records total that rarely change). In a few places across our application, we have to display those terms, so I find myself calling "Document.find_by_key(...)" to get the correct one. Is there a cleaner way to set a global variable to just point to a particular
[19:26:07] brycesenz: object, or will that be setting myself up for problems later on?
[19:30:00] neredsenvy: How do I include specific asset/javascript/css file in rails application. I added mine to /public/assets/ and linked it as I would with any framework with html tags in layout file.
[19:30:26] neredsenvy: The rails guide says i need to use require tree . from application.js but this will include all JS files
[19:30:32] neredsenvy: and I don't need to include all
[19:30:42] neredsenvy: some will be controller/view specific
[19:32:14] neredsenvy: I used = require uikit.min in my application.js the file is in same folder but it does not get loaded
[19:36:38] neredsenvy: ignore wrong folder
[19:43:50] rhizome: brycesenz: I'd just use a class method that returns the object. Document.privacy_policy
[19:45:13] brycesenz: rhizome...I'm an idiot. Thank you for that!
[19:46:41] rhizome: neredsenvy: there's a lot you can do there. read http://guides.rubyonrails.org/asset_pipeline.html (search for index.js)
[20:10:18] neredsenvy: In my application.js I have = require uikit.min and bellow it = require sticky.min However when application loads sticky is loaded first then uikit which causes a problem because uikit needs to be loaded before sticky can be loaded
[20:10:49] neredsenvy: Also application.js loads jquery_ui which creates problems with uikit from my js framework
[20:11:11] neredsenvy: anyway to exclude jquery_ui.js and have uikit.min.js be loaded before sticky.min.js
[20:13:50] neredsenvy: Blody hell I thot //= in application.js was a comment also had require tree there
[20:24:51] ohwhoa: Help with rails4 + activeadmin + globalize, I need a translatable field. Tried this - https://gist.github.com/kevinansfield/1505820 and this - https://gist.github.com/bbonamin/1515338 , still nothing in one case error with database connection timeout in second case cant save related translation. Someone have step by step solution or something like that ? Thanks
[20:26:10] ner0x: How can I properly seed a test database with default values without using fixtures? I have db/seeds.rb working but it seems to only work with development. Any help or links would be appreciated.
[20:27:33] droptone: I have the following search functions defined in my model, and I want to set them so that if no results are found, the object returned is nil, which it is not doing by default: https://gist.github.com/anonymous/2c6872b9c26e91cd1a70
[20:27:34] Tokenizer: sorry quick question, how do I do a time different in ruby? newTime = Time.now - (10 days)
[20:27:37] droptone: how do I go about setting that?
[20:29:32] centrx: Tokenizer, In Rails, it should be: Time.now - 10.days
[20:30:27] centrx: In conclusion, Ruby on Rails is excellent.
[20:31:16] droptone: haha, indeed it is.
[20:32:27] brycesenz: ner0x - I'm sure that there are other ways, but I use the seedbank gem to organize my seedfiles and ensure that certain things are seeding for certain environments - https://github.com/james2m/seedbank
[20:32:29] centrx: droptone, It should return an empty array?
[20:32:39] centrx: droptone, Or an empty relation of some kind
[20:33:14] Tokenizer: centrx: thanks
[20:33:43] droptone: centrx: correct, it's returning an empty array it appears. What's odd is, if I run a .inspect on the returned variable, if nothing was found, I don't get the typical metadata
[20:33:56] droptone: I just get []
[20:34:15] droptone: it would be ideal if it returned nil, but I suppose some sort of check to see if it is an empty array would suffice
[20:35:16] ner0x: brycesenz: I'll check it out. Thank you.
[20:35:50] droptone: would there be a way to run some sort of if conditional in the search function so where, if the search returns an empty array, I can set it to nil?
[20:36:04] droptone: or is there some sort of .empty? function built-in?
[20:36:39] centrx: Yes, that is what it is called
[20:37:15] centrx: Lesson for the day is, write out what you want to do in English, add a few periods, and there you have Ruby
[20:37:23] droptone: yup, that did it.
[20:37:27] droptone: switched .nil? to .empty?
[20:37:31] droptone: brilliant, thank you centrx.
[20:37:40] centrx: Rails also has .blank? which checks both
[20:39:17] ner0x: brycesenz: Would you happen to have any code you could gist me that I could skim over?
[20:39:48] brycesenz: ner0x - I don't understand. Code for what?
[20:40:09] rubyracer: has anyone got an error "Can't convert symol into integer" I am using a form_for for a non active record model
[20:40:29] ner0x: brycesenz: Often the docs show what you're supposed to do and reference putting code in "a file" but rarely tell you which file.
[20:40:45] ner0x: brycesenz: I think I've figured it out by examining the test suite for that gem.
[20:41:19] brycesenz: ner0x - the way that the gem works is that you put some seed files (that you want run for all environments) in the top level of your seed folder, and then environment specific seed files in their own environment. The gem just stiches it all together.
[20:42:27] ner0x: brycesenz: Sounds fantastic. I'll git it a try and see what I come up with.
[20:43:20] rubyracer: this is my code. I am getting a "Can't convert symbol into Integer" https://gist.github.com/ganeshran/8774603
[20:43:38] rubyracer: It is a form which creates an object desgined to hold data for user's filter options
[20:44:01] diggitydane: I'm trying to create a token when a customer is created. In 3.2.x this works, in 4.0.2 it runs it even on updates.
[20:44:04] diggitydane: https://gist.github.com/anonymous/8774625
[20:44:25] diggitydane: is before_validation xxx, on: :create no longer valid?
[20:45:16] ner0x: brycesenz: "At the bottom of your applications Rakefile"... Where is that?
[20:45:27] ner0x: brycesenz: Nevermind..
[20:45:48] ner0x: brycesenz: I thought it meant a specific custom rakefile. It's literally the global "Rakefile" lol
[20:46:05] brycesenz: ner0x - haha, no worries.
[21:18:11] neredsenvy: In my .css files that are loaded from application.css how do I access image files in images folder to call background: url(../image/image.png); Because as it is now it does not work
[21:18:53] diggitydane: if you're using asset pipeline, url('/assets/image.png')
[21:19:22] neredsenvy: diggitydane: Nope still nothing
[21:20:24] diggitydane: can you access that directly in the url? http://localhost:3000/assets/image.png
[21:21:12] neredsenvy: diggitydane: No I get no route matches error.
[21:22:59] diggitydane: not sure then. are you using asset pipeline?
[21:23:45] helpa: http://guides.rubyonrails.org/asset_pipeline.html - The Asset Pipeline Guide by Ryan Bigg, Richard Hulse & Mohammad Typaldos
[21:23:52] Radar: Section 2.3.2
[21:28:34] neredsenvy: Radar: If i change uikit.css to uikit.css.erb then I can use <%= asset_path %> But that is just horribly horribly horribly wrong.
[21:28:59] Radar: why's that?
[21:29:08] Radar: and it's not <%= asset_path %>, it's asset-path
[21:32:54] neredsenvy: I don't want to have Rub HTML tags in CSS makes code unreadable and ugly. No to mention if you are going to reuse the css file it won't work no to mention if someone else comes after you who is familiar with css and not rails they wont have any idea where the file is being loaded from.
[21:33:28] neredsenvy: So it's also counter productive because now instead of being able to hack away you have to go browse the folders to find the image. : (
[21:37:18] rushed: neredsenvy: I think you're mistaken, if you use the sass helper you only need to specify the file, not it's location, and you don't need to use erb markup (plain css is valid in a sass file so you can just tack the extension on, not change anything and start using the asset helpers only if you're not interested in the rest)
[21:38:44] rushed: I'm a liar, scss is the extension you want for plain css being valid :)
[21:39:00] neredsenvy: But now you also need to learn sass kills the productivity not to mention you actually have to have sass installed.
[21:39:15] neredsenvy: Is there no way I can just point to the file the CSS way ?
[21:39:35] rushed: neredsenvy: what part of "plain css is valid" in a scss file means "now you also need to learn sass" :P
[21:40:10] neredsenvy: rushed: What about if you don't have it installed.
[21:40:25] rushed: neredsenvy: it's a default
[21:41:01] neredsenvy: What if you dont have it. : / Say the gem is removed and cant install it : /
[21:41:58] rushed: neredsenvy: now your question is how do I use core rails features after having removed default components... which sounds like trolling :)
[21:42:16] neredsenvy: I mean the folder structure is assets [ images, stylesheets ] Is there no way I can simply point to a bg.png in images folder in css by just calling url(../images/bg.png)
[21:43:57] Mosselman: Hi guys. Is it correct that (in Rails 3 at least) cache columns are, by default, only usable for counts?
[21:44:32] Mosselman: I have a user who has many 'actions'. These actions have a `points` column and right now I have: user.num_points that does a sum of all of his points.
[21:44:47] Mosselman: I'd like to cache this. Is there something standard that does this?
[21:45:21] rhizome: Mosselman: :column_cache => :column_name if you don't want to use :associationname_count
[21:45:28] rhizome: which is the default
[21:45:36] rushed: neredsenvy: the point of assists is to manage them in the pipeline, that means optimization, consolidation, and cache busting, to do that you have to give up control over knowing the name of things, if you don't want to do that, you can put your assets in /public and refer to them directly, but you will then loose optimization, consolidation, & cache busting (which are there for a reason, even if perhaps your experience to date doesn
[21:45:36] rushed: suggest they're a necessary complication)
[21:46:26] Mosselman: rhizome: thanks I will try this in a few mins
[21:46:32] jammanbo: rhizome: He wants a sum not a count I think. Mosselman, no, no standard way AFAIK. Callbacks and an extra column in your user table
[21:47:17] jammanbo: am I wrong ??? again?
[21:57:32] deever: Could not find sprockets (~> 2.2.1) amongst [..., sprockets-2.10.1, ...]
[21:59:09] DaniG2k: guys I'm having a hard time getting some json from Facebook api
[21:59:21] DaniG2k: im using the following
[21:59:27] DaniG2k: JSON.parse(open("https://api.facebook.com/method/fql.query?query=select like_count from link_stat where url='#{uri}'&format=json"))
[21:59:34] DaniG2k: where uri is something like http://www.bbc.co.uk/news/world-asia-26003995
[22:00:02] DaniG2k: if I input that url manually it works but if I go it programmatically with JSON(open()) it seems to fail
[22:06:31] universa1: DaniG2k: difference between manual and programmatic input?!
[22:06:37] jammanbo: DaniG2k: Shot in the dark, do you need to explicitly escape the URL or something?
[22:06:43] DaniG2k: universa1: im scratching my head about that too..
[22:06:54] jammanbo: the spaces in the query I mean
[22:06:56] DaniG2k: jammanbo: i tried that with URI.escape(uri)
[22:07:02] universa1: DaniG2k: gist it. manual example vs code example.
[22:08:45] DaniG2k: universa1 jammanbo https://gist.github.com/DaniG2k/8775647
[22:08:57] nobitanobi: I am doing a rspec feature test, and I want to make sure that if a User visits a particular page without signing in, he will be redirected to the sign-in page. What should I check, the content that he will see, or the fact that he is redirected?
[22:09:24] universa1: DaniG2k: what works? what doesn't?
[22:10:07] DaniG2k: universa1: when I run the gisted code, I get the following error from the open mehtod
[22:10:10] DaniG2k: No such file or directory @ rb_sysopen - https://api.facebook.com/method/fql.query?query=select total_count from link_stat where url='http://
[22:10:13] DaniG2k: www.bbc.co.uk/news/world-asia-26003995'&format=json
[22:10:17] DaniG2k: when I do it manually, it gets the following
[22:10:34] universa1: DaniG2k: add the error to the gist.
[22:10:40] DaniG2k: universa1: for example https://api.facebook.com/method/fql.query?query=select%20total_count%20from%20link_stat%20where%20url=%27http://www.nationofchange.org/another-chapter-coal-s-trail-pollution-1391351714%27&format=json
[22:10:47] universa1: DaniG2k: and add the code which you execute manually...
[22:11:17] dagen: if i do something like <% for child in child.children.sort %> how can i catch .first or .last child?
[22:11:31] DaniG2k: universa1: https://gist.github.com/DaniG2k/8775647
[22:12:09] universa1: DaniG2k: require 'open-uri'
[22:12:33] DaniG2k: d'oh!! -_-
[22:12:44] universa1: https://gist.github.com/DaniG2k/8775647#file-error-L7
[22:13:05] DaniG2k: now im getting another error
[22:13:10] DaniG2k: https://gist.github.com/DaniG2k/8775647#file-error-L7
[22:13:19] DaniG2k: i meant, no implicit conversion of StringIO into String
[22:13:22] rushed: dagen: depends what you want to do, you could pull them out before hand, or compare indices using something like... child.children.sort.each_with_index do |c,i|
[22:13:35] DaniG2k: ah ok i know why that is
[22:14:10] dagen: rushed i just want to detect wich string is first and what string is last in my FOR
[22:14:51] jammanbo: What about uri = URI.parse(???); uri.query=URI.encode_www_form({query: "select???"}); uri.open
[22:15:00] DaniG2k: universa1: do you know why this would be? rake aborted! no implicit conversion of StringIO into String
[22:15:02] rushed: dagen: you're suggesting for is different than each in a way that matters to you?
[22:15:41] universa1: DaniG2k: no. but something in your code obviously returns StringIO where something else expects String...
[22:16:08] dagen: rushed, hmm not sure I understand your question correctly
[22:16:16] jammanbo: uri.open.read ?
[22:16:41] dagen: rushed i don't know FOR or EACH
[22:16:55] universa1: jammanbo: yeah ;) read should do the trick.
[22:17:06] dagen: maybe it makes sense
[22:17:26] DaniG2k: jammanbo: works!!! thanks :D
[22:18:10] jammanbo: infinite monkeys
[22:19:43] neredsenvy: Ok I didnt dc
[22:19:44] dagen: rushed i found this example http://stackoverflow.com/questions/2241684/magic-first-and-last-indicator-in-a-loop-in-ruby-rails
[22:21:58] dagen: but can't understood how can i use it
[22:22:45] neredsenvy: rushed: How must I name the sass files because css.scss or jsut scss does not work.
[22:23:40] jammanbo: Stay Calm and Keep Telling Google Your Secrets
[22:24:44] rushed: neredsenvy: assuming your layout & app/assets/stylesheets/application.css are in the default state adding a file like app/assets/stylesheets/foo.css.scss should result in the styles being included
[22:24:58] DaniG2k: so if I have a Mechanize task that retrieves data from some websites, how can I output that info to my rails app?
[22:25:13] DaniG2k: say I jst want to print out the output I get from the rake file onto a view
[22:25:30] DaniG2k: does the view take instance variables from rake?
[22:25:52] rushed: DaniG2k: views and rake tasks are not generally in the same context
[22:26:16] DaniG2k: rushed: i want to run a rake task, say, once a day or so. Then I want that info output to my view somehow
[22:26:21] DaniG2k: rushed: is rake not the way to go?
[22:26:33] neredsenvy: God damn conventions why cant we all just use C for everything.
[22:26:49] mochja: hello, im newbie and I need a bit of help.. Can I simplify somehow those https://gist.github.com/mochja/8775752 6 lines ? I have an array of hashes which contains date ranges and i need to check if actual date (d) is in that range..
[22:27:28] jammanbo: DaniG2k: You'd probably need to be writing to your DB from the rake, and reading it in the view
[22:27:31] rushed: DaniG2k: one option might be to write data to your databased when the rake task is run, and then use that data in the view later
[22:27:37] Mosselman: jammanbo: rhizome : I got disconnected so I don't know if I missed anything. But sum not being standard was what I understood from several SO posts as well.
[22:28:04] Mosselman: Did I miss any conversation stating otherwise just now?
[22:28:24] jammanbo: Mosselman: I'm sure you'll find a gem for this, but you could write your own. Pretty sure rails doesnt support what you want.
[22:28:40] Mosselman: jammanbo: thanks, for the info
[22:29:05] jammanbo: The search term would probably be cumulative/running sum/total
[22:29:38] neredsenvy: rushed: One question tho if you have to use image-path and alike as a result with sass then that means you cant use a bunch of browser based tools for manipulating css/html
[22:29:46] Mosselman: jammanbo: would you increase the user.points every time an action is recorded, or would you rather recalculate with every added action?
[22:30:16] jammanbo: those two options sound the same ???
[22:30:48] dagen: rushed do you have any ideas?
[22:30:57] jammanbo: Oh you mean, taking the current value and add the new points, or query all records and sum them?
[22:31:35] Mosselman: so on_save( user.points + action.points) or on_save( user.points = actions.sum(:points) )
[22:31:36] jammanbo: the latter if its practical
[22:31:42] jammanbo: but I'm anal
[22:31:51] rushed: dagen: re?
[22:32:16] Mosselman: jammanbo: In theory the former would work too of course, but there is a bigger chance of inaccuracy.
[22:32:18] jammanbo: Mosselman: If you've a;ready loaded all the actions, then definitely actions.sum
[22:32:31] dagen: rushed how to detect first or last in FOR?
[22:32:39] Mosselman: jammanbo: then again, a proper database like postgres should not have such a big deal summing some things
[22:32:45] dagen: please help
[22:32:59] Mosselman: so I don't think the latter solution is such a performance beast
[22:33:12] Mosselman: it all depends on the total number of records of course
[22:33:30] rushed: dagen: sure, what I said 20m ago... "depends what you want to do, you could pull them out before hand, or compare indices using something like... child.children.sort.each_with_index do |c,i| "
[22:34:20] dagen: and how i can compare indices? if i use hild in children construction?
[22:34:23] nobitanobi: I have scaffolded a controller and in my 'show' view I see this: <p id="notice"><%= notice %></p>
[22:34:26] nobitanobi: What is this "notice"?
[22:34:31] nobitanobi: Shouldn't it be flash[:notice] ?
[22:35:20] dagen: rushed how can i change the current: <% for child in current_user.children.sort %> to child.children.sort.each_with_index do |c,i|?
[22:35:29] jammanbo: dagen: I think what rushed means by "depends what you want to do" is that you might well be able to avoid having to do that by using some more idiomatic solution to your problem. If you explained it, someone might tell you jow.
[22:36:04] DaniG2k: if I have some json like this [{"count":34}] and I want to get the value, is it best to do array.pop and then get the val of the key "count" if has_key? "count"
[22:36:11] jammanbo: super bowel!
[22:37:08] dagen: jammanbo i try to display tree of users, and i need to detect where is first user and last user in 1 level of three and each second level of three
[22:37:39] dagen: _and in each second
[22:39:39] dagen: i try to undertsand how can i replace current string <% for child in child.children.sort %> with 'child.children.sort.each_with_index do |c,i|'
[22:39:51] dagen: and really I have no idea
[22:39:53] jammanbo: dagen: Um, what does your array of users look like? Is it nested? What should your HTML look like? It sounds like you need some kind of recursive partial approach rather than a loop.
[22:41:49] dagen: jammanbo i think it's nested, for example i have one User wich have some children users
[22:42:17] dagen: and i get each users and if they have children - print children like a tree
[22:42:51] dagen: jammanbo my html like this http://prntscr.com/2ozxwk
[22:44:53] dagen: jammanbo & rushed: http://prntscr.com/2ozymp
[22:45:22] dagen: i need to detect last elemnt in parent and child to display the last tree symbol.
[22:47:17] dagen: in my structure i have table users with records wich contains column parent. for example user with id 2 have :parent width value 1... parent for user2 is user1, and in my tree at 1st level i can see user1 and at 2 level i can see user2 as child of user1
[22:47:41] jammanbo: dagen: http://pastie.org/8692596
[22:48:52] jammanbo: the rest is just CSS
[22:50:48] jammanbo: arghh, anyone know of a Filmon.com station (or alternative) that'll show the super bowl? Its only been 10 mins but I dont think I can handle watching it on Channel 4.
[22:51:12] Affix: jammanbo: tvcatchup.com
[22:51:22] dagen: jammanbo hmm
[22:52:11] nobitanobi: Is the notice method in a Rails view the same than flash[:notice] ?
[22:53:28] dagen: jammanbo what value should be for users like me to ask them through has_many?
[22:54:08] dagen: now ehwn i try to use .users i see undefined method `users' for #<User:0xbf277d0>
[22:56:09] dagen: and what does it mean <% render user.users %> in your exanple?
[22:57:01] jammanbo: dagen: You said you had "User wich have some children users" ??? so if User has_many :users, you'd use user.users. If User has_many :children, you'd use user.children
[22:57:47] dagen: ok i see hash with all childrens
[22:58:04] dagen: with _children for user
[22:58:25] jammanbo: <% render user.users %> is effectively the same as <% @users.each do |user| %> <% render partial: 'users/_user', locals: { user: user } %> <% end %>
[22:59:02] jammanbo: sry, I mean <% user.users do |user| %>
[22:59:18] jammanbo: man I love rails!
[23:00:11] dagen: WOOOOOOWWWW
[23:01:15] DaniG2k: if I have a bunch of Article objects in my db and i want to sort them by a column (integer) how can I do that?
[23:01:27] dagen: jammanbo now i use this construction to display the tree https://gist.github.com/anonymous/e8ce0891060223813bb9
[23:01:36] DaniG2k: Article.all.sort_by! {|a| a.counter}
[23:02:15] DaniG2k: ah ok that was it
[23:03:29] Affix: DaniG2k: You can also do Article.order('column DESC').each do |a|
[23:03:35] dagen: jammanbo and i want to see somthenig like that http://prntscr.com/2p05mu
[23:03:40] jammanbo: DaniG2k: What? No. Dont do that!
[23:03:42] dagen: but i can't(
[23:04:26] jammanbo: DaniG2k: Use #order, as per Affix's instructions (although I'd prefer Article.order(column: :desc))
[23:04:32] dagen: how can i replace my current code https://gist.github.com/anonymous/e8ce0891060223813bb9 with your advices?
[23:04:55] Affix: jammanbo: I just prefer using the 'col desc' as I'm used to it :P
[23:05:33] DaniG2k: jammanbo Affix ok cool! yeah i thought there was a better way :P
[23:05:36] Affix: jammanbo: Don't you mean Article.order([:column, :desc])
[23:06:05] DaniG2k: does Article.order imply Article.all.order?
[23:06:21] Affix: It orders the table DaniG2k
[23:06:59] jammanbo: dagen: http://pastie.org/8692620
[23:07:21] jammanbo: Affix: What I said works.
[23:07:38] jammanbo: Perhaps if you want multi column ordering you use an array?
[23:07:42] Affix: ahh jammanbo I just haven't seen it done that way before
[23:07:42] DaniG2k: Affix jammanbo thanks guys
[23:07:54] Affix: no problem DaniG2k
[23:09:59] dagen: jammanbo http://prntscr.com/2p07wu
[23:10:12] dagen: is that user. is correct?
[23:10:49] neredsenvy: Can someone help me here https://gist.github.com/anonymous/5e65ce156fa5e127e8f7
[23:10:54] neredsenvy: How can I track down what causes
[23:10:57] dagen: and http://prntscr.com/2p0886 this paths is correct?
[23:11:01] neredsenvy: the 1.2k load time
[23:12:07] neredsenvy: I have been getting page load times of 1000-2000 since last change which was using sass
[23:12:34] neredsenvy: I tried switching back to just css is messes up my look but the load is down to 8ms
[23:12:35] jammanbo: dagen: yes that is all correct. try it.
[23:12:53] dagen: hm and what i need to open first?
[23:13:02] dagen: first or second i stucked)
[23:13:06] nerium: If I want to use the counter cache on a relation, should I use #size or #count?
[23:13:44] jammanbo: my convention, if you render @users, it will output the views/users/_user partial for each element of @users, and in each partial the user variable will be the current element of the @users array
[23:14:43] Mosselman: neredsenvy: are there no queries in those actions?
[23:15:21] dagen: stack level too deep
[23:15:32] jammanbo: Seriously man, can't write all your code for you ??? You've got enough there to be getting on with. It's totally standard stuff.
[23:15:45] Mosselman: neredsenvy: set this: ` config.log_level = :debug` in `config/environments/development.rb`
[23:15:50] Mosselman: so that you can see what is taking so long
[23:15:55] dagen: jammanbo please what i must to do to use your code.
[23:16:14] dagen: i try to use it but there ios an error: stack level too deep
[23:16:57] dagen: i try to understand your decision
[23:17:15] dagen: and i think is much more better but i cant understood yet how can i use it
[23:18:16] neredsenvy: Mosselman: None, I switched back to SASS now i get 1k to 2k ms load time.
[23:18:47] Mosselman: neredsenvy: did you do the above? It should give you some insight into what is taking how long
[23:18:51] Mosselman: per partial, etc.
[23:19:14] dagen: jammanbo when i try to use <% render @users %> i see this: Trace of template inclusion: app/views/users/_user.html.erb, app/views/users/_user.html.erb, app/views/users/_user.html.erb, app/views/u...
[23:19:27] neredsenvy: on GET uikit.css.scss 1574ms
[23:19:55] neredsenvy: But all I have of sass is two lines of image-path()
[23:20:15] neredsenvy: the CSS it self is 6000 lines
[23:20:54] neredsenvy: but when loaded as css it's 8ms load time simply adding .scss gives 1000-2000 ms load times
[23:21:08] neredsenvy: rest loads ok its just the css file
[23:21:17] Affix: neredsenvy: Are you compiling and compressing your resources?
[23:22:24] Affix: if not add these to your config/environments/*.rb
[23:22:27] Affix: config.assets.compile = true
[23:22:30] dexter91x: any example of moving this raw sql to activerecord so i can do interpolation ? http://pastebin.com/hf0uRarA
[23:22:35] Affix: config.assets.compress = true
[23:22:45] neredsenvy: Affix: Ok will add and restart server
[23:22:57] Affix: is this production/dev/test?
[23:22:57] neredsenvy: Wait I already have those lines
[23:22:58] agent_white: Afternoon folks
[23:23:06] neredsenvy: Affix: Dev I already have those lines
[23:23:22] Affix: Are they true or false?
[23:23:30] dexter91x: any example of moving this raw sql to activerecord so i can do interpolation ? https://gist.github.com/Code-Vortex/e4cd38ffdeba7a578661
[23:23:51] neredsenvy: Affix: True also have this line config.assets.css_compressor = :sass
[23:24:10] Mosselman: neredsenvy: 6000 lines of css?
[23:24:34] Affix: I didn't notice that Mosselman
[23:24:42] Affix: Yeah neredsenvy Why 6,000 lines of CSS?
[23:25:16] Mosselman: No wonder it takes forever ;)
[23:25:23] Mosselman: depending on your machine of course
[23:25:31] Affix: not even bootstrap is 6,000 lines lol
[23:25:45] neredsenvy: Affix: Mosselman it's bootstrap.
[23:25:55] Mosselman: neredsenvy: You should leave bootstrap as it is
[23:25:59] Affix: neredsenvy: I run bootstrap all the time
[23:26:04] Affix: My loads are way less
[23:26:07] Mosselman: and override what is needed from within other css files
[23:26:13] Affix: neredsenvy: Are you using min?
[23:26:14] Mosselman: otherwise you get this
[23:26:32] Mosselman: Why are you adding 'scss' to the path of it?
[23:27:03] Affix: neredsenvy: use bootstrap-rails gem
[23:27:29] dagen: i think i understand)
[23:27:36] Affix: then just add //= require bootstrap.min
[23:27:41] Affix: to the application.css.sass
[23:27:51] neredsenvy: Affix: Mosselman when I remove scss extension and image-path the load time goes down to 8ms
[23:27:51] neredsenvy: And the images are only 100kb each
[23:27:51] neredsenvy: and 2 of them
[23:28:05] rushed: neredsenvy: or https://github.com/twbs/bootstrap-sass ...generally speaking a google or two with "rails" + the tool you want to use might save you some time :)
[23:28:06] Mosselman: we use this one: https://github.com/twbs/bootstrap-sass
[23:28:16] Mosselman: haha you beat me to it
[23:28:29] Mosselman: neredsenvy: did you not read what we said above?
[23:28:39] neredsenvy: But if I use css then I can link image files
[23:29:03] Mosselman: neredsenvy: please read what we said above :)
[23:29:35] Mosselman: from "neredsenvy: Affix: Mosselman it's bootstrap." onward has all you need to know
[23:30:53] ner0x: Any reason to use activerecord-session_store over cookies? I'm getting a ActionDispatch::Cookies::CookieOverflow exception at the moment. It's the reason for my thinking about switching.
[23:30:56] Mosselman: bootstrap should be treated as a basis to work on. Something you include and then, with the use of your own css files, you change other things. Using a gem for including bootstrap will make it even easier and less error prone. On top of this you will gain access to the bootstrap variables in sass.
[23:35:51] Mosselman: neredsenvy: or no?
[23:37:09] neredsenvy: Mosselman: I prefer UIKit
[23:37:17] neredsenvy: Over Bootstrap
[23:37:26] Mosselman: neredsenvy: that is pretty much besides the point ;)
[23:38:28] Mosselman: neredsenvy: to answer your question more directly: the reason it takes so long to load that file when you add `.scss` to it is that when it is just `.css` the file just gets server straight away. When you add `.scss` the file gets handed to SASS first which will then process it pretty much line by line.
[23:39:09] Mosselman: neredsenvy: even if you prefer UIKit you can still do: 1. load bootstrap.css, 2. load uikit.css, 3. load your own .scss files with customisations
[23:39:24] Mosselman: you should never change the files of frameworks like sass and uikit
[23:39:44] centrx: What if I want to
[23:40:01] Mosselman: centrx: you can do whatever you want of course, but what I mean is that I advice against it ;)
[23:40:20] Mosselman: You can override rules in the css in custom files that you load after bootstrap
[23:40:51] Mosselman: That way you can still update bootstrap without having to sift through 6000 lines of code to find out what you changed in the first place.
[23:52:23] neredsenvy: On a side note how do you load a font in rails/sass
[23:58:15] dachi_: Hi. I've got a third-party command line application written. Which tools do I use to communicate with it, or should I write a separate wrapper for rails to talk with it?