« Back to channel list

#RubyOnRails - 24 August 2013

« Back 1 day Forward 1 day »
[00:00:58] joshsmith: is it standard to run rake assets:precompile now before pushing up to Heroku
[00:04:26] lsone: Depends on how you are handling your assets.
[00:04:31] lsone: We do it to greatly reduce deploy times.
[00:04:43] lsone: But I don't know if it is really the standard yet.
[00:11:26] brendan6: hellion: what do you mean less secure? That I believe permits all so if its from an untrusted source, yes, that is unsecure
[00:11:46] brendan6: hellion: You should explicitly outline which parameters you want to permit
[00:12:47] brendan6: joshsmith: No, your assets will compile on deployment. Try not to compile your assets locally and check them into git, this will increase your repository size
[00:13:26] joshsmith: brendan6: I'm doing a very painful upgrade to Rails 4 and it keeps breaking on precompiling
[00:13:30] hellion: brendan6: Im trying to pass dynamic hstore keys into my params…but things are not working. permit! works, of course.
[00:13:44] joshsmith: also these deploys are significantly slower than they were previously
[00:14:00] joshsmith: one timed out for taking longer than 15 minutes
[00:14:54] brendan6: hellion: http://theotherzach.com/writes/2013/3/11/rails-4-postgres-array-hstore-and-strong-params-guide-by-someone-that-likes-you
[00:16:28] brendan6: joshsmith: are you given a stack trace when it breaks or is it just timing out? Does compiling locally work?
[00:16:43] joshsmith: compiling locally is working, yes
[00:17:02] joshsmith: I'm running another deploy right now and we'll see if this one gives some more useful information
[00:17:13] joshsmith: at one point it just said an unknown error occurred and it was reported to Heroku
[00:17:25] joshsmith: possible it's just hitting some bad servers
[00:17:53] joshsmith: this is still dreadfully slow
[00:18:45] hellion: brendan6: Ive read that. Thanks. I just figured out how to do what I need…
[00:19:16] joshsmith: compiled slug size is 64.3MB, eesh
[00:19:41] bricker: joshsmith: the version of sprockets-rails used with rails 4 merged in the changes to the turbo-sprockets-rails gem, it should be faster if anything
[00:19:57] bricker: I'm surprised to hear that it's slower than rails 3
[00:20:11] bricker: I mean, I have only noticed it being faster
[00:20:21] joshsmith: it's much much slower for me
[00:25:20] brendan6: hellion: consider putting the dynamic hstore values into their own namespace and permitting all of those
[00:25:31] brendan6: joshsmith: what version of rails did the application start out as?
[00:25:44] hellion: brendan6: thanks for the help!
[00:25:44] joshsmith: 3.2.13, recently upped to 3.2.14
[00:25:52] brendan6: I agree with bricker, I have only noticed it being faster
[00:26:15] obelich: cya later sayonara mina san
[00:26:15] joshsmith: yeah I mean with a 'nilla rails 4 app I've seen it noticeably faster
[00:26:27] brendan6: joshsmith: did you remove the asset group, that is no longer needed in rails 4. Also ensure that you have updated your config files accordingly
[00:26:41] joshsmith: I did remove that and followed the upgrade guides
[00:26:50] brendan6: joshsmith: are you using compass?
[00:27:25] joshsmith: in fact we're removing most of our view code soon because we went from this web MVP to now a Grape API backend for a mobile app
[00:29:45] brendan6: joshsmith: Very odd. I'd chalk it up to Heroku then, wouldn't be the first time something is going oddly over there
[00:30:12] brendan6: joshsmith: Personally, I'd consider Chef + DigitalOcean
[00:31:52] joshsmith: I think maybe if we have to scale up we'll consider such a move
[00:31:56] joshsmith: heard many good things about DO lately
[00:32:15] brendan6: You already start off saving $30 /month
[00:33:02] joshsmith: yeah that's not worth the time investment yet
[00:36:37] sdwrage: is there an easy way to get the subdomain from a controller action?
[00:41:13] brendan6: sdwrage: request.subdomain
[00:41:28] sdwrage: brendan6, thanks :)
[00:49:57] joshsmith: brendan6: and now it's randomly giving me fast deploys
[00:50:01] joshsmith: 15 seconds vs 15 minutes
[00:51:41] Senjai: Hello all
[01:22:03] Senjai: I have a really interesting error when running a test to ensure that a user cannot delete themselves.
[01:22:05] Senjai: https://gist.github.com/Senjai/6325446
[01:22:11] Senjai: The first scenario passes
[01:22:18] Senjai: but the second throws an AR is not found
[01:22:31] Senjai: all helper methods work as intended and have been tested thoroughly in other tests.
[01:22:35] Senjai: What am I mising?
[01:23:11] s2013: are you using that rials 3 in action book or something?
[01:23:47] Senjai: s2013: rails 4 in action
[01:23:54] Senjai: Updated gist with show view
[01:24:07] s2013: it has to do with current_User i believe
[01:24:44] Senjai: s2013: I don't really see a problem there. It's just trying to find the admin_user which it says it cant
[01:25:31] s2013: Senjai: https://getsatisfaction.com/railstutorial/topics/how_to_prevent_admin_user_from_deleting_themselves
[01:25:42] joshsmith: Rails is trying to parse YAML with JSON
[01:26:59] Senjai: s2013: Derp, it's failing how it should be
[01:27:02] Senjai: s2013: wow I'm slow
[01:28:54] s2013: atleast you undersand it now.
[01:29:09] s2013: anyways, when you upload a video do you need to convert it?
[01:29:09] Senjai: s2013: Nono, I understood it
[01:29:19] s2013: cause there still isnt a cross browser standard
[01:29:20] Senjai: s2013: Depends :?
[01:31:41] s2013: basically i want users to be upload a video
[01:31:48] s2013: and it would play using a video player
[01:32:06] s2013: i can use an external solution but thats expensive
[01:33:22] soahccc: I created a new rails 4 project and as far as I want to use coffee script I get this error (the file has nothing in it!) "throw Error("JSON::GeneratorError: only generation of JSON objects or arrays allowed\n (in /Vo..scripts/application.js.coffee)")". What the hell could that be?
[01:36:54] chuck: Which JSON implementation does render :json {"foo" => "bar"} use?
[01:37:36] s2013: what do you mean by json implementation
[01:39:37] chuck: s2013, JSON parser, whatever.
[01:59:19] bonhoeffer: anyone get something like this on bundle: Errno::EPERM: Operation not permitted - /var/www/foo.com/shared/bundle/ruby/2.0.0/bundler/gems/stripe-ruby-2dbc700fc35c/bin/stripe-console
[01:59:29] bonhoeffer: just got this
[02:11:00] Senjai: I made a gross ish script to wipe my mysql database. How can I refactor this and/or bring in pluralize from active support for the model naming? https://gist.github.com/Senjai/6325626
[02:17:00] Duckily: does this make any sense? NoMethodError: undefined method `each ' for #<Array:0x0000000a5759b8>
[02:17:14] helpa: We cannot help you with your problem if you don't show us your code. Please put it on http://gist.github.com and give us the URL so we can see it.
[02:17:25] Senjai: brownies: Hiiii
[02:17:31] soahccc: Duckily: bad space?
[02:17:33] Senjai: brownies: GUESS WHAT :)
[02:17:56] Duckily: brownies: Shift.each { |s| s.save! }
[02:18:09] brownies: Senjai: what?
[02:18:13] Duckily: oops Shift.all.each { |s| s.save! }
[02:18:19] soahccc: Duckily: retype the space after each
[02:18:35] Senjai: brownies: I got my first full time gig as a rails dev ^^
[02:18:46] Duckily: soahccc: woah, what why?
[02:19:16] soahccc: Duckily: If you're on a mac you may have inserted a non breaking space with alt+space
[02:19:22] alan_andrade: @Senjai I don't think that script works. f is a file, not a class name. Also, I don't I get your question.
[02:19:37] Senjai: alan_andrade: it works, I've tested it
[02:19:40] soahccc: Duckily: I fail for that every other day
[02:19:55] Senjai: alan_andrade: It takes the name of a model, slices the .rb off of it, pluralizes it, and then truncates that table in the db
[02:19:59] Duckily: soahccc: my mind was just blown. so glad you were here, i bet that could have easily been a 3 hour problem
[02:20:20] Duckily: soahccc: how did you figure it out the first time?
[02:20:24] Senjai: alan_andrade: It's just... gross
[02:20:34] Senjai: alan_andrade: I can't figure out how to pull in pluralize from active_support, and It should probably be refactored.
[02:21:01] Senjai: alan_andrade: also, it only works for mysql databases. Or databases that support TRUNCATE"
[02:21:27] soahccc: Duckily: I figured like 3 hours ^^ and the saw it while selected the affected code: http://files.sven.bmonkeys.net/images/foo-20130824-042124.png
[02:22:16] brownies: Senjai: whoa. congrats? where?
[02:22:27] brownies: er, "congrats!" not "congrats?"
[02:23:02] Senjai: brownies: http://stefanikmarketing.com/ It's the top marketing in our region, and they dont really have much backend expertise, just design which is perfect.
[02:23:45] Duckily: soahccc: weird i don't see anything when selecting it
[02:23:50] Senjai: brownies: Mostly for SaaS solutions along with another developer for logistics providers or something.
[02:24:17] soahccc: Duckily: My editor puts this little dot there for spaces if I select text
[02:24:26] Duckily: soahccc: ah, thanks again
[02:26:48] alan_andrade: @Senjai To include the pluralize functionality, require 'activesupport/ext/string'
[02:27:04] alan_andrade: Or might be in other ext/ class, don't remember well.
[02:27:10] Senjai: alan_andrade: how'd you figure that out? Just curious
[02:27:36] brownies: Senjai: nice. sounds like a good environment for you to learn by doing... everything.
[02:28:03] Senjai: brownies: It's my first step from transitioning from business to programming, actually getting paid to code will help me learn a lot faster imo
[02:28:27] brownies: Senjai: what were you doing on the business side?
[02:28:28] Jason: is there a guide on installing rails 4 on a mac?
[02:28:39] Jason: I know I need rails 2(?), and my mac doesn't seem to have it.
[02:28:41] Senjai: brownies: I'm a business development consultant for the City of Sechelt
[02:28:43] Jason: err, ruby
[02:28:53] Senjai: brownies: and I've done consulting for mining firms and other municipalities
[02:29:16] Senjai: Jason: Open your terminal
[02:29:52] Senjai: Jason: enter the following in your terminal: \curl -L https://get.rvm.io | bash -s stable --rails
[02:30:11] Jason: Senjai: RVM?
[02:30:24] Senjai: Jason: Yes.
[02:31:14] Jason: Senjai: alright. next?
[02:31:23] Senjai: Jason: did it install?
[02:31:33] Senjai: hit enter
[02:33:33] Jason: Senjai: sorry, it looked like it was just syncing. it's not done yet.
[02:33:36] alan_andrade: @Senjai A lot of rails magic comes from ActiveSupport extensions to core. You can dig more in the Guides
[02:33:57] Senjai: alan_andrade: I got a load error trying to include it like that
[02:34:57] Senjai: alan_andrade: Bleh, fixed it
[02:37:32] zr2d2: anyone know if cancan is planning to update for rails 4?
[02:37:47] sevenseacat: probably eventually
[02:37:54] sevenseacat: still waiting for rails 3.1 upgrade
[02:38:37] max96at: how do I check if a symbol matches a string?
[02:39:00] alan_andrade: @max96at :symbol == "foo".to_sym
[02:39:20] max96at: any way without getting a symbol from the other variable?
[02:39:33] max96at: or string from the symbol for that matter
[02:40:42] alan_andrade: So you're interested in mathcing the class or the value it holds ?
[02:41:26] max96at: without creating a new object from either of them
[02:41:36] alan_andrade: I don't know any other way of checking if a symbol matches a string. I mean, those are fundamentally different things, so you'll need to convert at least one.
[02:41:53] alan_andrade: Why you want to avoid that
[02:42:19] alan_andrade: I'd convert both object to_sym since it's cheaper than converting to_s
[02:42:34] alan_andrade: :symbol.to_sym == "symbol".to_sym
[02:42:48] max96at: well, the advantage of symbols is that they only use one slot in memory, but if they're only used for a single word it's a waste of memory since it won't get garbage collected
[02:43:32] alan_andrade: Agreed. What are you're though on the solution ?
[02:43:34] max96at: the string would get gc'ed but it still seems weird that there's no other way of doing this :/
[02:44:01] alan_andrade: What would be THE way ?
[02:44:31] max96at: something like :name.match 'name'
[02:45:00] max96at: since ruby internally knows the symbol's and string's value
[02:45:32] alan_andrade: Ohh, I think that's possible.
[02:45:42] brownies: Senjai: oh, interesting
[02:46:25] alan_andrade: Dude, I think it's doable
[02:46:51] alan_andrade: :a.match /a/ => 0
[02:47:02] alan_andrade: which is not nil, thus there was a match
[02:48:12] max96at: hmm, interesting
[02:48:39] alan_andrade: you can use a block to match which will only execute if there was a match.
[02:49:03] alan_andrade: :a.match(/a/){ "I matched :) " }
[02:49:20] max96at: but then I need to create a regex from the string :P
[02:49:30] gerep: Hi all! I have a simple question. I have a table that will save a employee or a student, how should I call it? :)
[02:49:36] max96at: damn object conversions
[02:50:40] alan_andrade: :a.match Regexp.new string_var
[02:51:03] alan_andrade: @gerep employee OR student ?
[02:51:34] alan_andrade: Sound's like you're dealing with STI ?
[02:52:07] gerep: alan_andrade, yes, I'll save the name, parents names and also where it's file is stored. Like the Student X has a file on the box N folder Y, same to the employee, got it?
[02:52:50] alan_andrade: I think so...
[02:53:19] alan_andrade: I'd create User as the parent table, and have Employee and Student be childen of that.
[02:53:44] gerep: alan_andrade, yes, that's a lot better, thanks :)
[02:54:32] alan_andrade: And think about the files features as functionality. So that later on, I can do: class User; include Filable; end
[02:54:50] alan_andrade: which sounds really bad hah, but that'd be my approach.
[02:55:04] gerep: thanks :)
[03:01:36] adizam: Does anyone have any example projects (gems/libraries) that create models using active resource for validations.. but all of their data is pushed/pulled from an external restful api (written in nodes, not that it matters). I have architecture questions.. want to see different approaches to the same problem
[03:02:33] alan_andrade: @adizam I'm in the middle of something similar
[03:03:36] adizam: @alan_andrade I have an existing working project that I want to convert to a gem/library for easier version control (match my API to my rails projects that consume the API)
[03:04:23] adizam: So right now I have a series of models.. each model calls to the single api library (basically a bunch of methods that use httparty get/post/delete/etc).. return json data.. and the model parses it into itself before return
[03:04:44] adizam: But I hate that implementation, feels so dirty.. no validation.. feel like I could use some dynamic methods to get things like Model.find_by_x, etc
[03:05:02] alan_andrade: @adizam dude, check Her out.
[03:05:04] alan_andrade: her is a gem.
[03:05:12] adizam: Haha. i was like. who?!
[03:05:26] adizam: https://github.com/remiprev/her ?
[03:05:54] alan_andrade: It uses Faraday which is super robust and configurable
[03:06:29] alan_andrade: We have some prototypes that will map the data in a piece of code that lives in the Faraday middleware.
[03:06:42] alan_andrade: Completely out of the model file/scope.
[03:07:32] alan_andrade: I imagine we could end up with config/user_mapper.yml or something similar, which will be the mapper used when we post or get data.
[03:08:12] adizam: Interesting idea
[03:32:17] cydd: how gorgeous is this guy from reddit? http://i.imgur.com/VOzvvZ8.jpg
[03:36:15] Jason: Senjai: woo
[03:36:16] Jason: Senjai: thanks!
[03:46:04] benten: Any freelancers available?
[03:49:39] Senjai: benten: For what?
[03:57:10] s2013: is there anyway to encrypt a video link or something so only authorized user can view the video?
[03:59:51] joshsmith: s2013: how do you mean?
[04:00:21] joshsmith: s2013: you can always use cancan or something
[04:00:22] s2013: like only people who are authorized to view a video can view it and i dont want them to be able to download it for offline
[04:00:27] s2013: no im not worried about that part
[04:00:37] s2013: i meant to protect the video from being downloaded
[04:00:48] joshsmith: I think they'll always be able to http sniff it
[04:00:50] s2013: or being viewed directly from the video url if that makes sense
[04:01:20] joshsmith: you can hide the url for most people
[04:01:30] joshsmith: but technically if you're serving it up over the web
[04:01:38] joshsmith: someone will always be able to figure out where it came from
[04:02:18] s2013: alright.. also any video player you recommend? i have always been crappy on videos esp when it comes to converting and making it work for eveyrone etc
[04:02:30] joshsmith: what's the use case?
[04:02:44] joshsmith: how many videos? what kind of audience? will you be making money?
[04:02:51] s2013: no its just a practice project
[04:04:05] joshsmith: for something serious I'd really recommend Wistia
[04:04:23] s2013: ive used that before and bright cove too
[04:04:26] s2013: but they are a bit expensive
[04:04:48] joshsmith: there's this https://github.com/tobsch/mediaelement_rails
[04:05:07] s2013: does wistia have a rails gem?
[04:05:10] joshsmith: you could do streaming over AWS, s3
[04:05:20] joshsmith: https://github.com/wistia/wistia-api
[04:06:02] s2013: alright. thanks
[04:06:13] Senjai: s2013: you can do what netflix does with silverlight..
[04:07:09] joshsmith: Amazon has an Elastic Transcoder service
[04:18:09] crucify_me: http://pastie.org/8264709 hi is there any difference between these 2 migrations? thanks
[04:24:39] Senjai: Ask question, disconnect.
[04:24:41] Senjai: Good strategy
[04:26:03] alan_andrade: switching nicknames ha
[04:26:24] Senjai: alan_andrade: I tried to send him a memo to answer his question, but his nick wasn't registered, so he'll learn the hard way :P
[04:26:33] Senjai: alan_andrade: E.g. I attached the nickname to this account lol
[04:27:11] Senjai: alan_andrade: I'll give it back to him next time hes on, I'm not TOO cruel, only kinda
[04:45:38] rdev5: no Radar tonight?
[05:04:08] aarkerio: hi! what is the "standard" way to create an admin area?
[05:04:58] rdev5: write a failing test, then write some code to pass that test, rinse and repeat :)
[05:07:13] Senjai: aarkerio: However you want to :)
[05:07:38] dcope: hey all, i have a form that has multiple file uploads. is there an easy way to show a single progress bar for all the files without having to use something like jquery-file-upload (rails) ?
[05:07:42] Senjai: You can use active admin for an admin area, make your own namespace for admins, or have admin functions in line with the content (best option IMO)
[05:08:01] Senjai: dcope: Progress bars for that stuff is client side, so it's javascript
[05:09:01] rdev5: I still say write a failing test, then write code to pass it, rinse and repease :)
[05:09:08] rdev5: evening Senjai
[05:09:16] Senjai: rdev5: o/
[05:09:19] Senjai: rdev5: guess what :O
[05:09:31] Senjai: aarkerio: Also yeah, TDD/BDD way to go
[05:09:38] Senjai: rdev5: I got hired as a full time rails dev :)
[05:09:52] rdev5: o rly r u for reel?
[05:09:53] Senjai: Starting at the end of sep (when my current contract for this job ends)
[05:10:04] Senjai: rdev5: I'm like, bouncy and shit
[05:10:16] rdev5: mine starts Sep 4, did I tell you about it already? I think I did
[05:10:23] Senjai: rdev5: I think so
[05:10:47] Senjai: rdev5: I just can barely fathom the idea of being paid to doa hobby :P
[05:11:42] Senjai: YEURGH, why even add scope to rails if its the same as a class method?
[05:11:42] rhizome: what are you doing now?
[05:11:53] Senjai: rhizome: Business Development Consultant for the city of sechelt
[05:11:54] rhizome: scopes are going away...maybe
[05:12:09] rhizome: bizdev, gotcha :)
[05:12:30] Senjai: I just feel like if it's done just as well and universally understood in ruby, complicating it with a helper method that accepts a proc is just... unwarranted.
[05:13:02] Senjai: rhizome: And yeah, I'm tired of business, I really just want to code for the next four years.
[05:13:03] rdev5: well congrats, the college I'll be working for come september with this new job offer will put me in a position to propose one or more new languages to migrate their ASP platform to (hint hint: PHP, Rails, and eventually Go when I get around to it)
[05:13:08] Senjai: Then I'll worry about business
[05:13:21] Senjai: rdev5: Keep me posted!
[05:13:24] rdev5: Senjai: likewise
[05:13:26] Senjai: rdev5: Also, ASP, yuck
[05:13:29] rhizome: Senjai: nah, that's a good direction to go.
[05:13:37] Senjai: rhizome: bizdev or code?
[05:13:44] rhizome: biz -> code
[05:13:55] Senjai: rhizome: Someone was suggesting i get into the industry as a project manager
[05:13:56] rhizome: result-minded
[05:14:07] Senjai: but then someone else suggested that if I was good at it, they'd never let me develop
[05:14:21] Senjai: It's just asimple job doing the backend work for a design firm
[05:14:31] Senjai: But it's an in
[05:14:33] rdev5: CTO > Project Manager > Developer [this is the place you want to be :P]
[05:14:35] rhizome: my girlfriend is a PM, you won't do much coding
[05:14:59] rhizome: programmer with a business-mind is a strong combo
[05:15:00] Senjai: rhizome: Yeah, all my buddy said is that it would be good to have those skills. But yeah, I want to be a developer :/
[05:15:07] Senjai: rhizome: I have my own business ideas
[05:15:14] Senjai: rhizome: ATM i'm just working on my skillset
[05:15:26] Senjai: The problem is getting into SF from Canada
[05:15:30] rdev5: CTO's don't get to do anything but run tech errands for the CEO all day, they consult with the Project Manager, giving him things to manage and if he has time, build himself, but the developer is the guy that's buffered away from all the politics surrounding the CTO and Project Manager positions, he just gets to do what he loves and get paid for it :)
[05:15:33] Senjai: It's hard to get a visa without a business degree
[05:16:03] rhizome: cross that bridge when you come to it
[05:16:22] Senjai: rdev5: CTO like any C-Suite position is just day to day direction in the absence of the board.
[05:18:13] Senjai: but hopefully I can use this as leverage to get into a SaaS gig or the like
[05:18:21] lethjakman: rdev5: how do you plan on porting ASP to go?
[05:18:44] lethjakman: I read an article about that recently and it sounded really appealing, but I didn't see any frameworks anywhere near as nice looking as rails
[05:19:15] Senjai: lethjakman: rails is convention over configuration, sometimes you need ugly looking code and low level memory management ;)
[05:19:59] rdev5: or a complete rewrite :)
[05:20:23] lethjakman: Senjai: I know, and that's what I love about rails.
[05:20:44] rdev5: as it stands, I'm ready to go to town with CodeIgniter and PHP ActiveRecord ORM but eventually want to migrated over into Rails
[05:20:45] lethjakman: honestly I just want something similar. unit tests and some nicities
[05:21:05] lethjakman: rdev5: what's preventing you from rails the first time?
[05:24:41] aarkerio: so, there is a way to create an "URL shortcut"? I means convert "/pages/mypage" to "/whatever" using routes.rb?
[05:27:51] rdev5: lethjakman: I don't feel entirely confident in my experience in Rails just yet. I've taken a lot of courses, etc and am going through Ryan's book now but I'll probably start throwing together some apps after this
[05:28:10] rdev5: I started in PHP since 2004 and feel I've only begun to take off with it since 2010
[05:28:26] rdev5: so I'm not sure what to expect in terms of language acquisition here and application
[05:28:49] rdev5: Rails has been a fairly steep learning curve that I think I'm just now starting to get on top of
[05:29:08] rdev5: loving it so far though
[05:43:03] dcope: are javascript templates in haml possible?
[05:45:02] aarkerio: dcope, what do you mean? set JS code in haml?
[05:47:01] dcope: aarkerio: like a javascript template.. i found out you can with %script{:type => "x-tmpl"} ... but just wondering if you can put js within that?
[05:47:04] dcope: instead of using :javascript
[05:49:39] aarkerio: I think you need to insert a coffescript file
[06:01:11] SicutDominus: REGISTER SicutDominus
[06:02:25] SicutDominus: NickServ REGISTER SicutDominus
[06:02:31] SicutDominus: jesus i have no idea what i'm doing
[06:03:12] SicutDominus: this is where I can ask the pros questions I have about ruby on rails, right?
[06:03:24] willbradley: this is where ruby on rails people hang out :P
[06:03:40] willbradley: your questions may or may not get answered, but some people might be able to help
[06:03:44] rdev5: too tired to think of something clever
[06:04:29] SicutDominus: I've done some basic mucking around with Heroku, but then came across an article online that said they were being really dodgy by using unoptimal worker assignment
[06:04:43] SicutDominus: that slowed down all their stuff, making people pay for more of their services than they would otherwise need
[06:05:12] SicutDominus: in light of this context, are there any other hosting services for RoR apps that are easy for a beginner and free to play around with?
[06:05:35] SicutDominus: http://news.rapgenius.com/James-somers-herokus-ugly-secret-lyrics
[06:05:36] SicutDominus: that's the article
[06:07:20] willbradley: haven't heard about it. i use heroku.
[06:07:42] willbradley: free/beginners shouldn't need speed anyway
[06:07:46] brownies: that's a known reality of heroku
[06:07:59] SicutDominus: that's why I thought it was good, because I could try it out for free
[06:08:01] brownies: we kept using it anyway after that.
[06:08:02] brownies: ACTION shrugs
[06:08:41] SicutDominus: I like that it's free to start, but I have plans for something that might become very very high traffic, so I need something that I know is going to be ok at large volumes
[06:08:49] brownies: it's going to be fine.
[06:09:10] willbradley: if you're dealing with very very high traffic, "easy for a beginner and free to play around with" is no longer a high priority
[06:09:41] SicutDominus: if there's other good, well-regarded options, I'm interested to take a look
[06:09:50] SicutDominus: beginner friendly preferred, but not essential
[06:13:16] tubbo: SicutDominus: remember that such articles were written by fairly high traffic sites. rapgenius comes to mind.
[06:13:34] tubbo: SicutDominus: i host all my apps on heroku and i've never had a problem. all free apps, too. i love it. really makes deployment painless.
[06:13:51] SicutDominus: exactly, that's why I'm concerned, because I'm looking into something that might scale to be a huge subscription service
[06:14:03] SicutDominus: with thousands of users making hundreds of server requests a day
[06:14:05] tubbo: if it does, it won't be very hard to move off of heroku. trust me.
[06:14:12] SicutDominus: ok cool thanks
[06:14:13] tubbo: you keeping everything in git?
[06:14:24] tubbo: then you're good :P
[06:14:54] tubbo: SicutDominus: if you really are anticipating high load, you might want to check out vagrant and chef-solo, because they're ways to build boxes from scratch and test them locally.
[06:15:09] tubbo: i use chef for this one app that requires the use of two different apps (sinatra and rails) running side-by-side
[06:15:20] SicutDominus: noted, thanks
[06:15:48] tubbo: you might be interested in it...because it redirects http://domain.com to http://www.domain.com, circumventing the problem of hosting a heroku app on your own domain, which you have to CNAME..thus you can't host it as the top-level record.
[06:15:57] SicutDominus: also, if I'm planning to use heroku does that mean I should develop my database in postgresql from the start?
[06:16:06] tubbo: you should like, do that anyway
[06:16:10] tubbo: because it's the best database :)
[06:16:23] SicutDominus: so that's "rails new example_application -d postgresql" right?
[06:16:27] tubbo: postgres is real easy to develop with, i don't use sqlite anymore.
[06:16:39] SicutDominus: is that a matter of opinion, or by community consensus?
[06:16:44] tubbo: yeah i use rails new APPNAME --skip-bundle --database=postgresql
[06:17:31] SicutDominus: and all the rails helper methods for databases, as well as my introductory MYSQL will transfer across I assume?
[06:17:33] willbradley: sqlite is only useful for very lightweight development. it's not multi-threaded so an app with any sort of usage at all will lock up
[06:17:53] tubbo: it's a matter of opinion, but the community is overwhelmingly choosing postgres for new apps, as evidenced by rails' recent integration of the stuff that the pg_ext gem used to provide, which is support for types like hstore (which is exposed as a ruby hash in activerecord) and array (exposed as a ruby array in activerecord)
[06:18:08] tubbo: introductory mysql?
[06:18:12] tubbo: what do you mean?
[06:18:18] SicutDominus: as in I have learnt a bit of basic mysql
[06:18:26] willbradley: yeah, postgres isn't weird
[06:18:30] SicutDominus: and I assume i can reuse the same commands
[06:18:37] willbradley: just google how their datatypes work
[06:18:43] tubbo: yeah basically. just remember that it only accepts single quotes for string literals
[06:18:50] SicutDominus: thank you tubbo and willbradley, very very helpful
[06:18:58] tubbo: so SELECT * FROM table WHERE name = "blah" is invalid, but SELECT * FROM table WHERE name = 'blah' is
[06:19:19] tubbo: no problem man, hope you have fun with this stuff!
[06:20:04] SicutDominus: it's been good so far, just about getting past the point where I can build something useful and make money hahaha
[06:25:50] jrobeson: hmm.. if all that stuff about postgres is true.. when are they gonna make active record deal with foreign keys by default :)
[06:32:42] rhizome: => Rails 2.2.2 application starting on
[06:34:05] tubbo: rhizome: thanks for this.
[06:35:05] cydd: http://www.youtube.com/watch?v=gCFB-s2-Pkc
[06:35:09] cydd: does that sound cool?
[06:44:20] rhizome: don't worry, it didn't actually start :)
[06:44:47] rhizome: cydd: any other reddit crap you wanna paste?
[06:45:16] cydd: that was from reddit?
[06:50:55] rhizome: dunno, i didn't watch it
[07:06:27] grahamsavage: model is too big.. what's a good option.. create a subfolder, create modules in separate files and then use include?
[07:06:36] grahamsavage: or reopen the class?
[07:11:01] grahamsavage: ok.. i'm just going to create a folder called /models/#{section_of_app}/modules and stick all them all in that
[07:11:25] grahamsavage: some of these models are thousands of lines of code so it's just ridiculous
[07:14:09] rhizome: use something that's already autoloaded, like vendor/lib
[07:15:08] grahamsavage: problem if i move it in there, in lib there's already a ton of stuff that is not model related
[07:15:34] grahamsavage: like various servers, and background tasks and api's etc
[07:16:10] grahamsavage: i also don't want it in the /models/#{section_of_app} directories either because then it's hard too at a glance, see what's a model and whats not
[07:17:05] grahamsavage: i'm recursively loading every file under /app at the moment
[07:17:13] grahamsavage: sorry under /app/models/**/*
[07:28:25] kgeo: Hiall, I am running an app on heroku for a customer. At the moment it is small enough to run for free. I would like to run background processing. To keep it free I thought of shutting down the app late in the evening (the users only use it during office hours anyway) the same amount of time the background processed used. two questions: 1. how do I determine how long the background process worked. 2. How do I shut down the app for that speci
[07:28:25] kgeo: fic amount of time.
[07:42:10] nomadmonad: kgeo, try this on any production machine with bash, 10 h * 60*60 = 57600 secs: heroku ps:scale web=0 ; sleep 57600 ; heroku ps:scale web=1
[07:42:30] nomadmonad: naturally it's way better to set up a cron job to scale down and back up
[07:42:40] rhizome: ah, vendored rails. i missed you.
[07:43:29] kgeo: nomadmonad, thanks for the tip. will try
[08:30:57] rhizome: it's official: rails 2.3 is now bizarre
[08:46:30] rhizome: or this app is. regardless, sleep time.
[08:50:24] D3javu: I wont that customer make new event and i will be visible in upcoming events and when these events expire(by_date) will be deleted from upcoming and automatic added to the past events??
[08:51:21] ljarvis: is that a question?
[08:52:02] D3javu: How do I do that?
[08:52:38] ljarvis: I'm not sure I understand your question, but it sounds like you want a cronjob to update 'old' events to be marked as past events
[08:52:45] ljarvis: that said, I don't think it's necessary
[08:53:08] D3javu: yes a cronjob
[08:53:11] ljarvis: this is what scopes were built for
[08:53:15] D3javu: I relative new to rails
[08:53:21] ljarvis: there's no need for a cronjob
[08:54:09] ljarvis: scope :upcoming, -> { where(date >= 2.weeks.ago }
[08:55:00] ljarvis: sorry that was terrible, where('date >= ?', 2.weeks.ago)
[08:57:16] D3javu: these I write in controller?
[08:58:05] D3javu: no nead for the answer..I got it :D
[08:58:18] D3javu: ljarvis: tnx for advice
[09:07:50] Luis_: Hi, I've updated to rails 4 recently. But, now I've had a problem with: ActionDispatch::Cookies::CookieOverflow
[09:09:31] Scient: not related to rails 4 id say
[09:09:41] Scient: cookies have a max of 4KB size limit
[09:09:46] Scient: youre stuffing too much data in your cookies
[09:09:54] Luis_: I've try do change by (App)::Application.config.session_store :active_record_store but I can do "rake db:sessions:create"
[09:10:06] jammanbo: mmm … over-stuffed cookies
[09:10:08] Scient: or in your case its probablys stuffing too much things into session
[09:10:16] Scient: just dont Luis_
[09:10:23] Scient: dont put so much stuff into session/cookies
[09:10:27] Luis_: yes I'm using session
[09:10:32] Scient: do not EVER store objects in there, always store like id-s etc
[09:10:50] Scient: im 99.99% sure you are storing large object trees in your sessions like proper beginner :D
[09:11:02] Onslauth: Hi Guys, sorry to bother you all.
[09:11:06] Scient: 4KB should be enough for most stuff
[09:11:09] Onslauth: I was hoping someone might be able to to help
[09:11:16] Onslauth: I am trying to call a partial recursively
[09:11:26] Onslauth: and it doesn't seem to work so well
[09:11:39] Onslauth: I am trying to use it as part of a form
[09:11:42] Onslauth: using simple form
[09:13:08] Onslauth: I have this - https://gist.github.com/anonymous/6327056
[09:13:26] Luis_: Thanks Scient, I'm going to try to fix this, I hope that your answer help me.
[09:13:29] Onslauth: However, the render partial doesnt seem to do anything when called from itself.
[09:13:49] Onslauth: the puts is showing that its being called
[09:15:31] Onslauth: I just saw the problem :(
[09:15:36] Onslauth: Sorry for the hassle
[09:23:16] boytoy: Is it a no-no to try to render Rails views from Rack? http://stackoverflow.com/questions/11512825/rack-middleware-how-to-redirect-to-a-view-in-my-rails-application
[09:23:19] boytoy: Was gonna move this IE blocker from the application controller to Rack but now I'm having second thoughts: http://ruby-journal.com/how-to-block-old-ie-version-with-rails/ -- but now I'm not so sure it's a good idea.
[10:01:36] lessless: folks, what is the possible reason of undefined method `call' for true:TrueClass for Rspec test: expect(create_user).to change(User, :count).by(1) ?
[10:03:03] ljarvis: I thought it had to be wrapped in a proc.. expect(create_user).to change{User.count}.by(1)
[10:03:33] ljarvis: expect{create_user}.to change{User.count}.by(1)
[10:03:52] ljarvis: blocks need to be used to record before/after states
[10:05:39] triptec: I have 3 models, City, Tour and CityTour, City has many Tours through CityTour and the price of a Tour is stored in CityTour, Now I'm haveing a hard time to visulize how I would show Available Tours with price when we have a known City, or have I just choosen a bad naming scheme?
[10:06:23] ljarvis: triptec: city.city_tours.each { |ct| ct.price; ct.tour }
[10:06:41] ljarvis: just loop the join
[10:07:16] ljarvis: or, city.tours.select('tours.*, city_tours.price') { |tour| tour.price } will probably work too
[10:08:48] triptec: ljarvis: thanks a lot
[10:09:08] triptec: hate not knowing how to solve before hacking away
[10:09:53] ljarvis: it comes with experience, just remember join models are just normal models/associations, dont fear using them for results
[10:16:24] NDD: hello world
[10:17:12] NDD: anyone home?
[10:17:46] ljarvis: NDD: there's over 500 people in here :)
[10:18:06] NDD: I'm aware, but it's all so quiet
[10:18:23] NDD: I'm trying to get postgresql to work on my local machine for the first time
[10:18:34] ljarvis: what's the problem?
[10:18:36] NDD: was previously using mysql and the default sql lite
[10:18:40] NDD: which was good
[10:18:42] NDD: but now
[10:18:52] NDD: I go to localhost:3000
[10:18:57] NDD: after running "rails server"
[10:19:00] NDD: and get an error message
[10:19:05] ljarvis: NDD: keeping everything on one line/sentence would help me a lot
[10:19:14] NDD: could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server:
[10:19:23] ljarvis: is postgres running?
[10:21:16] NDD: Hang on, I've now got a new problem, the old one left. It now says "FATAL: role "my_application_name" does not exist"
[10:21:42] ljarvis: change the username in database.yml to your username
[10:21:48] ljarvis: or create a new one
[10:22:17] NDD: how do I create a new username?
[10:22:32] ljarvis: createuser foo on the command line
[10:22:37] ljarvis: where foo is the new username
[10:23:29] NDD: $createuser root Shall the new role be a superuser? (y/n) y createuser: could not connect to database postgres: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
[10:23:44] ljarvis: postgres is not running
[10:24:31] NDD: I downloaded postgres app, and i've started it. It created a new thing in my bar at the top of the screen (whatever you call it) next to the clock
[10:24:50] ljarvis: NDD: what's the output of `which psql`?
[10:25:12] NDD: psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
[10:25:34] ljarvis: you need to type 'which psql' sans quotes on the command line
[10:25:51] NDD: that was the output right there
[10:26:11] NDD: $psql psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
[10:26:18] ljarvis: heh, ok `type psql`
[10:26:37] NDD: $type psql psql is hashed (/usr/bin/psql)
[10:26:49] ljarvis: right, there's your problem
[10:26:55] ljarvis: http://postgresapp.com/documentation#toc_1
[10:27:07] ljarvis: you need to alter your PATH to use the correct psql binary
[10:27:37] ljarvis: this will make things like psql,createuser,createdb work as expected
[10:28:21] NDD: ok nice, thanks for the help, I'll see if I can get that to work
[10:32:22] NDD: right, so I added the /usr/bin/psql bit to my .bash_profile file, and now running "rails server" from my application root and going to localhost:3000 returns
[10:32:23] NDD: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
[10:32:48] ljarvis: what exactly did you add to PATH?
[10:34:05] NDD: i added "export PATH= '/usr/bin/psql:$PATH" to my .bash_profile
[10:34:15] ljarvis: you didn't read the documentation
[10:37:21] NDD: tbh the documentation isn't making a lot of sense to me....
[10:37:42] ljarvis: PostgreSQL ships with a constellation of useful binaries, like pg_dump or pg_restore, that you will likely want to use. Go ahead and add the /bin directory that ships with Postgres.app to your PATH (preferably in .profile, .bashrc, .zshrc, or the like to make sure this gets set for every Terminal session):
[10:37:47] ljarvis: PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
[10:37:50] ljarvis: that's what it says
[10:37:57] ljarvis: what part are you finding difficult?
[10:38:35] NDD: hang on, am I supposed to add that provide path into .bash_profile? Seems like it wants you to run it and a couple of other things in terminal, which isn't helping. I'm such a noob
[10:39:04] ljarvis: NDD: remove the line you added and replace it with: export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
[10:39:22] ljarvis: this is adding the postgres command line tools that ship with Postgres.app to your PATH
[10:39:32] ljarvis: rather than using the system ones that are not mapped to Postgres.app
[10:39:45] lessless: how to test that email has changed with rspec?
[10:39:56] ljarvis: lessless: 'email has changed' what does that mean?
[10:42:01] NDD: I've added the path to .bash, but running "rails server" and visiting localhost:3000 still comes back with "could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?"
[10:42:26] ljarvis: NDD: be patient :) open a new terminal session and type `psql` again
[10:42:40] lessless: ljarvis, there is a method which creates or changes user email if user is already there and I want to cover it with tests :)
[10:43:17] ljarvis: lessless: can you show me the method?
[10:43:19] lessless: https://gist.github.com/dirty-hippie/6327391
[10:43:29] NDD: $psql psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
[10:43:45] NDD: btw ljarvis - total legend. I'm very appreciative of the help
[10:43:50] lessless: NDD, what OS do you use?
[10:44:13] NDD: osx 10.8.4
[10:44:14] ljarvis: NDD: what's `type psql` again?
[10:44:24] ljarvis: lessless: you just need expect to receive
[10:44:48] ljarvis: you're hitting the db like 3 times in that method
[10:44:49] NDD: "type psql" returns "psql is hashed (/usr/bin/psql)"
[10:44:52] ljarvis: there's no need for it
[10:44:57] ljarvis: NDD: yup path is still wrong :P
[10:45:15] ljarvis: NDD: throw the PATH line in .bashrc instead of profile (i dont use bash so not sure if that will help)
[10:45:29] ljarvis: NDD: basically, type psql needs to return the path you added to PATH
[10:45:46] ljarvis: NDD: make sure you're restarting your terminal sessions completely during the edits, of course
[10:46:01] NDD: Right, ok.
[10:46:27] ljarvis: lessless: use find_or_initialize_by and then user.persisted? and assignments instead of update_attribute
[10:46:39] ljarvis: that way you dont need to hit the db even once during tests
[10:47:05] ljarvis: and only once generally
[10:47:21] NDD: "type psql" now returns "psql is /Applications/Postgres.app/Contents/MacOS/bin/psql" but localhost and "rails server" still not coming through for me
[10:47:41] ljarvis: NDD: the same error or the user error?
[10:48:27] NDD: still this error "could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?"
[10:49:10] ljarvis: lessless: https://gist.github.com/leejarvis/4d6fc7bf74f5c48cfa8a
[10:49:30] ljarvis: NDD: and 'psql' on the command line?
[10:50:43] lessless: ok, seems nice to me
[10:51:03] NDD: "$psql" returns "psql (9.2.4) Type "help" for help. "
[10:51:15] lessless: but, receive... what?
[10:51:44] ljarvis: lessless: expect(User).to receive(:find_or_initialize_by) { user } where user is a stub, you can then use expect() on that stub :)
[10:52:03] sevenseacat: ACTION nominates ljarvis for 'patience of a saint' award
[10:52:16] ljarvis: sevenseacat: <3
[10:52:55] ljarvis: NDD: comment out pg in your gemfile, bundle, then uncomment, then bundle again, I know it can be fishy at times but it seems like everything else should work as expected
[10:53:24] ljarvis: actually forget that it wont make any difference unless you remove the gem too
[10:53:36] ljarvis: that shouldn't be necessary, though
[10:54:24] lessless: ljarvis, lol, here is how I did that https://gist.github.com/dirty-hippie/6327449, but really stuck on the second test
[10:55:09] ljarvis: what is @base?
[10:55:39] ljarvis: also using let with a proc inside a block is nice and meta but horrible to maintain
[10:59:35] quazimodo: totally TDD'd it
[10:59:53] lessless: @base is a basic object, which is extended with module containing sync_user method
[11:00:03] NDD: Ok, I removed and then re-added pg to the gemfile, with bundle install and server restarts... Still back to "could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?"
[11:00:46] lessless: look at the updated gist https://gist.github.com/dirty-hippie/6327449
[11:00:59] lessless: just did not used RSpec much :)
[11:01:19] lessless: I understand that I'm doing horrible things, but do not know the other way :)
[11:02:05] lessless: the the reason for the lambda is that expect(sync_user(email, uid)).to change(User, :count).by(1) causing an error
[11:02:45] ljarvis: I'd write it something like this https://gist.github.com/leejarvis/dc980cf92b2d1971f3c9
[11:03:04] ljarvis: no need to the expect to change, no need to hit the db, none of that is needed for testing this method
[11:03:14] ljarvis: NDD: does `rails db` work?
[11:04:18] NDD: psql: FATAL: role "applicationname" does not exist
[11:04:28] ljarvis: NDD: createuser applicationname
[11:04:41] ljarvis: you actually named your app aplicationname, didn't you?
[11:06:10] NDD: Hahahahaha, no I didn't I changed it to make it clearer for you. I removed the username from database.yml, which fixed that problem but now means running "rails db" returns "psql: FATAL: database "appname_development" does not exist"
[11:06:33] ljarvis: you know what to do
[11:06:37] NDD: which seems fixable, but I have no idea how you'd do it in psql
[11:06:59] ljarvis: you only need the createuser command line tool
[11:07:01] NDD: go into psql and run some kind of CREATE DATABASE app name_development? that'd be my guess, i'll give it a shot
[11:07:17] ljarvis: rake db:setup does that iirc
[11:07:24] ljarvis: or just run createdb foo
[11:07:38] ljarvis: createdb is like createuser, but with a difference ;)
[11:10:39] NDD: omfg, fiddle with it a bit and now "rails db" returns "psql (9.2.4) Type "help" for help" plus taking me into appname_development, so it seems that it should be working but i'm still getting the same error "could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?"
[11:10:49] lessless: ljarvis,what to do with Double received unexpected message :encrypted_password with (no args) ?
[11:11:02] ljarvis: lessless: then you didn't rewrite the method like I told you to
[11:12:24] ljarvis: NDD: do you have a /usr/local/var/postgres/postmaster.pid file?
[11:13:17] NDD: no, /usr/local/var only has a folder called "mysql", and no "postgres"... I've been wondering about that, but can't find a set of files to copy in there online...
[11:13:45] lessless: this code gives a whole new perspective on testing for me... can u recommend something to read?
[11:15:10] ljarvis: lessless: I wish I could, people overuse factorys (ugh factory_girl) and other such things and it just covers your database in sperm. There's usually no need for it
[11:15:18] ljarvis: and the more controlled your specs are, the quicker they are
[11:15:20] ljarvis: https://gist.github.com/leejarvis/99486f64a45a704b0532
[11:15:28] ljarvis: (that's a production rails app I run)
[11:15:50] ljarvis: NDD: You may have to try the stuff in here http://stackoverflow.com/questions/8465508/can-not-connect-to-local-postgresql
[11:20:48] NDD: HALLELUJAH!!! "bundle exec gem pristine pg" fixed my problem. Thank you very very much ljarvis, I wish I was an attractive woman so I could surprise you at a rails conference or something as thanks, but I'm not so I'll have to stick with expressing virtual gratitude
[11:22:13] NDD: I assume developing with postgresql will then save me a bunch of headaches with deploying to heroku right? Thanks again ljarvis
[11:22:45] ljarvis: NDD: Yeah it's always a good idea to use the same production dbms locally
[11:27:03] NDD: As might be incredibly apparent, i'm rather new to RoR and IRC too for that matter, how come there's about 500 people online but a SUUUUUUUUPER slow inflow of messages from about 3 people? Shouldn't the new messages be coming in so fast they're hard to read? Or at least a little more steadily than they do? Heaps of people just leave their browsers open while they're AFK?
[11:27:33] ljarvis: NDD: A lot of people idle in here, yes
[11:27:55] ljarvis: Me included, I connect from a remote shell via irssi so it's not really keeping a browser open
[11:29:15] NDD: any awesome tricks for IRC that I should know about? The kind that I would facepalm after discovering 2 years down the line, cos they would have made things a lot easier?
[11:30:01] ljarvis: not really, irc is incredibly simple
[11:31:52] NDD: Are there any commands like /whisper or something like that, or ways to track whether a subset of people are online or anything like that?
[11:33:04] ljarvis: there's /msg nick msg to private message someone, and /nick to get a list of nicknames in a channel (but your client probably lists them), and of course nick[tab] autocompletes nicknames (which many people overlook)
[11:42:08] NDD: does anyone here write/run RoR websites either as a freelance coder or as part of some kind of entrepreneurial startup full time? I'm interested in this for my own future and would be really intrigued by some first hand perspective on finding work, hours, job flexibility, pay, job satisfaction etc.
[11:47:23] ljarvis: NDD: it really varies a lot so it's worth researching, most of which you can find on Google. Right now, though, you should just focus on learning everything you can to become confident in writing Ruby and building apps
[11:49:50] quazimodo: https://gist.github.com/quazimodo/6327681
[11:50:21] quazimodo: if you guys notice, my code is making refill[refill_line_item][id], but I want to make refill[refill_line_items][][id]
[11:51:49] sevenseacat: i lol'ed at 'covering your database in sperm'
[11:52:13] quazimodo: sevenseacat: wha?
[11:53:48] ljarvis: quazimodo: fields_for :refill_line_items, rli
[11:54:15] ljarvis: dont pass a model instance into fields_for otherwise it'll create input names relative to a singular item
[11:55:01] ljarvis: and if you're not gonna use that 'i' then I'd avoid each_with_index and just use fields_for :refill_line_items
[11:55:05] quazimodo: ljarvis: i'm still learning how to generate my forms both on the server, and fields via js because I've moved to using form objects instead of nested forms
[11:55:26] quazimodo: ljarvis: absolutely, I was manually writing my fields using it before
[11:55:53] ljarvis: quazimodo: sure, but yeah that's why, you need to tell fields_for you're working with 'refill_line_items' not 'refill_line_item'
[11:56:04] ljarvis: that's why you can see the singular version in the html
[11:56:08] quazimodo: ljarvis: oh, thats now making things like refill[refill_line_items][id], it's not making an array
[11:56:40] quazimodo: refill[refill_line_items][0][id], refill[refill_line_items][1][id] sort of thing?
[11:56:56] ljarvis: yeah, fields_for will do all that for you
[11:58:03] quazimodo: ljarvis: so, what happens if we want to make fields for an array of hashes for some contrived attribue
[11:58:07] ljarvis: also im pretty sure there's no need for the id hidden field, fields_for will handle that for you
[11:58:22] ljarvis: quazimodo: that's when rails tells you to go fuck yourself
[11:58:33] quazimodo: ljarvis: lol
[11:58:41] quazimodo: ljarvis: I'm fighting rails a smidge here
[11:59:05] ljarvis: arrays in forms usually have to be written by hand, for somewhat obvious reasons (once you've figured it out it'll all make sense)
[11:59:18] sevenseacat: thats generally a Bad Idea
[12:00:29] quazimodo: so, thing i'm thinking here is that if we extract a form object to map fields to objects, rather than use rails nesting, then things get very much more annoying if the nesting is on a has_many relationship
[12:00:35] ljarvis: quazimodo: https://gist.github.com/leejarvis/6327722
[12:00:54] ljarvis: ignore the html i didn't regenerate it
[12:00:57] quazimodo: does that make sense,? i dno
[12:00:58] triptec: how do I validate values on object before I allow them to be assosiated?
[12:01:06] quazimodo: ljarvis: ill looky
[12:01:27] ljarvis: triptec: you validate before the association can be saved, that's how validations already work
[12:02:06] triptec: ljarvis: ok
[12:03:10] quazimodo: ljarvis: oh i see, you don't iterate over the collection manually. I wonder why i was doin that
[12:03:34] ljarvis: quazimodo: you *can* but it's not necessary unless you need to do it manually
[12:03:40] triptec: so I have Products that can have other products as both children and parents but I'd like to validate that they are in the same store for example
[12:04:29] triptec: would that validation go in my through model or on my product model?
[12:05:33] ljarvis: the join model
[12:06:40] triptec: ljarvis: ok
[12:09:02] quazimodo: ljarvis: lol ff.object == nil
[12:09:37] sevenseacat: you dont have accepts_nested_attributes_for
[12:11:08] quazimodo: sevenseacat: which is precisely what I'm trying to avoid
[12:11:20] sevenseacat: why? you like pain?
[12:11:20] quazimodo: I *dont* want to accept nested attributes
[12:11:29] sevenseacat: if you're doing fields_for, then yes you do
[12:12:06] quazimodo: right. that answers that then, fields_for is designed around nesting and accepts_nested bla
[12:12:17] quazimodo: i didn't know if it was designed specifically for that, thank you
[12:12:37] sevenseacat: its designed to work with everything else rails uses, yes.
[12:13:39] quazimodo: sevenseacat: unless i've missed someting, why is ryan bates even suggesting that we use form objects to avoid nesting?
[12:21:14] quazimodo: maybe it's not to avoid nesting
[12:25:22] _JamieD_: what would people recommend as the best way to use twitter bootstrap 3 in a rails 4 app? use a gem (which one)? use the less files? or the css files, but then how to handle the font loading in the css?
[12:26:15] ljarvis: _JamieD_: we use 'bootstrap-sass' from the '3' branch
[12:27:27] sevenseacat: quazimodo: i dont know what youre referring to
[12:27:34] _JamieD_: ljarvis: how does that work for you? my concern with using a gem is you are at the mercy of the gem author when new versions are released.
[12:28:05] ljarvis: _JamieD_: it seems to be pretty stable, we've had no issues with it for the last couple of months
[12:28:28] ljarvis: _JamieD_: but yeah, you're right. You need to find out if the tradeoff is worth it (it is for us)
[12:28:36] _JamieD_: one other thing I want to do is use the social glyphicons which aren't included as standard so will need to add that in some how
[12:28:56] ljarvis: dump that into your assets
[12:30:20] _JamieD_: I'm terrible at css, I guess I'd need to overload the bootstrap styles for loading the fonts or something?
[12:31:06] sevenseacat: i wish more people knew how to write css
[12:32:02] _JamieD_: sevenseacat: I leave it mostly to the front end debs who now what they are doing rather than trying to do something I'm not very good at
[12:32:25] _JamieD_: I can't type well today :(
[12:32:36] sevenseacat: i guess i dont get why 'frontend' and 'backend' dev is distinguished
[12:34:42] ljarvis: heh markup/css/js is a requirement for my rails devs
[12:35:00] ljarvis: but anyway, _JamieD_ you can just apply the styles you want for the fonts?
[12:35:29] ljarvis: we use font-awesome and ignore all the bootstrap stuff, just using the selectors we need
[12:35:43] quazimodo: _JamieD_: it's just bootstrap :/
[12:35:51] quazimodo: i'd just use ... any bootstrap gem :/
[12:36:28] _JamieD_: ljarvis: I looked at font-awesome but isn't that only for bootstrap 2?
[12:36:54] sevenseacat: not a lot of bootstrap 3 stuff is released yet, given bootstrap 3 just got released
[12:37:10] _JamieD_: quazimodo: but then you have to tweak the css files anyway to mate the font urls correct
[12:42:59] quazimodo: <- figured that shitz out :D
[12:43:24] quazimodo: _JamieD_: i'm not sure if i've ever bothered to do that :/
[12:43:30] quazimodo: _JamieD_: you may be right tho huh
[12:47:25] _JamieD_: quazimodo: I'm not sure but I think it's only required if using bootstrap 3
[12:48:43] triptec: how do I create a association in a join model that requires a value besides the foreign keys?
[12:49:45] triptec: like appointment.time if appointment was a join model between doctor, patient?
[13:01:14] quazimodo: woot i made it work :D
[13:07:03] sventon: then I run "rails plugin" I got an error
[13:07:23] sventon: dependencies.rb:228:in `require': cannot load such file -- rails/commands/plugin (LoadError)
[13:07:49] sventon: then google this problem I don't find any relevant information
[13:08:23] sventon: what happen then you run "rails plugin" ?
[13:09:54] sventon: I mean could somebody help me out and run "rails plugin" on there machine so I know if it is only my installation : )
[13:12:31] sventon: actually do anybody know about a guide for generating plugins in rails4 ?
[13:13:13] marcin_m: Guys in my confirmation link I dont have host part
[13:13:29] marcin_m: but i have config.action_mailer.default_url_options
[13:13:43] marcin_m: Im using devise
[13:14:10] triptec: is there any way to do something like resturant.cities << city if city_resturants join table validates presence of say count?
[13:14:23] marcin_m: config.action_mailer.default_url_options is set to localhost
[13:16:08] sventon: do anybody know if the guide at http://guides.rubyonrails.org/plugins.html are for rails4 ?
[13:16:46] sevenseacat: marcin_m: and how are you generating the confirmation link?
[13:17:30] marcin_m: you mean this
[13:17:35] marcin_m: confirmation_path(@resource, :confirmation_token => @resource.confirmation_token, locale: I18n.locale)
[13:17:45] sevenseacat: a path is never an absolute url
[13:17:52] sevenseacat: you need confirmation_url
[13:18:06] marcin_m: I had problem with locale
[13:18:12] marcin_m: and i change to path
[13:18:41] marcin_m: then I added locale parameter and the path suffix stay untouched :0
[13:18:47] marcin_m: sevenseacat: THank you :)
[13:19:25] marcin_m: sevenseacat: btw is there any nicer solution to use current locale than this ?
[13:19:38] sevenseacat: no idea, never used locales in rails.
[13:24:27] krz: ive go config.autoload_paths += %W(#{config.root}/lib)
[13:24:43] krz: in application.rb. cant seem to execute a module in there
[13:24:54] krz: this is for Rails 4
[13:25:03] sevenseacat: do you have an actual problem we can help you with?
[13:25:26] krz: i get config.autoload_paths += %W(#{config.root}/lib)
[13:25:31] krz: NameError: uninitialized constant Foo
[13:25:37] sevenseacat: and where is foo defined?
[13:26:02] krz: lib/modules/foo.rb
[13:26:15] sventon: could somebody just run "rails plugin --help" on there machine so I know if I dealing with a rails bug or if something is wrong with my installation ?
[13:26:17] DouweM: lib/foo.rb
[13:26:30] DouweM: krz: ^ or use it like Modules::Foo
[13:26:58] sevenseacat: just because you've added lib to autoload, doesnt mean you can nest shit in random directories and expect rails to find it
[13:27:44] krz: shouldnt modules be placed in lib/modules? or just /lib?
[13:27:52] DouweM: krz: just lib
[13:28:01] DouweM: krz: why would modules be in a different dir?
[13:28:49] krz: DouweM: a few online references indicate lib/modules
[13:28:57] krz: so i thought it might be cleaner to put it in there
[13:29:04] DouweM: krz: then those are wrong *shrug*
[13:29:13] sevenseacat: it may be, but you still have to follow rails' naming conventions
[13:30:11] krz: kk works now. thanks for that
[13:32:07] sventon: why can't somebody help me! tried to find information an hour now
[13:32:54] sventon: if somebody could just run "rails plugin --help" on there machine it should be appreciated
[13:33:34] sventon: can you see me ?
[13:34:04] ljarvis: sventon: what's your issue?
[13:34:52] sventon: ljarvis: I want to generate a rails plugin but can't find any documentation
[13:35:25] sventon: found this http://guides.rubyonrails.org/plugins.html but don't know if it is up to date?
[13:35:48] ljarvis: I would assume so
[13:36:41] sventon: ljarvis: what happens if you run "rails plugin --help" ?
[13:37:11] sventon: that is the firs step in the guide http://guides.rubyonrails.org/plugins.html
[13:37:39] ljarvis: sventon: I get a loaderror
[13:38:04] ljarvis: sventon: try rails plugin new --help
[13:38:56] sventon: ljarvis: I done that and it works.
[13:39:46] sventon: but I can't figure out how to include a generated plugin
[13:39:55] sventon: (in my rails app)
[13:40:14] ljarvis: in your gemfile
[13:40:17] sventon: can't find any documentation anywhere
[13:40:26] ljarvis: http://guides.rubyonrails.org/plugins.html#publishing-your-gem
[13:40:33] ljarvis: "Gem plugins currently in development can easily be shared from any Git repository. To share the Yaffle gem with others, simply commit the code to a Git repository (like GitHub) and add a line to the Gemfile of the application in question:"
[13:43:13] sventon: ljarvis: wait I will try to create a plugin one more time
[13:43:43] sevenseacat: documentation is for chumps.
[13:44:04] ljarvis: do it live
[13:44:47] sevenseacat: ACTION goes back to reading up on German grammar
[13:44:58] sventon: ljarvis: after running "rails plugin new test_plugin" what is the next step if i want to install the plugin locally ?
[13:45:15] ljarvis: sevenseacat: documentation is for chumps
[13:45:24] ljarvis: sventon: did you read the docs?
[13:45:35] sventon: what docs?
[13:45:37] ljarvis: sventon: or my paragraph above
[13:46:18] ljarvis: sventon: http://ryanbigg.com/2013/08/bundler-local-paths/
[13:46:24] sevenseacat: i know, but i wont learn this shit any other way >_>
[13:46:37] ljarvis: sevenseacat: you are brave
[13:47:06] sevenseacat: i dont even understand this shit in English
[13:48:52] sventon: ljarvis: yes, but do you mean I need to push my plugin to github to be able to use it in my rails app ?
[13:49:23] sventon: or do I need to tell bundler where the gem are ?
[13:49:25] sevenseacat: guess he didnt read it
[13:51:00] sakshi: Hello all :) Please solve my simple problem related to haml. https://gist.github.com/sjain1107/6260119 There is some indentation problem at L26 which is not allowing me to see the icon.
[13:51:05] sventon: I did read that but there are something wrong with this workflow
[13:51:20] sventon: for example if I generate a normal gem i do:
[13:51:57] sventon: bundle my_gem
[13:52:04] ljarvis: a plugin is just a 'normal' gem
[13:52:14] sventon: bundle rake install
[13:52:15] sevenseacat: sakshi: without knowing the problem, well
[13:52:33] sventon: and then i can just use it in my gemfile
[13:52:44] ljarvis: sventon: add the gem to your gemfile, point it to the directory your gem is located
[13:52:54] ljarvis: basically exactly how that article/the docs tell you
[13:53:58] sventon: there are no correct docs for creating Rails Plugins
[13:54:20] ljarvis: there are, there's one issue with that page you viewed, and I showed you how to solve it
[13:54:23] ljarvis: the rest of it is relevant
[13:55:28] sventon: but is this a bug then or what ?
[13:55:40] ljarvis: what is 'this'?
[13:56:06] sventon: that "rails plugin --help" generate an error
[13:56:13] sevenseacat1: this, man, THIS.
[13:56:28] ljarvis: sventon: you're already passed that
[13:57:47] sventon: I creating a gem and want my gem to generate a rails plugin
[13:58:36] sventon: now I don't know if I should extract the generators from rails or if this is something that is going to change
[14:00:21] sventon: are the docs wrong or is this a bug in rails ?
[14:00:39] ljarvis: the docs are wrong, rails plugin new is what you should be using
[14:00:56] sventon: or is the plugin ties still in development ?
[14:01:52] sventon: ljarvis: thanks for your help
[14:06:45] sevenseacat1: my brain hurts
[14:28:17] lxsameer: hi i have model with a has_many relation, how can i retrieve all the record which has a relation ? (that has_many field is optional)
[14:28:29] OhGodWhy: why doesn't this work?
[14:28:31] OhGodWhy: def join_complete
[14:28:32] OhGodWhy: if @group.password = params[:pass]
[14:28:33] OhGodWhy: @group.users << current_user
[14:28:36] OhGodWhy: redirect_to groups_url
[14:29:17] lxsameer: OhGodWhy: don't paste in channel, user dpaste.com . 2) what's the error
[14:29:24] OhGodWhy: Yes, I'm sorry
[14:29:29] OhGodWhy: association type mismatch
[14:30:13] lxsameer: OhGodWhy: probably you want to check for correct password , am i right ?
[14:30:51] OhGodWhy: User(#70298689510040) expected, got NilClass(#70298649433980)
[14:31:07] lxsameer: OhGodWhy: use "==" instead of "=" in if condition
[14:33:23] lxsameer: OhGodWhy: in which line?
[14:33:54] OhGodWhy: the @group.users <<current_user
[14:34:44] lxsameer: OhGodWhy: current_user is nil probably
[14:48:43] bklane: I created a custom registration controller with devise but it is causing problems in the other gem-controllers, any idea why? https://gist.github.com/blklane/3057712d4541b2a6f7d6
[14:49:32] sevenseacat: do you have a user_url defined?
[14:49:49] sevenseacat: the error is also not coming from the controller you posted.
[14:50:01] bklane: sevenseacat: not explicitly, but I also do not call it anywhere in my repository
[14:50:19] sevenseacat: you cant define two devise_for blocks in your routes
[14:50:27] sevenseacat: one is overwriting the other
[14:51:17] bklane: what would be the bnest way to combine them?
[14:54:02] bklane: sevenseacat: I am still getting the same error after restarting the server
[14:54:25] sevenseacat: so we're back to the 'do you have a user_url defined'
[14:56:15] DouweM: bklane: what's your after_sign_in_path_for say?
[14:57:45] bklane: DouweM: that was the problem, i explicitally said what to do after the admin sign in via the applicaiton_controller but took out the user post
[14:58:12] bklane: redirect because i said it in the registrations_controller, but now when i put it back in the application_controller it works
[14:58:48] sevenseacat: i'll pretend this conversation makes sense.
[14:59:17] DouweM: bklane: sooo... problem solved?
[15:00:21] bklane: DouweM: Sevenseacat: i had the logic for the redirect in the registrations_controller for one model while having it in the application_controller for another model, causing problems. Now it is fixed, thank you
[15:03:09] senayar: i added turbolinks to do ajax navigation between page but i don't understand why the js is not loaded sometimes ? does i need to specify something ?
[15:04:05] sevenseacat: thats awfully vague
[15:04:34] senayar: ok i did not see they add weird js :(
[15:07:53] snenitho: senayar: you probably don't need turbolinks
[15:08:15] senayar: i need to encapsulate a beautiful spinner inside it
[15:08:46] senayar: to replace a custom ajax navigation
[15:08:47] snenitho: because now user clicks something and nothing happens :)
[15:09:41] sevenseacat: i see snenitho hasnt used turbolinks before
[15:09:57] bklane: sevenseacat: DouweM: having problems with the routing, tried match, and get but they dont seem to work, keep getting the errror "No route matches [GET] "/account"
[15:10:10] sevenseacat: bklane: code/error plz
[15:11:25] bklane: sevenseacat: https://gist.github.com/blklane/3057712d4541b2a6f7d6 in comment, have it standalone, tried to do it in the block with controller but that also didnt work
[15:11:55] sevenseacat: bklane: now look at how *all* your other routes are defined
[15:11:59] sevenseacat: and see how that route is different
[15:16:05] bklane: sevenseacat: i added the resources but still problematic
[15:16:21] sevenseacat: resources have nothing to do with it
[15:16:36] sevenseacat: compare get "/account" => 'registrations#edit' and match "/account" :to => 'registrations#edit'
[15:18:41] jammanbo: Is there some way to set the default value of a column to be a DB function using the migration DSL or must I resort to using execute?
[15:18:55] bklane: I tried get and match for both
[15:33:05] banas: I'm trying to create something similar to coursera using rails. We want to be able to display videos, but we wont be uploading them. We wanted them to be stored somewhere on a directory, and then play it in a given view. How might I do that?
[15:35:55] lxsameer: how can i query for count of a has_many field?
[15:43:15] banas: I have a video saved in a directory. How can I embed that into a rails view?
[15:47:51] AzizLight: I am using Rails 4, and using `require_directory .` in application.css.scss, but for some reason none of the files in the directory are getting included... any ideas what might be the problem please?
[15:52:01] jammanbo: lxsameer: @article.comments.count
[15:52:26] lxsameer: jammanbo: i want to get all articles which have any comment
[15:54:43] AzizLight: related to my question, the only file that gets loaded is application.css.scss ...
[15:54:50] AzizLight: and the javascript files
[15:55:59] dopie: https://gist.github.com/staycreativedesign/6328873
[15:56:03] dopie: where is my syntax erro312?#21?@!
[15:56:30] DouweM: lxsameer: do you know the SQL to get that result?
[15:56:42] lxsameer: DouweM: yeah
[15:58:11] jammanbo: lxsameer: Might be worth using a counter cache column then. Would make the query nice and neat.
[15:58:32] lxsameer: jammanbo: i don't know about that
[16:00:24] jammanbo: Actually, is it enough just to run Article.joins(:comments) ? … it's an inner join by default so will that omit any articles without commetns?
[16:00:47] DouweM: jammanbo: you might just be right
[16:01:02] lxsameer: jammanbo: interesting let me try that
[16:01:37] DouweM: yup, the AR querying guide confirms it
[16:01:53] DouweM: `Category.joins(:posts)` Or, in English: "return a Category object for all categories with posts"
[16:05:51] HashNuke: hey people ~!
[16:06:32] DouweM: hey HashNuke
[16:08:30] DouweM: hi bdscvr
[16:08:33] HashNuke: I'm passing datetime (rendered by rails as json) via a url and doing a where query with "created_at <= ?". I get different results compared to querying from the console with the param passed as an activerecord object's created_at attribute.
[16:08:40] bdscvr: I cannot access rails 3.2.x api docs
[16:08:57] bdscvr: How can I find it?
[16:09:00] helpa: HashNuke: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[16:09:00] DouweM: HashNuke: !gist some code
[16:09:16] DouweM: HashNuke: and are you completely sure you're passing the same thing?
[16:09:33] HashNuke: DouweM: yes. I'll paste it in a gist one sec.
[16:10:26] DouweM: bdscvr: surprisingly, I can't find them either
[16:10:29] jammanbo: schema.rb is used for setting default values for new (unsaved) models right?
[16:11:47] HashNuke: jammanbo: That's done in your model itself.
[16:11:48] DouweM: bdscvr: I use Dash.app, which has both Ruby on Rails 3.2.14 and 4.0.0 docsets
[16:12:46] HashNuke: DouweM: https://gist.github.com/HashNuke/1d91b3ae742e8c4f3179
[16:12:56] bdscvr: Dash, looks like only for mac?
[16:13:00] DouweM: jammanbo: you can set defaults through your migrations, which will be set on the DB itself, which will be reflected in schema.rb, which is mostly a dump of the DB. The defaults are applied by the DB and I think they're read by Rails from the DB aswell
[16:13:28] HashNuke: DouweM: Just to be sure, I also checked by converting the dates to unix timestamp to compare. They are exactly the same.
[16:13:35] DouweM: bdscvr: yeah
[16:13:58] DouweM: HashNuke: check the logs, what are the executed queries?
[16:14:42] RyanHirsch: I have a model with a start_date and end_date, I also have a current? attribute that does the calculation to see if today falls in that time range. Is it possible for me to search for all current items, using that attribute?
[16:15:38] HashNuke: DouweM: Ah. Thanks. There is a small difference I see - https://gist.github.com/HashNuke/1d91b3ae742e8c4f3179
[16:15:48] DouweM: RyanHirsch: if you can describe the property in SQL, sure. but you can't just have the query use a Ruby method
[16:16:43] HashNuke: DouweM: There seems to be some other int along with the activerecord date. I'll look into it and see what that is.
[16:16:52] RyanHirsch: DouweM: okay I figured just doing SQL was going to be the way I was going to have to go
[16:17:07] DouweM: HashNuke: that's the milliseconds
[16:17:42] HashNuke: DouweM: oh awesome. so now I only have to convert the json dates to millisecond accuracy.
[16:17:58] bdscvr: But I want a solution that works on Ubuntu, too?
[16:18:08] DouweM: HashNuke: it's still weird that they give such different results, or does that make sense in your case?
[16:18:47] snenitho: whut? json doesn't have a date type
[16:18:49] HashNuke: DouweM: I'm working on a chat app. I'm passing the oldest chat message's id and the timestamp to check for more history in the chat (loading older messages)
[16:18:57] DouweM: bdscvr: you should be able to find the docs somewhere, no idea where though
[16:19:14] HashNuke: bdscvr: looking for an alternative to Dash?
[16:19:44] HashNuke: bdscvr: I have Dash on my Mac. But I only tend to use that when I'm offline. I mosty tend to hit api.rubyonrails.com for all my needs.
[16:20:03] bdscvr: I just want to access rails 3.2 api docs
[16:20:08] HashNuke: bdscvr: For rails docs, you could also fire up the rubygems docs server locally - if you install docs along with the gems.
[16:20:50] bdscvr: Sounds interesting...
[16:22:28] bdscvr: I expect to access it via official rails api site like...
[16:22:58] bdscvr: api.rubyonrails.org/3.2
[16:23:15] DouweM: bdscvr: yeah, it would be nice if they did that for versions they still support
[16:23:40] bdscvr: Thx anyway
[16:42:59] rhizome: this is great: http://apidock.com/faq#What-is-the-bar-graph-on-the-top-of-documentation-pages
[16:44:32] rhizome: oh good, i love it when chrome eats my history and i have to search again
[16:47:43] dopie: how can i do this with rales
[16:48:00] dopie: I have a ul and i want every other li to be a specific color
[16:48:04] dopie: how would i do that?
[16:50:32] tricon_: dopie: Use CSS.
[16:53:46] Triconium: dopie: http://www.w3schools.com/cssref/sel_nth-child.asp
[16:53:57] rhizome: one of the more confusing urls of late: http://guides.rubyonrails.org/v3.2.13/2_3_release_notes.html
[16:54:25] dopie: The :nth-child() selector is supported in all major browsers, except IE8 and earlie
[16:54:44] dopie: god i hate IE
[16:58:31] Triconium: dopie: It's terrible.
[16:59:31] Triconium: dopie: If you _must_ support <= IE8, you can assign even/odd classes in Rails using `cycle`: http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-cycle
[16:59:47] dopie: thats what i wanted
[16:59:49] rhizome: guessing you have to support ie8
[17:00:14] dopie: everyone has to support ieh8 ie
[17:00:30] Triconium: dopie: We dropped support for it. Not worth the cost.
[17:00:43] dopie: Triconium, what site?
[17:01:01] Triconium: dopie: https://www.noshfolio.com
[17:01:32] Triconium: dopie: Small site for now, but with an emphasis on mobile, it's a little easier to not support IE.
[17:01:49] rhizome: but you have to support BB ;)
[17:01:49] dopie: Nice and Clean!
[17:05:57] Triconium: rhizome: Hah!
[17:06:01] Triconium: dopie: Thanks!
[17:06:07] Triconium: Trying to expand to other cities.
[17:07:28] dopie: Triconium, is that bootstrap?
[17:08:30] Triconium: dopie: Not yet. It's just all by hand. We're going to move to BS, though, for grid, responsive, and easier maintenance.
[17:08:39] dopie: Triconium, i changed my browser width
[17:08:47] dopie: i was about to say
[17:09:34] Triconium: dopie: So many CSS framework options now. Friend played with Pure, but BS is so easy to use and well maintained.
[17:09:42] Triconium: dopie: BS 3.0 is rad.
[17:09:58] dopie: yes$#@LK:#@
[17:13:46] substrate: Is there a way to monitor Passenger like the way WEBrick shows what's going on live?
[17:14:07] Triconium: substrate: Follow the log file.
[17:18:59] substrate: My Apache access log is just showing requests and file access, it's not showing the SQL like WEBrick does or anything. Am I looking in the wrong place?
[17:19:51] Triconium: substrate: You may need to change Passenger's log level.
[17:19:56] rhizome: this is the part where you tell us what environment you're using
[17:20:33] rhizome: also: 'passenger start' from the app root
[17:22:34] substrate: PassengerLogLevel: "This option may only occur once, in the global server configuration." Is that httpd.conf or passenger.conf?
[17:24:20] Triconium: substrate: Either is fine.
[17:27:51] substrate: oh, rhizome, to answer your question, this app's RailsEnv is set to development
[17:29:33] substrate: Triconium: I set PassengerLogLevel to 3 in httpd.conf, but I don't see any logs about what SQL it tried to use to insert a new Type (one of my models) into the database.
[17:30:01] substrate: Thanks for your help, though. I'll try putting around Google a little more and then move onto other code if I can't figure it out
[17:31:46] Triconium: substrate: Other options here: http://stackoverflow.com/questions/7432166/development-log-log-file-isnt-logging-rails-sql-queries
[17:35:14] substrate: alright thanks, Ill look through that and see if I cant get something to work
[17:38:18] substrate: Oh, rhizome's solution of passenger start worked. Thanks, you guys :)
[17:43:27] Triconium: substrate: Glad it was a simple solution.
[17:48:19] rhizome: anybody work with 2.x lately? i have an exceedingly strange problem: no logs on script/server, and no view changes appear in browser.
[17:48:36] rhizome: it's like the app is permanently cached
[17:49:06] Triconium: rhizome: Production or dev?
[17:52:49] siaW: i'm trying to send an email from my computer in production env
[17:52:51] siaW: i set this
[17:52:52] siaW: https://gist.github.com/siaw23/6329459
[17:53:00] siaW: but the email is not appearing in my email
[17:53:02] siaW: any help?
[17:57:30] Triconium: siaW: Check your sent email on that Gmail account.
[17:58:24] siaW: Triconium: nothing in my sent mail
[17:59:08] rhizome: Triconium: dev!
[17:59:20] Triconium: siaW: Check your logs for SMTP errors.
[17:59:53] rhizome: siaW: there's a config option to log mailer errors
[18:00:27] siaW: rhizome: how do i set that?
[18:00:47] Triconium: rhizome: Which server are you using?
[18:00:50] rhizome: it's in there somewhere
[18:01:02] rhizome: Triconium: webbrick and thin both exhibit the same behavior
[18:01:13] Triconium: rhizome: rm -rf tmp
[18:01:16] rhizome: siaW: it's commented out somewhere by default. look around.
[18:01:20] Triconium: rhizome: I've had some cache issues with that.
[18:01:26] Triconium: *That are resolved by that.
[18:01:45] siaW: rhizome: thanks
[18:01:46] rhizome: Triconium: i emptied them before, but i'll try nuking
[18:03:38] Triconium: rhizome: Are you using any sort of asset packager with 2.x?
[18:03:44] rhizome: i have to think this is an earlier version that was pushed to 2.3 without doing anything. rake rails:update didn't do anything
[18:04:28] rhizome: not that i can tell. there was vendored rails and a few plugins, but no gems in env.rb or anything
[18:04:56] rhizome: it's not my code
[18:05:38] rhizome: i have half a mind to just copy it over to 3.x and be done with it, but it's kind of an ancillary task to what i'm supposed to be doing.
[18:09:29] h4pless: is it necessary to remove and re-add indexes when renaming a table in rails 3.2?
[18:11:40] rhizome: rename the table, then see if the indexes are still there.
[18:11:53] Triconium: Probably depends on the DB.
[18:11:59] rhizome: undoubtedly
[18:14:36] h4pless: alright, i was just afraid to jump into renaming the table because i figured i might not be able to remove the indexes after the table no longer exists by the indexed name. but i guess i'll give that a shot
[18:15:50] h4pless: i guess i can always just rename it back if everything fails. thanks
[18:16:13] jankees: i have a question, i'm building an app with a connection to Stripe
[18:17:08] jankees: I have now a after_update hook in my user so it syncs the user information whenever something is saved, this all works as expected, however this is really annoying in tests...
[18:17:58] jankees: I've disabled all external connections in tests (like you should)
[18:18:19] jankees: The annoying thing is I have to add to a lot of test Stripe.expects(:some_mehod).returns(nil), anyone knows how i should approach this?
[18:19:09] TheMoonMaster: jankees: What about it is annoying?
[18:19:21] TheMoonMaster: jankees: Make a helper method to call it for you?
[18:19:30] jankees: It clutters my tests
[18:20:04] jankees: Is it a good idea to have this kind of logic in a model?
[18:20:18] jankees: I could also have it in some controller where the update of the user takes place,
[18:20:36] jankees: Is this changing of tests a sign it's not a good idea?
[18:20:41] TheMoonMaster: Why not just use Stripe webhooks instead?
[18:20:57] jankees: This is for creating customers, and adding cards
[18:21:05] jankees: web hooks is for reacting to status changes
[18:21:21] TheMoonMaster: There's no way I could have known what you were using it for.
[18:21:34] TheMoonMaster: Generally I don't craete the Stripe account information until it's needed.
[18:22:05] TheMoonMaster: So I have a method like `stripe_account` on the user and check if I have the `stripe_id` on the user, if so return the account, otherwise create one and return it.
[18:22:06] jankees: I would like to have a stripe customer for every signed up customer, makes a lot of logic easier...
[18:22:17] jankees: That's what i had before
[18:22:45] jankees: but then i had to write different logic for what happens when someone had a customer, removes a card, and re-adds one
[18:23:02] jankees: more complicated that having a customer for every user...
[18:23:13] TheMoonMaster: Why would you have to write different logic?
[18:23:17] jankees: Do you think this logic belongs on a user model?
[18:23:32] TheMoonMaster: I don't see why it would hurt.
[18:23:46] TheMoonMaster: But if you were only creating it on user creation via signup it might not hurt to make a Signup service.
[18:23:56] TheMoonMaster: service object that is.
[18:24:09] jankees: what would that service object do?
[18:24:22] TheMoonMaster: Create the user and create the stripe account for that user.
[18:24:30] jankees: I'm not really familiar with that term, i have heard it though
[18:24:45] jankees: I have a "StripeAdapter"
[18:24:57] jankees: That handles all communication with stripe
[18:25:07] jankees: bridge between my domain and stripes domain
[18:25:14] jankees: domain as in database domain
[18:25:14] TheMoonMaster: That sounds kinda like a service object.
[18:25:27] jankees: It has no state though
[18:25:32] TheMoonMaster: Neither do services.
[18:25:34] jankees: All public static functions
[18:25:39] TheMoonMaster: For the most part.
[18:25:49] jankees: I have created a service object without knowing then ;)
[18:25:58] TheMoonMaster: Watch http://railscasts.com/episodes/398-service-objects and see if that fits.
[18:26:10] alan_andrade: I had to work with a rails app that had lots of services. It was a pain to work with them.
[18:26:27] TheMoonMaster: alan_andrade: It's better than having spaghetti controllers.
[18:26:33] TheMoonMaster: Everything in moderation
[18:26:52] jankees: Maybe it's easier for me to add it to the controller, instead of the model
[18:27:01] jankees: i'm not sure yet.
[18:27:31] TheMoonMaster: .I still like the one where you pull the Stripe account off the model using #account or some similar method. That's always worked for me, even when changing credit numbers.
[18:28:02] jankees: can you show me the implementation of that method?
[18:28:05] alan_andrade: I'd create a module that contains the stripe logic, include Stripable, and create hooks that will execute in the after save.
[18:28:06] jankees: Just curious...
[18:28:26] jankees: alan_andrade: sounds nice
[18:28:30] TheMoonMaster: I dislike the idea of modules being for a single use.
[18:29:10] alan_andrade: but sometimes they can add more expressiveness to your code
[18:29:49] TheMoonMaster: I personally wouldn't do that for a single use.
[18:29:56] TheMoonMaster: If multiple models needed stripeable, totally.
[18:29:57] jankees: this is in my model: https://gist.github.com/jankeesvw/a613b7f656f232e28c70
[18:30:01] TheMoonMaster: But for a single model? No way.
[18:30:32] TheMoonMaster: jankees: Sounds like a lot of useless API calls.
[18:30:51] jankees: I'll have to optimise it later
[18:30:59] TheMoonMaster: I can't even tell what it's doing.
[18:31:12] TheMoonMaster: Since StripeAdapter is just kinda randomly there.
[18:31:17] jankees: ow wait, that's old...
[18:32:02] jankees: this is the one… https://gist.github.com/jankeesvw/a613b7f656f232e28c70
[18:37:31] rhizome: it's the user's sub that gets updated, why is it in that model?
[18:38:25] TheMoonMaster: rhizome: I think it's the users subscription on Stripe's end. I have no idea why it's in afterupdate rather than being called only when needed either
[18:38:26] jankees: I have a team model, that contains users
[18:40:07] siaW: pressing "cd ../" in terminal from this path Desktop/in_this_folder takes me back to .Trash :(. anyone knows why?
[18:40:19] siaW: i expect it to take me to Desktop and not .Trash
[18:40:37] jankees: I changed it, I removed the stripe_customer from my factory, now it doesn't want to talk to stripe that much
[18:43:06] lethjakman: hey, is there anywhere in the guides where I can read up on things like create.js.erb?
[18:43:12] lethjakman: I'm not quite clear on how to use them
[18:44:04] whowantstolivefo: hi, i follow this tutorial http://mapopa.blogspot.com/2009/02/rails-on-firebird-status-after-adapter.html and when i type >> rails generate scaffold Client name:string address:string email:string remark:text << i get this error, anyone help ?https://gist.github.com/maasdesigner/6329775
[18:44:57] Triconium: whowantstolivefo: Setup your DBs in `config/database.yml`.
[18:45:25] whowantstolivefo: Triconium: let me check
[18:47:54] whowantstolivefo: Triconium: https://gist.github.com/maasdesigner/6329798 same
[18:48:40] whowantstolivefo: i have activerecord-fb-adapter (0.7.5) in my local gem
[18:48:40] alan_andrade: identation in the database.yml
[18:49:51] alan_andrade: the gem is not even called
[18:50:26] Triconium: Yes, you need to indent properly.
[18:50:49] alan_andrade: development:\n\tfoo:bar
[18:51:29] whowantstolivefo: i cant figure out
[18:52:58] alan_andrade: here: https://gist.github.com/maasdesigner/6329798#comment-893724
[18:56:09] whowantstolivefo: Triconium: https://gist.github.com/maasdesigner/6329838
[18:56:49] Triconium: whowantstolivefo: activerecord-fb-adapter needs to be added to your Gemfile.
[18:57:07] whowantstolivefo: where can i get this gem ?
[18:57:44] alan_andrade: what do you mean where you can get it ?
[19:00:39] apeiros: wow, custom select with AR can yield to ~10x performance improvement (only useful if you don't need model instances)
[19:00:42] whowantstolivefo: i will add to my gem file this ? activerecord-fb-adapter ?
[19:01:38] whowantstolivefo: Triconium: it works now thank you
[19:01:50] Triconium: whowantstolivefo: You're welcome.
[19:04:38] rhizome: TheMoonMaster: no, that method is in some model that has_many users, why wouldn't it be a part of the user model when it's the user's details that are being operated on?
[19:05:31] TheMoonMaster: Oh weird, so that's a "Team" I believe and I guess it's updating the subscription for itself.
[19:05:52] TheMoonMaster: Although I don't know why it would need to.
[19:07:19] whowantstolivefo: now it says https://gist.github.com/maasdesigner/6329891
[19:13:14] alan_andrade: This might be stupid recomendation, but, is Firebird running ?
[19:13:47] whowantstolivefo: alan_andrade: i dont know
[19:14:24] alan_andrade: I haven't used that db
[19:32:27] willbradley: trying to use devise with :login (username or email) but logging in gives me a no such column: providers.login
[19:32:41] willbradley: is there a minimum version for using this feature?
[19:35:06] willbradley: actually, it seems their numbering is just confusing, I have to do both of these "1." things https://github.com/plataformatec/devise/wiki/How-To%3a-Allow-users-to-sign-in-using-their-username-or-email-address#tell-devise-to-use-login-in-the-authentication_keys
[19:37:36] rdev5: rails time
[19:43:42] lethjakman: are js.erb's slow? I saw that you can pass renders through them, but it seems like that'd be a lot more text than just passing JSON back and then writing some custom javascript.
[19:46:25] Scient: did not understand your question
[19:46:32] Scient: js.erb just renders like any regular template
[19:46:34] Scient: and outputs js
[19:48:03] lethjakman: Scient: oh hrm, it's not like JSON where it renders without reloading the page?
[19:48:22] Scient: its just a regular template
[19:48:26] Scient: depends on you what you put in it
[19:48:58] rhizome: it's like an extra js file that will process ruby code in it before it's sent
[19:52:05] lethjakman: don't think I like that very much.
[19:52:11] lethjakman: so it's rendered in addition to the html render?
[19:53:39] lethjakman: basically what I want is the ability to add additional forms to a page easily
[19:53:59] lethjakman: I'd rather not just create a $('form') and add a ton of attributes and do a bunch of fancy parsing
[19:54:03] lethjakman: but that's the best way I'm seeing to do this
[19:58:23] alan_andrade: I don't see why you need to do a request just to add a form to the page.
[19:58:41] alan_andrade: Can you do that with JS ?
[19:59:00] alan_andrade: I mean, all functionality within JS, no ajax requests ?
[20:17:01] rdev5: does rspec not pick up changes made at some point, e.g. caching of some sort
[20:17:26] rdev5: seems that my specs kept getting hung up on something that should've been passing, I modified some things, reverted (I think) everything back and all of a sudden it's going through
[20:18:25] rdev5: I seems it was failing with redirect_to subscribem.root_url(:subdomain => @account.subdomain) I changed it to redirect_to subscribem.root_url(), it gave a different error, reverted it back, and all of sudden what I though was previously failing is now passing
[20:18:43] alan_andrade: rspec sorcery
[20:18:59] alan_andrade: Are you using spork by any chance ?
[20:19:39] rdev5: don't think so
[20:19:42] rdev5: just rspec and capybara
[20:20:04] rdev5: doing git checkout . to revert and see if I can reproduce the issue
[20:23:09] rdev5: why do you ask about spork btw?
[20:24:05] alan_andrade: I have had failing tests because spork wouldn't load the files I just changed
[20:24:37] alan_andrade: Zeus has been working much better for me.
[20:31:54] rdev5: nevermind, it was a model validation line that was throwing me off
[20:37:20] alan_andrade: Do you think is a good idea to hack Arel/Active Record to keep joining/querying/crud functionality with a DB model that relates with an API model ?
[20:38:07] alan_andrade: Say you have a Customer model backed by Mysql and Active Record
[20:38:36] alan_andrade: and a Purchase model that is backed by API calls.
[20:38:44] alan_andrade: Customer.has_many :purchases
[20:47:00] tubbo: alan_andrade: sure, why not?
[20:47:56] alan_andrade: dunno, Sounds like a very tough problem and I just wanted to make sure I'm not going crazy with the solution I want to code
[20:47:59] tubbo: you're not really "hacking arel"
[20:48:24] tubbo: once you need data from AR, the query must be executed. so you're really dealing with an Array of objects at that point.
[20:48:25] alan_andrade: Yeah, I know. This goes far beyond
[20:48:57] alan_andrade: before the query gets executed, we might need to touch the query though
[20:49:13] alan_andrade: Customer.includes :purchases
[20:49:29] tubbo: huh? that won't work, purchases isn't a table
[20:50:03] alan_andrade: that's what I'm really thinking of.
[20:50:21] tubbo: why would you need to do that?
[20:50:22] alan_andrade: 'to include' something coming from an external service
[20:50:46] tubbo: alright hold on, let's step back
[20:50:57] tubbo: are you trying to do customer.purchases at some point?
[20:51:29] tubbo: it seems like that's what you want, at least as a first step, to list all purchases given a customer_id of some kind
[20:52:06] tubbo: ok so write the method customer.purchases to just do an API call to /purchases.json?customer_id=whatever
[20:52:21] tubbo: and then create Purchase objects from each position in the JSON response array
[20:52:34] rhizome: and basically forget about using associations for it
[20:52:57] tubbo: you have to build in your own "associations" to objects that live outside activerecord.
[20:53:21] alan_andrade: In this scenario wouldn't apply logically, but It'd be pretty nice to do Customer.create foo:barr, purchases_attributes: { [amount: 1] }
[20:53:57] tubbo: i think you can do that, if you define `def purchases_attributes=` on Customer
[20:54:28] tubbo: you can define it to just pass the Hash it's given as JSON to a `POST /purchases` endpoint
[20:54:30] alan_andrade: right, but that's some logic has already being written.
[20:54:42] tubbo: uhh...what?
[20:54:57] alan_andrade: yes, I mean by rail/active_record
[20:55:12] tubbo: not really, rails/AR doesn't know about your JSON API
[20:55:18] tubbo: it's for talking to a database
[20:55:32] tubbo: you're basically just making methods that act like AR but talk to a different backend, that isn't relational
[20:56:08] tubbo: i like using HTTParty myself for making classes that are "API models" for external resources
[20:56:37] alan_andrade: But knows the relation between Customer and Purchase, so if I can use accepts_nested_attributes but saving with an API call
[20:57:08] tubbo: you might have to write that stuff in yourself
[20:57:35] tubbo: accepts_nested_attributes_for i *believe* just moderates the arguments you give in new(), but doesn't care what kind of backend you use
[20:57:45] alan_andrade: I get I can write all these methods myself, my question was focused on knowing how stupid/good idea is to keep AR code as much as possible
[20:57:57] tubbo: oh it's absolutely not a good idea.
[20:58:09] tubbo: use AR for what it was intended for, and if it doesn't suit your needs build your own thing
[20:58:13] tubbo: definitely++++++++++++
[20:59:06] alan_andrade: right, but when I think that, I also think in gem like squeel.
[20:59:09] alan_andrade: Have you used it?
[20:59:10] tubbo: i see models backed by non-AR stuff all the time, mixed in with AR all the time
[20:59:23] tubbo: i've never used sequel, no
[20:59:53] alan_andrade: It exposes an API that let you do much more stuff with DB.
[21:00:12] alan_andrade: So it's a gem that is sitting in the middle of Arel and AR.
[21:00:31] tubbo: that's cool
[21:01:25] alan_andrade: Right know I think its a pretty complex gem, solving a hard problem that personally I wouldn't dig into.
[21:01:44] alan_andrade: but what was it that Ernie Miller though it was a good idea?
[21:02:11] alan_andrade: Sound like crazy to me, specially with the instance_eval feature it was.
[21:02:23] Scient: what problem does it solve
[21:02:36] Scient: and how does one method or construct define if the code is bad or not :P
[21:03:04] tubbo: squeel seems to extend arel a bit
[21:03:19] alan_andrade: Ohh, I didn't mean the code was bad, its complex for me. I don't have that level of coding to understand how/what it does
[21:03:39] tubbo: not a big fan of that expression syntax though
[21:04:02] tubbo: i like the way rails 4 does it: where(blah: true).and(foo: bar).or(bat: baz)
[21:04:08] tubbo: .not() as well
[21:04:09] alan_andrade: Its hard to get the syntax, but once you get it, sql queries can be optimized nicely
[21:04:27] Scient: different syntax is hardly optimization of queries :P
[21:04:35] alan_andrade: Man, the .not() was something I being waiting for soooo long.
[21:05:01] Scient: i just write sql by hand for complex stuff
[21:05:22] tubbo: yeah it doesn't seem to actually optimize anything, it's just a different syntax for writing where() clauses
[21:05:29] tubbo: as well as a way to name attributes in a table
[21:06:37] alan_andrade: You're right, maybe it doesn't optimize too much, but I rather read complex sql queries written with squeel than with strings
[21:06:40] tubbo: having each statement in the query be in different, chained methods is imho much easier to refactor and build upon
[21:06:42] alan_andrade: Are easier to read IMO
[21:07:25] tubbo: being able to call sql functions in ruby is nice :)
[21:07:38] alan_andrade: I appreciate your time discussing this idea. Thanks a lot @tubbo @Scient
[21:07:50] tubbo: where date: coalesce(params[:date], '%Y-%m-%d') :)
[21:08:16] tubbo: instead of where date: %(coalesce('#{params[:date]}', '%Y-%m-%d'))
[21:08:33] chrisan: is there a way to pass multiple values for a constraint like domain/subdomain? `constraints :subdomain => "www1" do` say adding "www2" as an example
[21:11:29] chrisan: nm self noob answer, pass an array :)
[21:12:16] alan_andrade: hah, cool you figured it out
[21:15:28] tum: Hi RoR community. I am a new to rails. I have a question about database schema.
[21:16:23] tum: I have two classes of users that share some fields, but not all.
[21:16:42] tum: Is there a concept of database table inheritance?
[21:16:58] tum: Or shuold I create two separte database tables?
[21:17:05] tum: *should
[21:18:29] alan_andrade: Single Table Inheritance might be one answer
[21:18:48] skyjumper: not a popular answer
[21:19:00] alan_andrade: Yeah, not very cool
[21:19:52] alan_andrade: How would you model your tables in the DB if not STI ?
[21:19:57] rdev5: Radar on vacation or something
[21:20:58] tum: I see. Is STI the only way to go? What are the pros/cons?
[21:21:01] knes: Hello, I have multple models and not too sure how to access data in each one of them when they are associated together http://pastie.org/8266519
[21:21:32] knes: Questions is for example in if I dot captain = Team.first.gameweeks.last.captain
[21:21:53] knes: How can I access captain.gameweek.some_field for example ?
[21:21:56] asahi: wondering if someone can tell me why isn't working - https://gist.github.com/asahi1/6330478
[21:22:02] knes: like go "back up"
[21:23:04] skyjumper: tum: polymorphic associations?
[21:23:13] alan_andrade: A captain would have multiple gameweeks right ?
[21:24:15] knes: they have multiple gameweeks
[21:24:34] alan_andrade: hm, you'd have to specify what gameweek you want to 'access'
[21:24:42] alan_andrade: captain.gameweeks.first.blah
[21:25:16] knes: but by doing "C = Team.first.gameweeks.last.captain" for example
[21:25:33] knes: should it knows which gameweek_id it is
[21:25:50] alan_andrade: I..... don't think so
[21:26:16] knes: when I do c.gameweeks.first it returns nil
[21:26:19] knes: at the moment
[21:26:37] alan_andrade: hm, let me see
[21:27:15] rhizome: knes: just get the game and pull the captain, field, etc. out of it
[21:28:51] knes: but the thing is that I need to know which gameweeks the captain is associated with the get the gameweek "number" field so I can get the captain data for that gameweek
[21:28:57] alan_andrade: @asahi you might neet update_all instead ?
[21:29:14] knes: something like captain.gameweeks.find_by(number:2).total_pts
[21:30:07] alan_andrade: there's no other way, you need the gameweek you want to access.
[21:30:27] alan_andrade: iterate over captain.gameweeks ?
[21:30:48] knes: sorry I meant captain.gameweeks_stat.find_by(number:2).total_pts
[21:31:11] asahi: alan_andrade: i figured out the problem. i shouldn't have had the bang after map!
[21:31:34] knes: but if I knew wich gameweek @captain is attached too., I can do @captain,gameweeks_stats.find_by(number: @captain.gameweek.number).total_pts
[21:32:17] alan_andrade: ohhhh, right!!! @asahi
[21:33:38] alan_andrade: @knes I'm confused. I don't I get what you're trying to do.
[21:34:39] knes: yes, sorry. let me try to explain it better. hold on.
[21:36:13] knes: My Player model ( football player, so only ~600 unique ) is associated to a stat model. In the stat model I have all the stat for that player for that specific "gameweek"
[21:36:54] knes: I also have Gameweek model, which has a has_many associations with the Player
[21:37:02] knes: so I can now the lineup for that gameweek
[21:37:11] knes: Gameweek also have a "number" field
[21:37:37] knes: I also have a captain field in Gameweek which is an other associated with the Player model
[21:38:11] knes: so when I do @captain = Gameweek.last.captain
[21:38:44] knes: I would like to be able to do @captain.Stats.find_by(number: @captain.gameweek).total_points
[21:38:56] knes: or something like that
[21:39:10] knes: sorry, I'm a noob :/
[21:39:30] LauraE: I created an app with scaffold (photo title:string place:string -- using scaffolding), seeded with a couple of records, modified the routes.rb to just have only this line: get '/photos/:id', to: 'patients#show'. Now how can I get this to work int the browser (localhost:3000/photos/1 - does not work).
[21:39:49] alan_andrade: I'm trying to get the relationship between Player and Stats.
[21:40:52] alan_andrade: So there's a join table that will hold the gameweek number, and a bunch a stat_id
[21:41:11] alan_andrade: player has many stats through player_stat table
[21:42:24] knes: The easier questions does rails knows that when I do @captain.gameweek I want to have access to the Gameweek specified in the @captain = Gameweek.first.captain ?
[21:42:43] knes: But yeah otherwise your relationsships are good
[21:44:07] alan_andrade: So, I think I have the answer but I could write it in squeel.
[21:44:14] alan_andrade: the idea is to query:
[21:44:46] alan_andrade: captain.stats.where( player_stats: { gameweek.number: 5 } )
[21:45:39] alan_andrade: What you want to do is not possible
[21:46:25] alan_andrade: captain = Gameweek.first.captain # => And then assume captain.gameweek will be tight to the first Gameweek ? Not doable
[21:46:50] alan_andrade: I mean, not possible with current active record features
[21:47:33] knes: ok got t
[21:47:43] knes: thanks for the help
[21:47:49] knes: I would look for an other way :)
[21:48:33] alan_andrade: hm , I don't feel I helped :
[21:48:41] alan_andrade: let's figure it out
[21:49:01] alan_andrade: gameweek = Gameweek.last
[21:49:26] alan_andrade: captain.stats.in_gameweek( gameweek )
[21:51:29] alan_andrade: scope :in_gameweek, ->(gameweek){ joins(:player_stats).where(player_stats: { number: gameweek.number } ) }
[21:52:08] alan_andrade: not so sure the where clause will work with this code though.
[21:52:13] alan_andrade: but that'd be my approach
[21:52:16] LauraE: I see my mistake - thank goodness for gem better_errors ( I installed it, and error was more obvious!) So I am all set :)
[21:52:57] knes: the thing is at the moment I don't have the stats model
[21:53:02] knes: I was thinking of adding it
[21:53:26] knes: what Im doing at the moment is scrapping http://fantasy.premierleague.com/web/api/elements/12/
[21:53:36] knes: and storing the data in the Player model
[21:53:46] knes: As you can see on that json, there's a fixture_history
[21:54:10] knes: I was thinking of either creating a Stat model for each of the array
[21:54:28] knes: or just browsing / querying the array
[21:54:50] knes: but for that I need to know in which "gameweek" ( Gameweek.number) we are
[21:55:01] siaW: i have a Broker < ActiveRecord::Base. how do ha put has_many on it from a User <ActiveRecord. i want to make it so the user has many comments from the User. the User has comments and username. any help how to make the association? please?
[21:56:12] knes: My end result would be to display a table per Team, per gameweek so I need to know the scores/stats of each player in that specific "gameweek" ( Gameweek.number)
[21:58:56] alan_andrade: Why don't you think about the problem in that order ?
[21:59:08] alan_andrade: Team > Gameweek > Stats > PlayerStats
[22:01:04] alan_andrade: team.each, gameweeks.each, gameweek.stats, stat.player_stats...
[22:01:53] knes: This is more or less that I have. Team ( Team_name, etc ) > Gameweek ( number, starters = 11 Players, subs =4 Players, captain = 1 Player, vice_captain = 1 Player) > Player ( copy of http://fantasy.premierleague.com/web/api/elements/12/)
[22:02:08] knes: Maybe I need to work on the controller and the view. It will help me figure it out
[22:02:19] knes: maybe it is a none problem :)
[22:02:49] knes: While we were talking I stumbled an other problem. http://pastie.org/8266519
[22:03:28] alan_andrade: what other problem ?
[22:03:33] knes: Why when I have something like @gameweek = Gameweek.find(x) then I do @gameweek.substitues << Player.find(x)
[22:03:42] knes: once I save @gameweek
[22:04:09] knes: I have the same player I pushed in @gameweek.substitues and also in @gameweek.players
[22:04:32] knes: in the Gameweek model, gameweek.rb
[22:05:53] knes: this is the scrapper code
[22:05:57] knes: http://pastie.org/8266628
[22:06:04] alan_andrade: There is no way to know the difference between a Player and Substite
[22:06:36] alan_andrade: The join table only has gameweek_id and player_id
[22:07:04] alan_andrade: so adding a player or a substitute is the same thing.
[22:07:39] alan_andrade: I think you need another join_table ?? (not sure though)
[22:07:47] alan_andrade: you have gameweeks_players
[22:07:54] alan_andrade: you need gameweeks_substittues
[22:08:15] knes: in schema I already have it though
[22:08:23] alan_andrade: that way a player is definitely different from player
[22:08:37] knes: http://pastie.org/8266636
[22:08:44] alan_andrade: Then get rid of the class_name
[22:08:49] knes: relevant part of the schema
[22:08:56] alan_andrade: no no, my bad, forget last line.
[22:09:03] knes: oups not
[22:09:25] knes: that is the schema.rb
[22:09:25] knes: http://pastie.org/8266638
[22:10:00] alan_andrade: Right, this schema is infering there is a substitute table
[22:10:24] alan_andrade: that's why you're using class_name: Player
[22:11:22] knes: I dont have a subsitute table but I think that what has_and_belongs_to_many :substitutes, class_name: "Player"
[22:12:07] alan_andrade: lets put this in context.
[22:12:10] bdscvr: DouweM: HashNuke: late answer but I should share it: http://api.rubyonrails.org/v3.2.14/
[22:12:42] alan_andrade: Team a has many Game weeks
[22:13:15] alan_andrade: GameWeek 1 has many players and many substittues
[22:13:30] alan_andrade: players are: Ronaldo
[22:13:34] alan_andrade: substittues are: []
[22:13:38] knes: ( and one captain and one vice_captain )
[22:14:00] alan_andrade: when you do gameweek1.substitutes << ronaldo
[22:14:10] alan_andrade: this whould go away as a player ?
[22:14:21] alan_andrade: Ronaldo can't be a player and substite
[22:14:34] alan_andrade: is that what you're trying to solve ?
[22:14:55] alan_andrade: gameweek1.substitutes << xavi
[22:15:07] alan_andrade: gameweek1.players # => xavi, ronaldo
[22:15:17] alan_andrade: gamewee1.substitutes # => xavi, ronaldo
[22:15:32] knes: at the moment when I add in substitues, it also add the Player in gameewek1.players
[22:16:28] knes: and vice versa
[22:16:33] alan_andrade: This is what I think its happening:
[22:16:58] alan_andrade: the class_name option in a habtm method, will override the real join class.
[22:17:15] alan_andrade: meaning it's actually saving on gameweek_players
[22:17:45] alan_andrade: I think we need a has_many :players, through: blah, source: Player
[22:18:11] alan_andrade: habtm won't work if you have a different class name.
[22:18:24] knes: I think I need to use join_table
[22:18:24] alan_andrade: you need to create the join table model as well
[22:18:27] knes: and specify the table
[22:18:52] knes: like has_and_belongs_to_many :substitutes, class_name: "Player", join_table: "gameweeks_substitutes"
[22:19:10] knes: going to try it now
[22:19:43] alan_andrade: class GameweekSubstitute; belongs_to :substitute, class_name "Player"...' end
[22:19:57] alan_andrade: oorrrr, yeah!
[22:20:07] alan_andrade: using join_table option sounds good
[22:21:21] knes: ok nearly there
[22:21:31] knes: getting an error because I have t.integer "substitute_id"
[22:21:35] knes: instead of player_id
[22:22:48] alan_andrade: hmm, interesting, It shouldn't complain about that umo
[22:23:40] alan_andrade: so it hits the real join table, but now it's looking for player_id since class_name is "Player"
[22:24:34] knes: it fixed the error
[22:24:38] knes: and it is working
[22:24:47] knes: Than you so much
[22:25:23] knes: it was indeed the join_table that needed to be specified because I had 2 HMBTM associations
[22:28:55] knes: Alright, on this good news Im going to bed
[22:29:01] knes: thanks again for the help Alan
[22:32:48] Bumptious: hello everybady. I am trying to come up with my own rails base application which I can use as a starting point for building sites using a bunch of packages I like to use
[22:32:50] Bumptious: https://github.com/limratana/base_app
[22:33:29] Bumptious: i don't have a super clear path/plan for this and I was wondering if anyone had some advice
[22:43:01] knix: Bumptious: http://edgeguides.rubyonrails.org/rails_application_templates.html
[22:45:03] Bumptious: @knix thank you, checking it out now
[23:00:21] Bumptious: @knix this looks like exactly made for what i am trying to do haha
[23:01:39] Bumptious: any opinion on Rails Composer?
[23:01:52] rgbdev: Is it appropriate to post a Stack Overflow link or no? I've got a weird issue going on with username availability checking between development (MySQL) and production (Postgres)
[23:03:15] rhizome: are you trying to use db-specific functionality for it?
[23:05:18] rgbdev: rhizome: May I send you a PM with the link to specific function?
[23:24:02] bonhoeffer: i'm having trouble reading a simple json render: https://gist.github.com/tbbooher/6330975
[23:24:20] bonhoeffer: i'm pretty sure there is some easy syntax to get the data i need
[23:25:21] bonhoeffer: i really want a hash not an array
[23:28:36] rgbdev: I'm having trouble with removing an AND statement from a generated query: https://gist.github.com/roberthimler/eaefdf49159313e6147e
[23:29:31] alan_andrade: @bonhoeffer your pastie its huge and I don't get what's wrong.
[23:29:49] bonhoeffer: alan_andrade: i tried to make it small, and then the full file for reference
[23:30:16] bonhoeffer: apologies, i have a simple question . . . my js reads the json as an array, i really just want a hash
[23:30:23] bonhoeffer: votes[2] produces Object {CO05: 3}
[23:30:38] bonhoeffer: i really want votes['CO05'] to produce 3
[23:31:22] alan_andrade: @rgbdev you can't with that approach
[23:31:44] alan_andrade: If you're using rails 3.x you can't. If you're on Rails 4, you might.
[23:31:51] bonhoeffer: alan_andrade: sorry -- the big file was on the top -- it was just there for reference :)
[23:32:22] alan_andrade: I'd do it by doing where "blah or foo
[23:32:48] alan_andrade: User.where("foo =? or blah = ?", [a,b])
[23:32:49] rgbdev: alan_andrade: 3.2.6
[23:33:12] alan_andrade: if you're using squeel gem, query could be written as.
[23:33:12] apeiros: if it's =, you can also use hashes
[23:33:15] rgbdev: alan_andrade: Good call. I'll try that.
[23:33:20] apeiros: User.where foo: a, blah: b
[23:33:39] alan_andrade: This will do an AND.
[23:33:53] apeiros: ah, you had OR there, right
[23:34:47] alan_andrade: with squeel would be writter as: User.where{ (foo == blah) | (blah==foo) }
[23:36:44] rgbdev: alan_andrade: https://gist.github.com/roberthimler/612a335f7d7ec4079197
[23:37:12] bonhoeffer: alan_andrade: i have a much better gist now
[23:37:22] bonhoeffer: https://gist.github.com/tbbooher/6330975
[23:37:34] bonhoeffer: my json looks like [{"VA08":4},{"CA12":1},{"CO05":3},
[23:37:49] bonhoeffer: i think this would work if my json looked like my json looks like {"VA08":4},{"CA12":1},{"CO05":3},
[23:37:54] bonhoeffer: (not an array)
[23:37:56] alan_andrade: ohhh right! you dont even need the OR
[23:38:09] bonhoeffer: is generated by: render json: PolcoGroup.districts.map{|d| {d.short_name => d.votes.size}}
[23:38:13] rgbdev: alan_andrade: ?!
[23:39:25] alan_andrade: @rgbdev only thing you're interested to match is username right ?
[23:39:34] rgbdev: alan_andrade: Correct
[23:40:02] alan_andrade: That's what I mean with you don't even need the OR clause. Because you're only matching 1 column.
[23:41:15] rgbdev: Sorry, I understand that, but how would it actually be written then?
[23:41:40] alan_andrade: I'll comment in the gist.
[23:44:04] alan_andrade: @bonhoeffer looking
[23:44:16] bonhoeffer: alan_andrade: really i just want to generate a hash from AR.map
[23:44:33] rgbdev: alan_andrade: Thanks! Hmm, error: ArgumentError (wrong number of arguments (0 for 1))
[23:44:38] bonhoeffer: Books.map{|b| {b.year => b.size}}
[23:44:52] alan_andrade: @rgbdev stacktrace ?
[23:45:01] bonhoeffer: and get {1999: 10}, {2000: 12}
[23:45:55] rgbdev: alan_andrade: Commented on gist
[23:45:55] bonhoeffer: or really {1999: 10, 2000: 12, ...}
[23:46:21] alan_andrade: @bonhoeffer yeah, I think you're mixed up with the data structure you want.
[23:46:36] bonhoeffer: {1999: 10, 2000: 12, ...} direct to json map
[23:46:49] alan_andrade: {199:10}, {100: 12} is not possible, has to be contained by an array
[23:47:09] alan_andrade: {1999: 10, 2000: 122} sounds good
[23:47:24] workmad3: bonhoeffer: Hash[Books.map{|b| [b.year, b.size]}]
[23:47:39] bonhoeffer: yeah -- cool -- i'm thinking i can do .each { |k,v| hash[k] = v } as well
[23:47:43] workmad3: bonhoeffer: or Books.map{|b| {b.year => b.size}}.inject(&:merge)
[23:48:20] workmad3: bonhoeffer: or indeed yes, Books.each_with_object({}) {|b, hsh| hsh[b.year] = b.size}
[23:48:59] alan_andrade: @rgbdev verify your method called checkname. sounds like you're not passing an argument is necessary
[23:49:21] alan_andrade: checkname is the controller method
[23:50:13] alan_andrade: I don't think the missing argument is in the query, might me somewhere else
[23:50:25] alan_andrade: Or c/paste the full stacktrace to know what's going on
[23:50:29] rgbdev: alan_andrade: user = User.where('lower(username) = ?', scrubb) works!
[23:50:46] rgbdev: Someone made an amazing response here: http://stackoverflow.com/questions/18424006 alan_andrade
[23:52:57] alan_andrade: I'm confused why you're doing the lower()
[23:53:30] alan_andrade: It feels you're allowing MATT and matt as different usernames ?
[23:54:37] rgbdev: alan_andrade: No, the opposite… It's because mysql is case-insensitive by default on text equality, postgres is not.
[23:55:36] workmad3: rgbdev: you're doing that the wrong way around tbh ;)
[23:55:44] alan_andrade: So you're using mysql, but coding to support postegres in the future ?
[23:55:53] workmad3: rgbdev: you need to be calling lower(?) in your where for that
[23:56:11] rhizome: username.downcase
[23:56:12] alan_andrade: right, I think workmad3 is right
[23:56:15] workmad3: rgbdev: otherwise someone signing in as 'Matt' won't match their account 'Matt' that they signed up as
[23:56:44] workmad3: rgbdev: do you trust that your database and your rails app are set up with the same locale downcasing algorithms? or do you not worry about that? :)
[23:57:32] workmad3: rgbdev: or are you only really worried about english/latin-alphabet countries at the moment (and forseeable future)
[23:59:37] workmad3: rhizome: ^^ sorry, those were really aimed at your 'user.downcase' answer ;)