« Back to channel list

#RubyOnRails - 11 July 2014

« Back 1 day Forward 1 day »
[00:00:52] j_mcnally: febuiles: im half kidding
[00:00:56] febuiles: I think the ruby version was due to the fact that they couldn't use REE anymore (that repo is at 2.1) but I' m not sure on that
[00:01:37] febuiles: j_mcnally: I remember they wanted to make the upgrade to Rails 3 in 2011, I'm sure they have their reasons :)
[00:01:55] febuiles: since 2011*
[00:09:39] kaspergrubbe: DHH have commented on that he don't know what all the Github engineers are doing, I think this could be the answer :-)
[00:20:10] Altonymous: Using postgresql we're noticing that sometimes after creation of a record other instances don't see the new record??? So for instance we create the record with if object.save then assuming the if returns true we enqueue a background job.. That background job generally doesn't get picked up for a 2nd or two and runs in a different thread. When the job is picked up it sometimes throws a RecordNotFound exception, but on retry,
[00:20:10] Altonymous: seconds later, works fine. Is there something we should be doing to ensure the object is found by the background job? It's intermittent and like I said generally works on retry.
[00:24:44] koyd: Altonymous: are you using postgresql as a master-slave setup, or single db host?
[00:33:11] rhizome: lots of unstated information there
[00:42:42] fluve: hi there, is anyone able to help me with passing through an :id params on a render in create action that was initially passed through to the originating action?
[00:49:50] helpa: fluve: 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.
[00:49:50] Radar: fluve: !code
[00:49:59] Radar: fluve: Likely that you're trying to do something like the post + comments setup from the GS guide.
[00:50:21] fluve: i'll do a gist but its not from the gs guide
[00:53:27] fluve: https://gist.github.com/timhaynes/5e558c791f25a9205f74
[00:53:38] fluve: Line 18 is where I'm falling down
[00:53:47] fluve: (or perhaps before that...!)
[00:56:36] Radar: fluve: What is hitting the create action? Where is the form?
[00:57:02] fluve: the form is in book_direct.html.erb
[00:57:26] fluve: it works fine if there are no errors, but if there are i want to go back to that page and show errors..
[01:08:47] Radar: fluve: Show us the code from the form please.
[01:11:39] fluve: radar: https://gist.github.com/anonymous/b083c7864b61c5ee7fa5 thanks
[01:12:18] Radar: fluve: 1) why are you passing through @user if it's just current_user 2) why not form_for([@event, @event_booking])
[01:12:29] Radar: This is exactly the example from the GS guide.
[01:12:34] Radar: !getting-started
[01:12:49] sevenseacat: no GS guide for you
[01:12:57] helpa: Nom nom. Thanks, Radar!
[01:12:57] Radar: !botsnack
[01:13:00] helpa: http://guides.rubyonrails.org/getting_started.html - Getting started with Ruby on Rails guide written by Mike Gunderloy
[01:13:00] sevenseacat: !gettingstarted
[01:13:08] Radar: I'm sure that the hyphen was supported too
[01:13:25] Radar: Section 6.4 in that guide covers that example
[01:13:31] fluve: I apologise, have read through that some time ago but will do so again!
[01:13:32] Radar: Creating a comment for a post == creating a booking for an event
[01:14:36] sevenseacat: also, happy friday to you all!
[01:15:04] fluve: happy friday
[01:16:12] fluve: also, thanks radar for pointing me in right direction, just reading through this and makes sense
[02:22:03] cronus: if an Account has_many Subscriptions how do I select an account that doesn???t have any subscriptions where subscription_name=???something??? ? I don???t get how to do this with AR
[02:28:17] cronus: Account.joins(:subscriptions).where(subscriptions: {name: ???something???}).all finds all accounts that have a subscription with name something.. how do I find all accounts that do NOT have a subscription with name something?
[02:28:50] sevenseacat: if you're using rails 4, just use where.not
[02:29:30] cronus: hm guess i could upgrade.. what if im using rails 3?
[02:29:46] sevenseacat: i feel your pain dude
[03:19:14] fwaokda: what would be the best way to have my webpage "listen" for input followed by the enter key? I don't want to supply a textbox for it just kinda want to listen and record the input on the keyboard and then execute a method once the enter key is pressed
[03:20:46] uberjar: fwaokda: a javascript library like jQuery can make that easier for you
[03:21:02] uberjar: fwaokda: $('input.user-search').keypress(function(event){
[03:21:04] sevenseacat: listen for input on what?
[03:21:08] uberjar: if(event.keyCode == 13){ etc
[03:21:12] sevenseacat: there has to be some kind of input
[03:21:22] fwaokda: uberjar, ok thanks! I'll look into that, would i likely use a textbox but just set it to display: none;?
[03:21:47] uberjar: fwaokda: you can do it a bunch of different was.. just check into jquery keypress() function
[03:21:56] fwaokda: sevenseacat, i have a barcode scanner that acts as a keyboard. It submits a 13 char barcode number followed by an enter key
[03:22:08] fwaokda: uberjar, thanks!
[03:42:55] lanox: Radar: i thought i bookmarked the books to get, but i did which one did you recommend
[03:57:57] Radar: lanox: Rails 4 in Action and Well Grounded Rubyisy
[04:02:31] banisterfiend: how do i add a capistrano hook so that it runs a local command before deployment? (i want to ensure that the local branch has been pushed to the remote)
[04:07:42] lanox: Radar: Thanks mate
[04:11:28] lanox: Radar: are the both books for newbies ? which one should i buy first
[04:12:27] quazimodo: so I need to migrate a schema and change some data. Rake to the resuce?
[04:12:32] quazimodo: or should I find a gem to help
[04:16:09] lethjakman: lanox: can I throw eloquent ruby in there? :)
[04:16:53] lethjakman: quazimodo: that sounds like something you can do with a normal migration...however I'd need more detail
[04:17:15] lanox: lethjakman: sure is that for complete noob
[04:18:05] iFire: if user.send(@options[:active_column]) == 'f'
[04:18:05] iFire: return false
[04:18:12] iFire: why is this wrong
[04:18:33] sevenseacat: depends what 'right' is
[04:19:07] iFire: I'm trying to set false as the return of a function
[04:19:07] lethjakman: lanox: sure, assuming you know things like arrays and such...you probably want basic programming capabilities
[04:19:29] iFire: the database is a table with users and a column active with a value of 't' or 'f'
[04:19:50] iFire: if the user is inactive return false as the function return
[04:20:05] sevenseacat: whats wrong with `user.active?`
[04:20:29] sevenseacat: `return user.active?`, even
[04:21:04] iFire: well I want the column to be customizable
[04:21:08] quazimodo: lethjakman: i haven't spent time doing any migrations that act on data yet, so I don't know. All i know is that I need to rename a model so I have to change table name, change model/view/controller names & references, then go into the polymorphic stuff and change OldClassname to NewClassname
[04:21:46] sevenseacat: ok,so you might need send
[04:21:51] sevenseacat: you definitely dont need =='f'
[04:21:57] sevenseacat: thats just dumb
[04:22:06] lethjakman: quazimodo: sounds feasible to me. you can execute direct SQL in a migration file. I'd recommend manually writing an up and down in that case.
[04:22:07] iFire: I don't know ruby :(
[04:22:38] sevenseacat: time to learn if you want to write rails apps :)
[04:22:46] iFire: sevenseacat: so what should it be?
[04:23:08] lanox: lethjakman: do you know any of those books.
[04:23:09] sevenseacat: depends on what @options[:active_column] is
[04:23:24] sevenseacat: and what happens if it gets set to a column that doesnt exist
[04:23:26] iFire: sevenseacat: well it's supposed to be set to active in a yml
[04:23:36] sevenseacat: so its not really customizable then, is it
[04:23:49] iFire: sevenseacat: if it doesn't exist I think it hard crashes
[04:23:54] iFire: or something
[04:24:11] lethjakman: lanox: the ones Radar recommended? I own Rails 4 in Action. I haven't gotten to the well grounded rubyist but it's in my works library.
[04:24:57] lanox: so the ones that he recommended are complet books for noobs
[04:25:02] lanox: yeah looking to get them
[04:25:04] iFire: sevenseacat: I don't know the part when you test for truth
[04:25:19] sevenseacat: you dont need to 'test for truth'
[04:25:25] sevenseacat: it either is truthy, or it isnt
[04:25:28] lethjakman: lanox: I recommend getting Ruby first then moving to rails.
[04:25:38] lethjakman: I tried the opposite way and it took me longer because of it.
[04:25:54] lanox: aha i see
[04:26:21] lanox: so the million $ question which ruby book to get
[04:26:23] iFire: if !user.send(@options[:active_column]) doen't work though
[04:26:32] helpa: What "didn't work"? Did your server not start? Did your computer explode? Did your webpage turn bright pink? Did your client not pay your bill on time? You may have to be more specific. A Gist (http://gist.github.com) of the code that doesn't work (and the error you are getting) will be helpful.
[04:28:35] lethjakman: lanox: ok...so my personal recommendation would be this: https://www.ruby-lang.org/en/documentation/quickstart/, then Eloquent Ruby, then guides.rubyonrails.org, then Rails 4 in Action.
[04:28:42] lethjakman: you should be pretty grounded after that.
[04:28:56] lethjakman: but that's just lethjakman's opinion.
[04:31:14] lanox: well i need to start somewhere
[04:31:25] lanox: so really any opinion is a good opinion
[04:31:43] lanox: well i am coming from perl so it shouldn't be 2 hard i guess
[04:32:04] lethjakman: good luck with your journey, you're in a good place to start :)
[04:32:06] lethjakman: yeah it's not
[04:32:12] lethjakman: they're fairly similar in a lot of ways
[04:32:18] lanox: i am trying to transit from been plain sys admin to devops
[04:33:03] lethjakman: one of my coworkers transitioned from a sysadmin to a developer a few years ago and he was very happy with the decision
[04:34:07] lanox: yeah i am trying to do that as well but when i was 20 i only belived in html and css and nothing else for personl work/blogs blah blah
[04:34:25] lanox: and now in my close to 30s i realieazed what a full i was
[04:34:34] lethjakman: it's never too late.
[04:34:50] lethjakman: you'll enjoy making interactive sites.
[04:35:03] lethjakman: you've got a head start against alot of guys who don't know html/css very well too.
[04:35:36] lanox: we shell see i guess :)
[04:36:57] iFire: helpa: sevenseacat I got it to work
[04:37:30] lethjakman: oh what a fool I was when I started learning rails. this app is a mess.
[04:37:33] ckboii89: hey guys, can the .create() function take more than 1 param? i need create attributes for 1 single call
[04:37:42] iFire: sevenseacat: if you want a look the code is at https://github.com/fire/casino-activerecord_authenticator
[04:38:03] ckboii89: liek this .create(param_1,param_2)
[04:42:04] quazimod1: sevenseacat: I'm reading some PMBOK
[04:42:34] quazimod1: ACTION remembers why he doesn't remember anything from management class
[04:47:55] christopherjbolt: Anyone have experience with simple_form, I???m trying to instantiate a form with parameters. Something like this ??? https://gist.github.com/Iknewthisguy/d0842c90106db021d0ce
[04:50:14] lethjakman: christopherjbolt: what's the issue?
[04:51:22] christopherjbolt: After I select a value and post, which posts back to the same form it doesn???t select the value for that input.
[04:52:07] christopherjbolt: i.e. I select ???Pending???, which posts :pending back to the form, but my guess is it doesn???t select the value out of the collection because it???s not the same.
[04:52:40] lethjakman: christopherjbolt: try it as a hash
[04:52:49] lethjakman: .to_h at the end of it should do the trick
[04:53:17] lethjakman: just an idea, I've been away from simple form for a minute.
[04:55:22] christopherjbolt: The value posted back to the form is ???pending??? which doesn???t allow to_h
[05:01:23] christopherjbolt: lethjakman: Got it. selected hash
[05:01:24] lethjakman: christopherjbolt: no, I mean on your array.
[05:35:40] tagrudev: !isitfriday?
[05:35:48] sevenseacat: see, helpa knows his shit.
[05:39:57] lanox: ugh today feel like its never going to end
[05:41:28] pontiki: the day will end. but time won't stop.
[05:42:16] mozzarella: sevenseacat: did you figure it out?
[05:42:20] mozzarella: the activemodel thing
[05:43:19] sevenseacat: what activemodel thing
[05:44:18] mozzarella: Board.first.title? => true
[05:44:26] mozzarella: although title is not a boolean
[05:44:37] sevenseacat: oh that thing
[05:44:44] fwaokda: it is normal to have views that aren't tied to a specific model yes?
[05:45:43] sevenseacat: views have nothing to do with models
[05:47:19] sevenseacat: mozzarella: just looks like syntantic sugar. i dont know where exactly its defined.
[05:48:13] mozzarella: I??think I??know but I??don't really understand the code
[06:20:31] mozzarella: I'm getting some weird syntax errors all of a sudden
[06:24:45] mozzarella: http://i.imgur.com/mxUQBde.png
[06:24:50] mozzarella: what's wrong with that line
[06:25:52] sevenseacat: the missing - in <%- ? does erb need one? i dont know
[06:26:18] sevenseacat: in future, code is preferred, rather than screenshots
[06:27:05] mozzarella: I??have never seen <%-
[06:27:13] mozzarella: but -%> is used to remove the new line, I think
[06:28:00] sevenseacat: i much dislike logic like that in views
[06:28:08] sevenseacat: erb makes it particularly ugly
[06:29:01] mozzarella: you know what's weird?
[06:29:13] sevenseacat: no but im sure youre going to tell me
[06:29:19] mozzarella: everything was working fine before I changed some file
[06:29:29] mozzarella: and that's not even the file I changed
[06:29:35] mozzarella: changed/edited
[06:31:26] mozzarella: I??reverted my changes and I'm still getting the syntax error
[06:31:33] mozzarella: I??just don't know what to think anymore
[06:31:39] helpa: http://i.imgur.com/m9m3wr9.gif
[06:33:18] mozzarella: http://i.imgur.com/tsAdMbK.jpg
[06:33:48] sevenseacat: what part of 'code, not screenshots' did you miss the first bunch of times i told you?
[06:36:50] mozzarella: http://paste.fedoraproject.org/117175/14050605/
[06:38:35] mozzarella: lol? I??get a syntax error everywhere I??go on the website
[06:38:42] mozzarella: every fucking where
[06:38:46] mozzarella: I??haven't changed anything
[06:38:50] sevenseacat: you must have
[06:39:25] sevenseacat: code doesnt spontaneously just invalidate itself
[06:40:29] mozzarella: I??think I'm going to update my gems, and hopefully that will fix it
[06:40:43] sevenseacat: thats a terrible way to fix the problem, and likely wont work.
[06:42:56] mozzarella: if it doesn't work I'm going to restart my computer, I haven't changed anything I??swear
[06:43:00] mozzarella: this is madness (?????????????????????)
[06:43:17] mozzarella: must be the gods or something
[06:43:44] arathald: madness, probably, yes
[06:44:04] sevenseacat: its you changing something that you likely thought was completely unrelated, so you discounted it
[06:44:18] sevenseacat: surprise! its related
[06:44:46] mozzarella: I??switched to branch master which hasn't been updated since yesterday, and it's still happening
[06:46:18] mozzarella: well, updating my gems didn't do shit
[06:46:32] sevenseacat: ACTION is not surprised
[06:46:48] mozzarella: let's restart my computer, my ram is probably corrupt
[06:48:50] sevenseacat: ACTION has a sneaking suspicion what the problem is, based on where the error came from within rails
[06:50:03] sevenseacat: ACTION will wait until mozzarella admits to tinkering with activemodel while looking into that boolean thing yesterday
[06:50:43] mozzarella: holyshit you think?
[06:50:57] mozzarella: I??edited something with pry, not sure if it wrote the changes to the disk
[06:51:42] sevenseacat: try `gem pristine activemodel`
[06:54:35] mozzarella: I??didn't know pry would write it on disk
[07:25:58] _lazarevsky_: morning #rubyonrails
[07:37:04] _lazarevsky_: hey guys I'm getting a syntax error
[07:37:10] _lazarevsky_: was wondering if you could spot where the problem is
[07:37:20] _lazarevsky_: https://gist.github.com/anonymous/a77f2624f7533853c59c
[07:37:24] _lazarevsky_: ping sevenseacat
[07:37:52] sevenseacat: without you even telling us what the error is? no.
[07:37:55] _lazarevsky_: the error i'm getting -> syntax error, unexpected keyword_end, expecting '}'
[07:38:24] _lazarevsky_: IF NOT CLOSED!
[07:38:39] _lazarevsky_: damn ruby.. :) in coffeescript u dont hafta close the if
[08:02:42] adac: Guys is somehting like that possible? = t('my.text', button: t('my.buttons.text'))
[08:03:54] mikecmpbll: adac: what's that meant to do?
[08:05:23] adac: mikecmpbll, its a text for a description on how to proceed on a form. like "Click the button %{button} to proceed"
[08:07:58] mikecmpbll: don't know much about translations personally, but i don't think theres a way to do that.
[08:08:11] mikecmpbll: oh, other than the way you're doing it
[08:08:16] mikecmpbll: yeah that'll work.
[08:08:25] helpa: http://youtu.be/kfVsfOSbJY0
[08:12:58] mozzarella: kickin' in the front seat
[08:15:12] tbuehlmann: https://www.youtube.com/watch?v=wWLhrHVySgA \o/
[08:15:35] adac: haha such a great song!
[08:17:06] adac: over a 1.3 million downvotes. Today my faith in humans has been restored. thanks mikecmpbll :)
[08:17:28] sevenseacat: and after friday then comessss
[08:17:30] helpa: http://www.youtube.com/watch?v=GVCzdpagXOQ
[08:21:00] mozzarella: why is there always a black guy rapping, in the middle of any pop song
[08:21:25] mikecmpbll: and a santa in the background
[08:21:31] mikecmpbll: every. damn. song. that santa.
[08:21:50] mozzarella: do they have some kind of diversity quota
[08:23:29] mozzarella: holyshit, she's also partying on Saturday
[08:23:41] mozzarella: does she ever take a break?
[08:24:05] mikecmpbll: probably sunday monday tuesday wednesday and thursday.
[08:31:42] Macaveli: Any idea how can update errbit on heroku? I didn't do the setup of this I only have full access to both systems
[08:33:19] sevenseacat: check the errbit docs?
[08:37:57] Macaveli: sevenseacat, I don't get it I have air brake errbit and heroku
[08:38:00] Macaveli: what do I need to update?
[08:38:19] cheeti: hi, in active admin i have moved filter box to the top but the space is not hiding why?
[08:38:46] sevenseacat: Macaveli: what are you trying to do? airbrake and errbit are two tools that do the same thing
[08:38:58] sevenseacat: cheeti: what?
[08:40:35] cheeti: <sevenseacat> how to move filter box to the top in active admin?
[08:40:50] helpa: cheeti: You have not provided enough information to debug your problem. Please provide this information: https://gist.github.com/radar/5384431
[08:40:50] sevenseacat: cheeti: !debug
[08:41:58] Macaveli: sevenseacat, when adding comment on our errbit online I'm receiving an error "At least one recipient (To, Cc or Bcc) is required to send a message" so I want to upgrade errbit to the latest version since this is a known error https://github.com/errbit/errbit/issues/452 but I have no idea how this is possible I only found this in the code: https://gist.github.com/YOUConsulting/302a825a67f7c20c13bf
[08:42:23] Macaveli: Since I didn't do the setup of the error reporting system
[08:43:30] sevenseacat: Macaveli: update your local errbit install, push it to heroku?
[08:44:14] sevenseacat: http://errbit.github.io/errbit/#section-6
[08:44:54] Macaveli: I can't find this gem?
[08:45:03] Macaveli: It's not even in the Gemfile folder
[08:45:17] sevenseacat: its a separate app
[08:45:19] mikecmpbll: errbit runs as a separate app, amirite?
[08:45:31] mikecmpbll: Macaveli: https://github.com/errbit/errbit#upgrading
[08:45:53] mikecmpbll: nvm same as what sevenseacat linked to.
[08:46:01] Macaveli: so where do I have to execute that? I don't have any files of it on my system?
[08:47:15] sevenseacat: so tell that to the person who told you to upgrade it
[08:47:58] mikecmpbll: you'll need the repo and access to the heroku instance ..
[08:51:41] Macaveli: I'll ask him I hope he doesn't charge consultancy hours for it sevenseacat mikecmpbll :/
[08:52:08] rushed: Macaveli: we can???t all work for free~
[08:52:30] Macaveli: he should have supplied the information for free with the code turnover
[08:52:38] sevenseacat: Macaveli: you want him to do a job and dont want to pay him for it?
[08:52:47] sevenseacat: its probably just a clone of the errbit repo
[08:53:04] Macaveli: yeah but where is it stored? Where do i Have to push it to
[08:53:08] Macaveli: i don't know tbh
[08:53:13] rushed: Macaveli: have you checked your Heroku admin panel for another project? :P
[08:53:25] Macaveli: rushed, there is only 1 project in the heroku admin pane
[08:53:29] sevenseacat: you said you had the full heroku details
[08:53:30] mikecmpbll: then it aint on heroku
[08:53:41] mikecmpbll: not on that account anyways.
[08:53:47] Macaveli: it's on heroku
[08:53:59] Macaveli: the url is http://remsis-errbit.herokuapp.com/
[08:54:05] Macaveli: so I think it's on heroku
[08:54:11] dANOKELOFF: When i try to use cap production deploy , they dont asking me to have the password , just Authentification failed for user. I dont know how to fix that
[08:54:21] rushed: Macaveli: https all the things :(
[08:54:54] mikecmpbll: i just made the most insipid cup of tea ever.
[08:54:57] rushed: dANOKELOFF: ~/.ssh/config
[08:55:00] mikecmpbll: one of them days.
[08:55:02] Macaveli: !define insipid
[08:55:25] Macaveli: lacking flavour; weak or tasteless: mugs of insipid coffee.
[08:55:27] workmad3: dANOKELOFF: sounds like openssh on the server only allows key-based auth and you've not got the right keys on your machine
[08:55:34] Macaveli: new word learned
[08:55:49] workmad3: mikecmpbll: it's not insipid, it's just nothing can compare to the joy you have of today being...
[08:55:53] helpa: mikecmpbll: http://youtu.be/kfVsfOSbJY0
[08:55:53] workmad3: mikecmpbll: !friday !!!
[08:56:33] workmad3: ACTION slurps his lovely coffee
[08:56:45] sevenseacat: ACTION drinks her lovely vodka
[08:57:15] workmad3: lovely vodka? isn't that like saying lovely paint stripper?
[08:58:01] sevenseacat: we seem to have this discussion every friday afternoon >_>
[08:58:12] workmad3: it's only morning for me :)
[09:01:52] mikecmpbll: ironic that i work with a SaaS application but 60% of my time is spent supporting some bloody client side software
[09:08:19] wopi: Hi All, How I can disable loading associations in ActiveAdmin on the index page ?
[09:08:34] wopi: https://gist.github.com/astropanic/9bdf4abb31b2e65932ec - here are my setup
[09:12:19] Macaveli: to upgrade an app on heroku
[09:12:26] Macaveli: do I have to usethe heroku toolbelt,
[09:13:10] mikecmpbll: one would assume so.
[09:21:14] workmad3: Macaveli: if by 'upgrade' you mean 'deploy a new version' then no... you just need to push an update to the app's heroku git endpoint
[09:23:15] Haegin_: Morning all. I've got three models, a payslip, a profile (defines defaults for a payslip for a given tax year) and a user (the person that both payslips and profiles relate to). User has_many payslips and profiles but payslip needs to has_one profile through user. How would I do this?
[09:25:06] mikecmpbll: doesn't need to be through user
[09:25:12] workmad3: Haegin_: so a user has many profiles?
[09:25:31] mikecmpbll: payslip belongs_to profile ..
[09:25:35] workmad3: Haegin_: so how would you determine which profile a particular payslip is attached to?
[09:26:10] workmad3: mikecmpbll: hey, I was trying to get him to figure that need out for himself ;)
[09:27:36] Haegin_: workmad3: A user has one profile per tax year, the payslip is in a tax year so it has one profile through user (the one with the matching tax year)
[09:28:08] workmad3: Haegin_: rails 3 or rails 4?
[09:32:05] Haegin_: workmad3: 3.2
[09:32:51] Haegin_: I've just found you can pass a lambda to has_many so I'm trying the same with has_one - will that work?
[09:33:16] Haegin_: mikecmpbll: I don't want to add a profile_id to the payslip table which belongs_to would need wouldn't it?
[09:33:19] workmad3: Haegin_: that's rails 4 ;)
[09:33:27] mikecmpbll: Haegin_: why not?
[09:33:34] sonvu_ae: May I ask one question about Ruby? I just start learning Ruby and have one question but #ruby-lang is down
[09:33:43] mbuf: is there a HAML example to display selected rows based on a drop-down menu?
[09:34:02] mbuf: criteria could be if a hidden field is set to true or false
[09:34:15] hadifarnoud: how can I load dummy data into test database?
[09:34:47] rushed: sonvu_ae: doesn???t look down to me :)
[09:34:51] workmad3: Haegin_: in rails 3.2, you'd use the :conditions option for the association
[09:35:38] sonvu_ae: rushed: I have this "string.each do |wordaa| counts[wordaa] += 1 end counts"
[09:35:39] rushed: mbuf: if you mean client side, that sounds like you want some js
[09:35:54] workmad3: mikecmpbll: if there's a set way to determine the profile, storing the profile_id is somewhat unnecessary and does lead to a data model that can be inconsistent (e.g. someone could store a profile_id for a different user's profile... or a different tax year's profile)
[09:35:57] mbuf: rushed, I see
[09:36:02] sonvu_ae: http://pastebin.com/ME6MDVLc
[09:36:07] workmad3: mikecmpbll: generally small concerns, I'll admit, but some people worry about them :)
[09:36:20] rushed: sonvu_ae: the ruby channels appear to be working fine, you should ask there
[09:37:09] sonvu_ae: ok i will post my problem there, thanks you
[09:37:31] arup_r: What is the difference between Post.where(spam: false).attributes and Post.where(spam: false).serializable_hash ,... I see both are giving Hash... Can anyone explain me ?
[09:39:28] Haegin_: mikecmpbll: several reasons. Firstly because it's not needed, we have everything we need already without adding an extra column. Secondly the payslips table is huge so it'd be a beast to migrate. Thirdly there are payslips that don't have profiles to add an extra dimension of fun to this.
[09:39:33] Haegin_: workmad3: ah ok, thanks
[09:40:50] mikecmpbll: Haegin_: what's the actual point of a profile, in the app?
[09:41:17] Haegin_: mikecmpbll: to define defaults for the tax year that are used by another model (period) to build payslips
[09:42:06] mikecmpbll: just would make sense to me that when you build a payslip to build it from the profile, then, but meh you have all the options, choose your weapon.
[09:44:44] mikecmpbll: or why don't you just use the tax year as the foreign key?
[09:46:39] workmad3: Haegin_: how often is the profile for a payslip accessed btw?
[09:47:40] workmad3: Haegin_: also, do you necessarily need a 'has_one' association for this? could you not instead just create a profile instance method that does 'user.profile.where(tax_year: tax_year)'? :)
[09:48:21] workmad3: Haegin_: or, as an optimisation, 'Profile.where(user_id: user_id, tax_year: tax_year).first' ;)
[09:49:01] mikecmpbll: how's that an optimisation? :p
[09:49:29] arup_r: Any idea on mine ? :)
[09:49:48] mikecmpbll: arup_r: why don't you just look at the source
[09:49:51] Haegin_: workmad3: I've got that instance method already, I'm trying to upgrade to an association so I can use accepts_nested_attributes_for but I'm thinking it might be more effort than it's worth
[09:50:01] workmad3: mikecmpbll: doesn't involve a 2-table lookup if user isn't loaded ;)
[09:50:37] mikecmpbll: workmad3: ah yes.
[09:50:59] mikecmpbll: but you'll be losing referential integrity oh noess
[09:51:11] workmad3: mikecmpbll: err... no you won't :P
[09:51:18] mikecmpbll: you don't know that the user with that ID exists :p
[09:51:30] mikecmpbll: ACTION quits while he's behind
[09:52:00] workmad3: mikecmpbll: if it's a proper foreign key to the users table in the payslip then yes you do ;)
[09:52:16] workmad3: mikecmpbll: and if it's not, you have the same level of referential integrity as with going through the user ;)
[09:52:57] workmad3: mikecmpbll: in either case, the profile may not exist... which is a valid result from what Haegin has said :)
[09:53:05] Haegin: argh, conditions on a has_one are evaluated at the class scope, not the instance scope so the tax_year of the payslip is unavailable. darnit.
[09:53:59] workmad3: Haegin: you could always implement 'profile_attributes' and 'profile_attributes=' yourself you know ;)
[09:54:22] mikecmpbll: Haegin: you can pass a proc to the conditions option
[09:54:34] mikecmpbll: google it i can't remember the syntax.
[09:56:56] mikecmpbll: workmad3: i was getting it mixed up with joins, there's no join there meh. told you that tea was insipid
[09:57:09] arup_r: mikecmpbll: I was asking definition type answer... But its ok let it be..
[09:58:20] mikecmpbll: arup_r: it was an exercise for you ;)
[09:58:31] mikecmpbll: the source code isn't particularly complicated and it shows the interplay between the two methods you mentioned.
[09:58:57] arup_r: mikecmpbll: It seems you do know the difference well.. right ? ;)
[10:00:40] Haegin: workmad3: yeah, I'm thinking I might just do that instead
[10:00:49] arup_r: mikecmpbll: Very good
[10:00:56] arup_r: mikecmpbll: :-)
[10:01:28] workmad3: arup_r: it's good practice for you to go and figure things out from the source though ;)
[10:02:43] maodun: foo = users(:foo), when I use fixtures like this, my validations for my User model are run, can I avoid this?
[10:03:21] maodun: like a "build" equivalent instead of "create", which is what it seems to be doing?
[10:03:39] maodun: I know FactoryGirl exists and has such a distinction, but I was hoping to keep it simpler
[10:03:52] mikecmpbll: validations aren't run on fixtures?
[10:04:06] mikecmpbll: i didn't think so anyway
[10:05:12] maodun: hmm, I'm getting an SQLite3::ConstraintException about bar_id may not be NULL
[10:05:24] mikecmpbll: oh. that's a DB constraint
[10:05:28] mikecmpbll: nothing to do with rails.
[10:05:33] maodun: yeah, I didnt notice that initially
[10:05:38] mikecmpbll: the clue being SQLite3::ConstraintException :p
[10:08:09] maodun: I'm a little confused how my db/schema.rb got set up with null: false, but I've fixed it now. Thanks
[10:10:58] arup_r: workmad3: I do.. sometime I am lazy... too many work.. so i asked here if someone already explored it or not.. :-)
[10:12:35] banisterfiend: how do i add a capistrano hook so that it runs a local command before deployment? (i want to ensure that the local branch has been pushed to the remote)
[10:14:20] mikecmpbll: banisterfiend: https://github.com/capistrano/capistrano/blob/master/README.md#running-local-tasks ?
[10:15:16] banisterfiend: mikecmpbll thanks :) but how would i define the hook, i mean what would i hook and how? and how would i determinate the deployment if the local task "fails" for example?
[10:17:14] mikecmpbll: i guess you just use the before/after hooks ..
[10:17:24] mikecmpbll: and raise an error to terminate
[10:18:09] workmad3: banisterfiend: I'd guess you'd hook the deploy:update_code task
[10:18:17] puppeh: does a signed cookie also implies that it is base64 encoded?
[10:18:26] puppeh: and also, what about encrypted cookies? are they base64 encoded too?
[10:18:37] workmad3: banisterfiend: and insert your task before that one
[10:19:49] mikecmpbll: banisterfiend: which cap version?
[10:20:00] mikecmpbll: don't think 3 has that task
[10:20:21] workmad3: puppeh: that sounds like implementation details of the headers
[10:20:27] workmad3: puppeh: not something you should assume ;)
[10:21:48] banisterfiend: mikecmpbll 2.1.5
[10:21:58] banisterfiend: mikecmpbll sorry, 2.15.5
[10:22:01] mikecmpbll: ah ok. then look at the cap 2 task flow
[10:22:20] workmad3: mikecmpbll: ah yeah... I've not looked at cap 3 yet... seems cap 3 has git:create_release
[10:22:37] workmad3: mikecmpbll: although I suspect in cap 3 you'd want to hook in at the start of deploy:updating
[10:23:16] workmad3: banisterfiend: as for how to hook... 'before "deploy:update_code", "banister:update_remote_locally" '
[10:23:29] workmad3: banisterfiend: and then you just define your namespace and task ;)
[10:23:58] banisterfiend: workmad3 thanks, and to stop the deployment, i just "raise" ?
[10:24:32] workmad3: banisterfiend: think so
[10:25:58] michael_mbp: guys anyone familiar with Promotions in Spree?
[10:26:08] michael_mbp: ACTION feels like alice.
[10:26:33] banisterfiend: workmad3 btw can you think of a more efficient way of doing this? Enrollment.includes(:grade).where(instance_id: instances.pluck(:id)) where instances is a relation that's a result of this: instances = Instance.ends_between start, end
[10:26:40] workmad3: mikecmpbll: I suspect Radar is asleep or not around atm...
[10:27:55] mikecmpbll: s/pluck(:id)//
[10:28:12] workmad3: banisterfiend: it's uglier, but if Instance.ends_between is a scope, you can do 'Enrollment.includes(:grade).where("instance_id IN (#{Instance.ends_between(start, end).to_sql})")
[10:28:42] workmad3: mikecmpbll: that works in rails 4... I happen to know banisterfiend is on rails 3 :)
[10:29:03] mikecmpbll: insider info
[10:30:10] workmad3: banisterfiend: oh... you may need to tack a '.select("id")' onto your scope too
[10:32:24] banisterfiend: workmad3 thanks
[10:34:02] michael_mbp: where Radar when you need him :)
[10:34:28] workmad3: michael_mbp: sleeping? :)
[10:34:42] michael_mbp: Hero's don't sleep :p
[10:34:53] banisterfiend: workmad3 i arel-a-fied it with: Enrollment.includes(:assessment).where(Enrollment.arel_table[:instance_id].in(Instance.ends_between(DateTime.current, DateTime.current + 10.days).pluck(:id)))
[10:35:02] banisterfiend: workmad3 but not sure if that's efficient?
[10:35:05] workmad3: banisterfiend: don't do the .pluck
[10:35:22] michael_mbp: workmad3: run into bit of a nightmare with Spree
[10:35:35] workmad3: banisterfiend: that will end up as 2 queries, while the version I showed does a sub-select in a single query ;)
[10:35:48] banisterfiend: workmad3 hmm, is there a way to write your one with arel?
[10:35:59] workmad3: banisterfiend: I think you did... just drop the pluck ;)
[10:36:07] banisterfiend: workmad3 when i drop the puck it braeks
[10:36:13] banisterfiend: i'll show the error
[10:36:25] mikecmpbll: probably because you need the select too
[10:36:27] banisterfiend: TypeError: Cannot visit ActiveRecord::Relation
[10:37:01] workmad3: ah, yeah... ActiveRecord::Relation can handle ARel stuff, but ARel can't do anything with an ActiveRecord::Relation
[10:37:21] workmad3: you'd need to convert your scope into ARel somehow
[10:38:04] banisterfiend: workmad3 if i convert it to arel will it still work as a normal scope?
[10:38:16] workmad3: probably not
[10:38:48] workmad3: but if you had an arel version, you should be able to wrap it into an ActiveRecord::Relation with a .where in a scope ;)
[10:39:32] maodun: I'm still having fixtures issues. I'm using labels to set up associations between my fixtures, but the when I test the association in rspec, the association comes up nil: "user.name" is fine, but "user.address.zipcode" isn't.
[10:39:53] maodun: does fixtures support this type of reference? I see that user's address_id has been set
[10:40:14] maodun: I just can't figure out why address is returning as nil
[10:41:03] Haegin: thanks for the help earlier mikecmpbll and workmad3. I ended up just posting the params for the profile separate to the payslip and having the controller handle it in this case.
[10:59:12] michael_mbp: ha Radar is awake, he just replied my tweet!
[10:59:32] mikecmpbll: he sleep tweets.
[10:59:41] michael_mbp: he's awesome.
[11:00:29] mikecmpbll: technically known as somnamtweetism
[11:04:16] vasilakisfil: hi! I am trying to impement URI templates in rails through rails' route helpers but helpers escape '{' and '}'.. for instance when I do api_v1_player_path(id: '{:id}') I get "/api/players/%7B:id%7D"
[11:04:32] vasilakisfil: is that how supposed to be ? I can always unescape them using CGI.unescape
[11:04:46] vasilakisfil: but I don't know why it doesn't feel right
[11:07:02] mikecmpbll: you can't have { and } in a URL
[11:07:33] selvait90: I have upgraded rails 2.3.5 to 2.3.6
[11:07:44] vasilakisfil: aha ok then it makes sense
[11:07:47] selvait90: and got an error on loading page
[11:07:50] selvait90: https://github.com/haml/haml/issues/178
[11:08:14] selvait90: Can anyone help to apply this fix
[11:10:41] mikecmpbll: selvait90: probably easiest to roll back haml to that version
[11:10:50] selvait90: http://pastebin.com/qHDFjUUe
[11:11:58] mikecmpbll: selvait90: what haml version are you on?
[11:12:00] selvait90: mikecmpbll: $ haml -v
[11:12:11] mikecmpbll: upgrade to haml 3 then i guess
[11:12:28] selvait90: mikecmpbll: thanks, let me try
[11:12:45] mikecmpbll: deepj commented on May 23, 2010: No fix for Haml 2.2.x?
[11:12:46] mikecmpbll: nex3 commented on May 23, 2010: No. I only maintain a single stable version of Haml at a time; currently, that's 3.0.x.
[11:29:28] selvait90: mikecmpbll: i have upgraded the haml to 3.0.0 and then 3.0.25
[11:29:35] selvait90: but still getting same error
[11:30:44] mikecmpbll: looks like the fix was introduced in 3.0.5
[11:30:54] mikecmpbll: or possibly 3.0.6
[11:31:51] selvait90: how are you checking that, it might me helpful for me to check in future
[11:31:55] mozzarella: it's possible for a singular resource to have a singular path OR plural path?
[11:32:23] mozzarella: resource :session => /session/new, resource :sessions => /sessions/new
[11:33:24] selvait90: mine is like
[11:33:25] selvait90: app/views/user_sessions/new.html.haml where line #7 raised:
[11:33:30] selvait90: NoMethodError in User_sessions#new
[11:34:05] greengriminal: Is it possible to set a on-behalf-of header in an email?
[11:34:39] hadifarnoud: how can I load dummy data into test database?
[11:34:51] rushed: hadifarnoud: factorygirl is one option
[11:35:17] hadifarnoud: rushed: can I somehow do it during migration of test database?
[11:35:33] rushed: hadifarnoud: you probably don???t want to
[11:35:36] mikecmpbll: selvait90: the date of the issue is may 23rd 2010, and i'm looking at the version release dates
[11:35:37] mikecmpbll: http://rubygems.org/gems/haml/versions
[11:35:41] selvait90: mikecmpbll: now I am loading haml 3.0.7
[11:36:00] wasamasa: can't google remove all rubyforge search results
[11:36:03] wasamasa: and ddg, too
[11:36:04] hadifarnoud: why not rushed? that way everyone is using same db for testing
[11:36:10] hadifarnoud: I mean same data
[11:36:19] rushed: selvait90: do you have an adversion to using the latest version of something? :)
[11:37:02] wasamasa: and rubygems not link to rubyforge, too?
[11:37:11] rushed: hadifarnoud: habit? preference? with factories the data the tests expect is right there with the tests
[11:37:51] mikecmpbll: hadifarnoud: fixtures...
[11:38:18] selvait90: rushed: yes, our application is running at 2.3.5
[11:38:33] selvait90: we are trying to take it to 2.3.18
[11:38:43] hadifarnoud: mikecmpbll: thanks. that looks easy enough for me
[11:39:00] helpa: hadifarnoud: For a list of the most common testing framework gems used with Ruby and, by extension, the Rails framework see: https://www.ruby-toolbox.com/categories/testing_frameworks
[11:39:00] mikecmpbll: hadifarnoud: !testing
[11:39:06] mikecmpbll: eh that wasn't what i wanted
[11:39:22] hadifarnoud: I know, right
[11:39:31] mikecmpbll: http://guides.rubyonrails.org/testing.html
[11:46:02] jankees: Hey guys, question.
[11:46:16] jankees: A friend of mine wants to start with Rails, what's the best book nowadays?
[11:46:31] jankees: What's a good book, maybe that's a better question :)
[11:48:48] w0bni: jankees: I went with two books - first "Beginning Ruby, from Novice to Professional" and then "Beginning Rails 4"
[11:48:55] w0bni: how much programming experience does he have already?
[11:49:14] w0bni: I ended up skimming through a lot of "obvious" stuff, so went through both books in a couple of days
[11:50:39] mikecmpbll: or don't use a book at all.
[11:52:09] newb: i did tryruby.org
[11:52:15] newb: and then rails for zombies
[11:52:29] w0bni: I started out with rails for zombies, but didn't really feel like I learned a lot
[11:52:30] newb: and then that was pretty good baseline and then i jsut researched specific stuff as i needed it
[11:52:46] mikecmpbll: i started with api.rubyonrails.org
[11:52:48] newb: admittedly this was some years ago now
[11:52:53] newb: and i think its moved on quite a bit
[11:52:55] mikecmpbll: and it's what i still use.
[11:53:10] w0bni: mikecmpbll: did you have some MVC experience beforehand?
[11:53:23] puppeh_: when I do cookies[:a] = "b" and cookies[:c] = "d", are "a" and "c" separate cookies?
[11:53:27] egrouse: id say its fairly easy to pick up MVC
[11:53:30] egrouse: once you understand why its done
[11:53:33] egrouse: it makes sense
[11:54:55] mikecmpbll: seriously though, the whole internet is at your mercy, there's every possible scenario that you might encounter described in some blog post or another with 5 different ways.
[11:55:13] mikecmpbll: don't understand why beginners buy books.
[11:55:56] mikecmpbll: books for specific topics, or complicated high level stuff, sure, but you won't need that until you're well in to rails development.
[11:56:37] codepodu: puppeh_: yes
[11:57:07] puppeh_: I don't understand, then why when I do then request.headers['Cookie'] it's just one string with all these separate cookies?
[11:57:52] puppeh_: and the HTTP header Cookie states: an HTTP cookie previously sent by the server with Set-Cookie (below)
[11:57:58] puppeh_: it doesn't talk about "mutliple" cookies
[12:01:29] puppeh_: so what I see in the chrome developer tools (Cookies panel) are separate cookies from the same domain?
[12:01:53] puppeh_: for ex. I see different expire dates and sizes on these Name/Value columns of the developer tools..
[12:06:45] jankees: A few years ago I started with Agile Webdevelopment with Rails
[12:06:55] jankees: But I don't know if there is better stuff nowadays
[12:08:31] puppeh_: so if they are different cookies ("a" and "b") then each one of them can be up to 4KB, right?
[12:10:52] workmad3: puppeh_: don't think so
[12:11:33] puppeh_: yeah me neither, I guess they are sent as one entity in the broswer through the 'Cookie' HTTP header which itself can be max 4kb
[12:11:46] puppeh_: http://stackoverflow.com/a/4604212/1242778
[12:11:49] workmad3: puppeh_: I was wondering that... it's browser dependent
[12:12:02] puppeh_: yeah that too, but the specification states 4kb
[12:12:04] workmad3: puppeh_: some browsers have a max size per domain constraint on top of the max cook size
[12:13:20] workmad3: puppeh_: the cookie limit isn't browser dependent though (although some browsers have slightly different overheads per cookie) :)
[12:13:47] workmad3: puppeh_: so 4k per cookie... but you may hit a browser max-size for the domain of 4k, or a browser max number of cookies...
[12:14:19] workmad3: puppeh_: http://browsercookielimits.x64.me/ seems to have found a good number of limits
[12:14:38] puppeh_: what I need to understand first is that when you do cookies[:a] and cookies[:b] on Rails that's 2 different cookies, right? but why there is one single HTTP header (ie. request.headers['Cookie']) if they are separate cookies?
[12:15:14] workmad3: puppeh_: by any chance is it an array? ;)
[12:23:38] nettoweb: guys, is there a way to check if an object can be destroyed? I just want to know if it dont have any associate objects to tell the end user
[12:24:46] nettoweb: I know I can do if user.destroy but if return true, my object will be destroyed, I just want to show this information
[12:27:37] puppeh_: workmad3: no it's a string of all the cookie values concatenated
[12:27:47] puppeh_: workmad3: in this case it looks like "a=b c=d" etc
[12:36:24] comma8: I'm setting up capistrano for deployment. It's the second project I've done this for, and it is going a lot faster and easier than the first time... but raspberries and potatoes it's still quite a pain in the green bean
[12:36:32] comma8: (all swears replaced with Food.random)
[12:37:52] mikecmpbll: heh. what the fuck.
[12:38:16] tagrudev: 2 hours to beer o'clock
[12:38:35] mikecmpbll: 3 for me -_-
[12:46:48] selvait90: mikecmpbll: I ended up upgrade rails to 2.3.8 to solve "undefined method `safe_concat' in form_tag on Rails 2.3.6" - https://github.com/haml/haml/issues/178
[12:46:59] mikecmpbll: selvait90: okay :)
[12:47:06] selvait90: thanks for your help :)
[12:47:31] mikecmpbll: no probs. you might want to think about upgrading rails a lot more than that
[12:47:39] mikecmpbll: we're at 4.1.4 now.
[12:47:59] clocKwize: does rails 2 still get security updates?
[12:48:31] mikecmpbll: think it stopped after rails 4 was released
[12:48:36] mikecmpbll: they do two major versions iirc.
[12:49:58] hadifarnoud: I get app error: Missing `secret_key_base` for 'production' environment, but I did set it with heroku config:set SECRET_KEY_BASE=[secret]
[12:50:32] vasilakisfil: has anyone worked with hal on APIs before ?
[12:51:08] rushed: hadifarnoud: heroku config just sets the env variable, you still have to pull it in
[12:51:30] elaptics: clocKwize: you prob want railslts.com
[12:52:01] hadifarnoud: I think I am rushed. this is in my secrets.yml secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
[12:53:06] clocKwize: elaptics: hadn't seen that before .. I wasn't really asking for me though, was just wondering considering selvait90 asked about 2.3.8
[12:53:24] elaptics: clocKwize: just realised that, was about to mention selvait90 :)
[12:53:58] elaptics: they release for free to the community after 10 days so worth doing that at least
[12:54:11] elaptics: they also support rails 3 too now
[12:54:39] selvait90: mikecmpbll: agree with you. we are on process of upgrading to 2.3.18 first
[12:54:50] selvait90: from there we are going to move forward
[12:54:52] mikecmpbll: that seems like a ridiculously small step
[12:54:59] mikecmpbll: but i'm sure you have your reasons :d
[12:55:28] rushed: billable hours? :P
[12:55:56] selvait90: Yes, Our app is very big and it had customised gems. so trying to incorporate those changes as well
[12:57:49] selvait90: it works good in first step to 2.3.8, now I will do long jumps
[12:58:39] clocKwize: selvait90: going for 2 to 3 will be biggest step.. then to 4 shouldn't be bad ;p
[12:58:42] mikecmpbll: you won't get any breaking changes in the minor versions
[12:58:49] mikecmpbll: so there's no point doing those upgrades as steps.
[12:59:27] elaptics: mikecmpbll: you might because some of those were the security ones with yaml, etc
[12:59:29] mikecmpbll: 3 to 4 is mainly a pain in the arse because of strong params
[12:59:37] mikecmpbll: elaptics: ah okay.
[13:00:10] elaptics: those upgrades are always ones where you wish you had better test coverage :)
[13:00:54] selvait90: from now I will check with http://railsdiff.org/
[13:01:14] elaptics: oh, that looks like a handy site
[13:01:18] elaptics: didn't know about that before
[13:01:30] mikecmpbll: i saw that a while ago then was looking for it recently and couldn't remember what it was called
[13:01:34] mikecmpbll: bookmarked this time ;D
[13:02:12] selvait90: thanks guys for big support
[13:05:19] pontiki: man what a useful site!
[13:13:50] wasamasa: I'd need such a thing for emacs development
[13:13:55] wasamasa: ACTION bookmarks
[13:15:34] skroon: when nesting Sass do I *have* to specify all the elemnts in between, or is there a way to have a wildard? e.g. <div class="a"> <div class="b"> <div class="c"> </div> </div> </div> can I do something like: .a { *.c { background-color: #f00; } }
[13:16:16] hadifarnoud: I get this on heroku -> app error: Missing `secret_key_base` for 'production' environment, but I did set it with heroku config:set SECRET_KEY_BASE=[secret]
[13:17:39] hadifarnoud: I've done heroku config:push too
[13:20:24] michael_mbp: guys, is there a quick way to go through files in an app renaming everything? something along the lines of ag/sed/piping for ex. to rename 'fancy_namespace' to whatever I want in ./app/views/refinery/fancy_namespace/admin/fancy_namespace/edit.html.erb
[13:28:24] comma8: michael_mbp, if you mean renaming the files themselves, I use a tool called "perl-rename"
[13:29:04] michael_mbp: perl script or?
[13:31:26] comma8: yes, it's a perl script. I think this is the homepage: http://search.cpan.org/~pederst/rename/
[13:31:53] comma8: I installed it for arch linux from the AUR, and it just worked.
[13:41:03] kiddorails: Hey guys! I'm writing controller spec. Stuck in some situation - https://gist.github.com/anonymous/90e7f6f978ebcc8c30a3
[13:41:09] kiddorails: Can anybody please help me out with this? :)
[13:44:18] mikecmpbll: http://pattle.github.io/simpsons-in-css/
[13:47:45] codepodu: kiddorails: controller.instance_variable_get('@user').stub(:paid?).and_return(true)
[13:48:09] codepodu: your controller doesn't have access to the test's @user variable
[13:48:16] codepodu: im guessing that's what you want to do
[13:49:17] kiddorails: codepodu: but @user is not an instance variable of that controller
[13:49:40] codepodu: ah, wrong guess, then.
[13:49:46] codepodu: the reason your code doesn't work is
[13:49:53] mikecmpbll: kiddorails: i don't understand the problem.
[13:50:00] codepodu: your controller has no access to the @user in the test
[13:50:25] codepodu: you stubbing out that object's properties has no effect on the user object used by the controller
[13:50:29] mikecmpbll: what is @user ? and what is .paid?() ?
[13:50:31] kiddorails: codepodu: but, controller action retrieves that particular object by say User.find(1) and checked paid? on it
[13:50:32] tagrudev: http://d3dsacqprgcsqh.cloudfront.net/photo/a3YVDvQ_460s.jpg
[13:50:41] codepodu: kiddorails: common misunderstanding
[13:51:09] codepodu: kiddorails: your controller retrieves *a* particular instance of the user object, not THE particular instance that you stubbed out
[13:51:23] kiddorails: but @user in the spec is the same object as the object retrieved in that controller action. how can it be different in behavior? ::confused::
[13:51:33] codepodu: kiddorails: it never is :)
[13:51:44] kiddorails: ah. codepodu
[13:51:51] kiddorails: so, how do I approach a problem like this?
[13:51:59] mikecmpbll: this is why i use fixtures.
[13:52:23] kiddorails: mikecmpbll: yes, I agree.
[13:52:37] codepodu: kiddorails: put the code to retrieve your user object in a method in the controller. stub that method out and return the user object you created in the test
[13:52:58] codepodu: or use a fixture, like mikecmpbll says
[13:52:59] kiddorails: mikecmpbll: I am working on a this codebase (which is not mine). I am gradually improving the tests coverage. Using factories, but coverage is still less.
[13:55:02] kiddorails: codepodu: hmm.
[13:55:23] kiddorails: codepodu: mikecmpbll : Thanks. Checking what is the shortest solution for now :)
[13:55:51] mikecmpbll: i still don't really understand what the problem is, but my testing-fu is weak
[13:56:48] kiddorails: mikecmpbll: the problem is, I have this @user object in my spec. By default, @user.paid? gives false. I stubbed that in my spec to give true.
[13:57:05] mikecmpbll: is that the should_receive? stuff?
[13:57:13] kiddorails: mikecmpbll: @user.should_receive(:paid?).at_least(1).times.and_return(true)
[13:57:21] mikecmpbll: ah okay, don't use rspec or stubs or anything
[13:57:25] kiddorails: in the spec itself.
[13:57:26] mikecmpbll: didn't know what that meant.
[14:00:37] gavit: anyone know a datagrid like gem where you can "add rows" for input rather than "output" (i.e.https://github.com/bogdan/datagrid). Think of something like a TODO list for a project (who, what, when) or a sales order (qty, item, price)
[14:13:09] rushed: gavit: you might find an example useful http://railscasts.com/episodes/196-nested-model-form-revised
[14:14:30] vasilakisfil: do you think for a simple api oauth2 is overkill ?
[14:23:08] workmad3: vasilakisfil: yes, just use oauth1 unless you have a specific reason for oauth2 (and probably about a decade of experience of securing enterprise APIs)
[14:23:49] workmad3: vasilakisfil: oauth2 suffers from the big problem of being non-obviously not-secure by default ;)
[14:27:08] vasilakisfil: I think I will go with simple token-based authentication for now
[14:27:19] vasilakisfil: thanks for the info though
[14:50:50] apeiros_: ok, so protected_attributes fucks me over once again??? we have shared code in rails 3.2 and rails 4.1. The rails 4.1 project uses the protected_attributes gem so the old models still work. now 4.1 removed find_or_create_by_* and replaced it with find_or_create_by. the latter however does not pass on without_protection. any idea how to go about this?
[14:50:55] banisterfiend: yo, AR question: Enrollment has_many enrollment_statuses , how do i grab all enrollments that have at least one of their enrollment statuses 'name' column set to 'attended' ?
[14:52:58] mikecmpbll: banisterfiend: Enrollment.joins(:enrollment_statuses).where(enrollment_statuses: { name: 'attended' }).uniq
[14:53:29] arup_r: mikecmpbll: You are so fast.. :-)
[14:54:03] banisterfiend: mikecmpbll thanks
[14:55:31] mikecmpbll: apeiros_: not sure i quite understand?
[14:55:51] apeiros_: mikecmpbll: which part should I elaborate?
[14:55:56] mikecmpbll: sec, let me re-read.
[14:56:02] mikecmpbll: friday afternoon fuzzy brain
[14:56:05] arup_r: crankharder: To whom you are saying ?
[14:56:28] apeiros: Rails 3.2: Foo.find_or_create_by_a_and_b(1, 2) # works fine, without accessible attributes
[14:56:46] apeiros: Rails 4.1: Foo.find_or_create_by(a: 1, b: 2) # fails, because attrs not accessible
[14:57:12] apeiros: Rails 4.1: Foo.find_or_create_by({a: 1, b: 2}, without_protection: true) # fails, because find_or_create_by does not expect nor pass on the `without_attributes` arg
[14:57:50] apeiros: and we need protected_attributes for the moment until we can move all code which depends on shared code to rails 4.1
[14:59:48] mikecmpbll: you could use the deprecated finders gem in the rails 4.1 app? :/ meh i dunno
[14:59:57] mikecmpbll: or make the attributes accessible
[15:01:32] apeiros: that's what I currently do. I have an if Rails::VERSION::MAJOR in the code anyway since there's no version working in both
[15:01:41] apeiros: and now I have attr_accessible in the >3 branch
[15:02:06] apeiros: (since there we don't really use attr_accessible - only for compat)
[15:04:32] mikecmpbll: sounds like a mess :D
[15:12:20] apeiros: mikecmpbll: totally is
[15:12:25] apeiros: I hate this situation
[15:12:44] ecnalyr: I've got a potential client who wants to have an application/website, a directory (think local phonebook), that references 1-page 'websites' that have their own domain for every business in the directory (clients that pay a monthly fee to be listed in the directory / have a 'website' ). I suggested having a (standard) rails application be the primary directory app and have it reference individual business-card-likewebsi
[15:12:45] ecnalyr: tes that we set up for each business. The client scoffed at this idea and insists everything be in one place and said 'a centralized php website would be best' (while simultaneously stating he doesn't know much about programming / web development. . . rolls eyes). What I'm here to ask about is this: Is it reasonable to set up a Rails application and have individual 'website' models (that display a view with the busines
[15:12:45] ecnalyr: s' information in one of X different ways) that are pointed to by their own domain? If I could tell the client, "I'm going to build you a central directory that has all the client's websites visible from different domains," he wouldn't care if it's from one rails app all hosted on one server/stack. I've never pointed to 'another domain' while that domain is used locally on the same server/stack so I don't understand th
[15:12:46] ecnalyr: e logistics of it. (it smells like it'd be exceptionally simple, but I thought I'd check here)
[15:13:01] ecnalyr: Holy crap that's long
[15:13:10] ecnalyr: (was one line here)
[15:15:09] mikecmpbll: ecnalyr: just point the domains to the app, and you can route on them
[15:18:54] ecnalyr: mikecampbll - is it really that simple? I pictured there being some 'gotchas' with getting the app to display, say, myapp.com/website/1 as an entirely separate domain rapidly, e.g. joescrabshack.com
[15:19:16] ecnalyr: ignore the word rapidly.
[15:19:23] mikecmpbll: it's not something i've seen/done before but my guess is it wouldn't be aprticularly difficult
[15:19:45] mikecmpbll: you'd point all the domains at the app, have a root route with a domain constraint for myapp.com
[15:20:11] mikecmpbll: and a root route without the constraint to catch all the rest to website#show or something
[15:20:18] mikecmpbll: and then inspect the request host in the controller
[15:20:45] mikecmpbll: there may be a better way but that's off the top of my head and it should work
[15:22:05] ecnalyr: That makes a lot of sense.
[15:22:13] ecnalyr: And is similar to what I was thinking - thanks for your input.
[15:22:23] ecnalyr: (as always)
[15:43:04] stepfresh: when defining class methods in a module the convention seems to be to use the splat for the arguments (such as only: [:show]) instead of defining the arguments explicitly, why is that?
[15:43:58] mikecmpbll: stepfresh: have you got an example? i don't know what you mean
[15:44:46] mikecmpbll: your example just looks like a named parameter, or a hash parameter.
[15:44:57] stepfresh: https://github.com/ryanb/cancan/blob/master/lib/cancan/controller_additions.rb#L14
[15:45:01] dda: stepfresh: I don't think it's a convention as it's just a way to make it more flexible towards customization of the options.
[15:45:34] stepfresh: or https://github.com/doorkeeper-gem/doorkeeper/blob/master/lib/doorkeeper/helpers/filter.rb#L5
[15:46:03] stepfresh: dda: but they seem to then reference args[0] and args[1] which seems decidedly inflexible
[15:46:45] mikecmpbll: it allows you to receive any number of arguments
[15:47:37] mikecmpbll: both those examples there it receives the arbitrary arguments and passes them on
[15:47:48] mikecmpbll: frankly it doesn't care to define what they all are.
[15:47:52] stepfresh: no i understand the point of the splat, just not why its used over say, (method, filter_options, *args)
[15:48:14] stepfresh: as the order of those arguments are fixed elsewhere in the code
[15:48:26] mikecmpbll: i can't see that in either of those examples
[15:48:47] stepfresh: https://github.com/doorkeeper-gem/doorkeeper/blob/5f92eeb1015023b9eecc3b9954f23201788d9135/lib/doorkeeper/doorkeeper_for.rb#L61
[15:50:21] dda: stepfresh: It's in the way Ruby < 2 interprets the arguments. With keyword arguments that's kinda obsolete, I think.
[15:50:56] stepfresh: dda: that makes sense
[15:50:58] mikecmpbll: stepfresh: as opposed to this? https://gist.github.com/gists
[15:51:03] mikecmpbll: https://gist.github.com/mikecmpbll/1b0dcca88b99a6cce6f2 *
[15:51:13] dda: It's better to check if the method was called with args+options as a Hash for code that runs on Ruby 1.8 or 1.9
[15:51:28] stepfresh: exactly mikecmpbll
[15:51:44] mikecmpbll: stepfresh: no reason at all, authors preference i guess
[15:52:01] stepfresh: good to know, thanks both!
[16:03:05] centrx: Wow this is so cool
[16:10:49] stef1a: i am getting an undefined_method _path error in a form_for building a nested resource: https://gist.github.com/smlance/7ec08ccabe8a1eb458c5
[16:12:51] rsl: stef1a: yr routes please?
[16:14:29] stef1a: rsl: https://gist.github.com/smlance/7ec08ccabe8a1eb458c5
[16:15:08] rsl: stef1a: that's a nested resource. you have to pass both resources: form_for [@project, @submission]
[16:16:35] stef1a: rsl: that gives me the same error
[16:16:53] rsl: make sure @project is... a project and not nil
[16:17:54] stef1a: rsl: got it; thanks! had to define @project in submissions_controller
[16:18:15] stef1a: i don't understand why rails gives a routing error, though
[16:23:43] rhizome: because it's going to POST to a route based on the form object passed
[16:25:07] rsl: stef1a: because it can't generate a polymorphic url from nil [or with nil as part]
[16:26:19] stef1a: rhizome: and the submissions route happens to lie nested within the projects path?
[16:26:48] stef1a: rsl: i don't quite understand that explanation, particularly the polymorphic url and nil... what would be nil?
[16:27:04] rsl: stef1a: any instance variable not assigned a value is nil
[16:27:26] rsl: open up irb and see what @any_random_name is
[16:27:41] rsl: vs what the local variable any_random_name does
[16:28:27] stef1a: nil vs NameError
[16:29:20] rhizome: stef1a: the route is constructed from the "X" in "form_for X"
[16:31:34] stef1a: rhizome: okay, i see. thanks.
[16:32:10] rsl: stef1a: so when you pass a nil value to form_for it's not gonna know how to correctly generate the path
[16:39:45] atmosx: I'm trying to migrate a project from a server using psql to another
[16:40:08] atmosx: but have troubles with psql not finding some tables...
[16:40:30] atmosx: I tried to run the migrations using: bundle exec rake db:create:all
[16:40:33] atmosx: is there anything else?
[16:43:28] rhizome: atmosx: you still have to migrate after db:create:all
[16:44:50] norm: i know i've solved this problem before, in rails 3, how can i suppress bogus routing messages like ActionController::RoutingError (No route matches [GET] "/crossdomain.xml"):
[16:45:54] slash_nick: what's bogus about it?
[16:46:47] rhizome: maybe spurious spider errors
[16:47:29] rhizome: you can do a catchall route that just points to your front page or something
[16:49:53] centrx: Best web server to use for tiny app with three users?
[16:50:52] rsl: webrick
[16:51:19] rhizome: i use apache & passenger for everything, no matter the size, but i'm starting to think about fronting it with nginx.
[16:51:35] rhizome: is thin still a thing? that will at least be picked up automatically by rails s
[16:52:42] atmosx: rhizome: did it, works. thanks
[16:52:58] rhizome: you're welcome
[17:00:12] centrx: rsl, Is webrick safe to put on a publicly accessible IP address?
[17:05:23] rsl: centrx: far as i know. seems like it would be silly for them to make a server that isn't safe to access.
[17:06:30] bricker`work: httparty is fine but damn that class-level "base_uri"... that's a problem just waiting to happen
[17:06:52] centrx: rsl, Is webrick used for anything other than local development with Rails?
[17:07:29] rsl: centrx: it was not written to be a rails development tool if that's what you're asking
[17:07:49] rsl: i cannot speak to what "everyone" uses it for
[17:07:59] rsl: but it was written as a real, lightweight server
[17:08:56] centrx: Okay, cool, I'll start with that
[17:13:01] rsl: centrx: no problem
[17:32:36] axilla: afternoon all, how can I get a form check_box and a form label to be aligned horizonally?
[17:35:30] rsl: axilla: play with css line-height and vertical-align
[17:40:50] andrew9183: use bootstrap
[17:46:21] andrew9183: what does included do in a model
[17:47:08] tubbo: y'all bishes
[17:49:16] antivert: happy friday sucka
[17:50:20] crankharder: andrew9183: dont think 'included' is a thing
[17:50:31] hfp: Hey all, I'm getting a hard time with my seeds file. It complains that I am trying to use non US-ASCII characters. I tried the env vars to UTF8 trick, the file encoding to no avail. I eventually narrowed it down to one hash tha I am committing as part of an array to my database. But I can't see where are the alleged non UTF-8 characters in that particular hash? If I remove it from the array, everything goes fine. Hash in questio
[17:50:31] hfp: n: https://gist.github.com/Coaxial/cd94bb44d22345886dad
[17:51:11] mikecmpbll: hfp: code and error please ...
[17:55:59] axilla: rsl: the answer was to put it into a do loop to do it the rails way
[17:56:05] hfp: code + error: https://gist.github.com/Coaxial/fb598ed13f9458550092
[17:56:13] axilla: f.label do %> blah blah
[17:56:17] hfp: The problematic record is the Mckibbins Irish Pub
[17:56:22] rsl: uhhhh no. that's not the actual answer.
[17:56:34] rsl: since form elements styling varies from browser to browser.
[17:56:37] hfp: mikecmpbll ^
[17:56:54] rsl: uniformly having things aligned requires css
[18:02:38] universa1: hfp: do other rake tasks work? because in your trace there???s no single mention of your seeds.rb
[18:03:03] hfp: Yes, if I comment out the Mckibbins hash entry, the rakefile executes fine
[18:03:11] universa1: hfp: and your seeds.rb file probably wants: # encoding: utf8 at the top ;)
[18:03:27] hfp: well, file says it's already utf8
[18:04:02] hfp: universa1: Even if I add it, I have the same error
[18:04:53] mikecmpbll: if you've narrowed it down to that line
[18:04:57] mikecmpbll: try narrow it down further.
[18:05:06] universa1: hfp: does that line work in rails c ?
[18:05:11] mikecmpbll: removing stuff from it .. i've no idea, so that seems the easiest way for me.
[18:05:35] universa1: hfp: what happens when you call the seeds.rb file from rails console ?
[18:06:02] hfp: universa1: Well, I tried assigning the listings array by copy pasting the whole array and it worked but the error doesn't say which line it's tripping on.
[18:06:11] hfp: universa1: How do I do that?
[18:07:07] universa1: hfp: require 'db/seeds.rb??? should do the trick
[18:07:28] universa1: hfp: did you als try Listings.create! listings ?!
[18:08:26] hfp: I added the error from the console https://gist.github.com/Coaxial/fb598ed13f9458550092
[18:09:22] hfp: Why would it think it's the end?
[18:09:41] universa1: hfp: can you please add: # encoding: utf-8 to the top of the seeds file again?!
[18:10:00] universa1: hfp: restart rails console, and do the call again.
[18:10:05] hfp: Sure, one sec
[18:11:32] rhizome: you could split that line into separate lines at the field separators, it might narrow it down a bit
[18:11:54] universa1: rhizome: yeah, if the encoding part doesn't fix it ;)
[18:12:43] hfp: universa1: I'm getting an uninitialized constant error now, put it in the gist
[18:13:08] rhizome: specifying encoding won't help if the db encoding is the problem
[18:13:46] universa1: hfp: can you require 'db/seeds.rb' instead of exec ??? ?
[18:14:12] hfp: require doesn't work
[18:14:13] hfp: LoadError: cannot load such file -- db/seeds.rb
[18:14:21] rhizome: yeah what. why aren't you using rake?
[18:14:33] hfp: rhizome: Because rake gives a cryptic error
[18:14:43] universa1: it didn't work. was trying to narrow it down to the code or rake ;)
[18:14:46] rhizome: as opposed to
[18:14:57] universa1: hfp: can you try rake again? ;)
[18:15:11] hfp: rhizome: Check the gist: https://gist.github.com/Coaxial/fb598ed13f9458550092, the error from rake is called "error"
[18:15:50] universa1: hfp: require "./db/seeds.rb" should work
[18:15:52] hfp: universa1: It works now
[18:15:55] rncrtr: I have accounts & addresses tables. How do I get back all fields from both tables joined on address_id? It only returns Accounts's fields
[18:15:55] rhizome: that's the invalid byte sequence, not cryptic
[18:15:55] hfp: using rake
[18:16:14] hfp: rhizome: Well without a line number on seeds.rb it wasn't very helpful
[18:16:53] rhizome: rncrtr: huh?
[18:17:12] hfp: universa1: What does encoding changes? When I do `file db/seeds.rb` it says the file is already UTF-8
[18:17:35] hfp: So why couldn't it work without that line?
[18:17:50] universa1: hfp: it tells ruby that the file is utf8 encoded and that it should handle it as utf8. because ruby still defaults to us-ascii iirc
[18:18:05] rncrtr: rhizome: Is there a way to return all fields from joined tables in a rails controller
[18:18:18] universa1: hfp: not sure if it looks at the magic bytes at the beginning of the file.
[18:18:30] universa1: hfp: and this might be different between 1.9.3 and 2.x
[18:18:51] hfp: universa1: Yeah, that's another thing, why does 1.9.3 seems to be the defacto standard for rails apps?
[18:18:58] rhizome: rncrtr: what are you doing, without using the word "join"
[18:19:09] universa1: hfp: 2.1.2 is recommended with 4.1
[18:19:41] universa1: hfp: because it was the current stable version at the time of the release of rails 3
[18:19:54] ponch_: has anyone used Amazon s3 and uploaded/downloaded files ?
[18:20:05] rhizome: ponch_: no, nobody ever. ask your question.
[18:20:22] hfp: universa1: So this is rails 4.0 app, should I upgrade Ruby to 2.0.0?
[18:20:23] universa1: rhizome: i was so tempted to do: !anyone ;)
[18:20:33] universa1: hfp: i'd upgrade to 2.1.2 yes.
[18:20:39] rncrtr: rhizome: I have Accounts and addresses associated in my models, but can't get all the fields from addresses to return
[18:20:42] rhizome: in the old days it was "NE1"
[18:20:43] universa1: hfp: and rails to 4.1 ;)
[18:21:01] ponch_: i'm trying to download using Amazon s3 and it is giving me a 403 forbidden error that i can't figure out the reason for
[18:21:08] rhizome: rncrtr: "eager loading"
[18:21:09] ponch_: have you run into it before ?
[18:21:17] universa1: ponch_: well we can't either. show your code.
[18:21:18] ponch_: "eager loading"?
[18:21:28] ponch_: alright ill do a paste bin
[18:21:35] helpa: ponch_: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[18:21:35] universa1: ponch_: !gist
[18:23:42] ponch_: alright https://gist.github.com/anonymous/e91683132b693964dac0 is the link to the download method im working on
[18:25:04] hfp: universa1: I'm always afraid that it'll break things by going up a dot release
[18:25:41] universa1: hfp: run your tests??? :-p but from 4.0 to 4.1 is mostly painless
[18:25:52] universa1: ponch_: error?!
[18:26:07] ponch_: 403 forbidden access
[18:26:13] hfp: universa1: And also, how do you know whcih Ruby version is "standard" for every Rails version?
[18:26:15] universa1: error trace...
[18:26:20] mikecmpbll: hfp: by the way, here's your non-ascii characters: https://gist.github.com/mikecmpbll/1ff03700cf999f282a89
[18:26:37] mikecmpbll: see the difference between yours (top) and ordinary characters (bottom)
[18:26:54] mikecmpbll: if you just rewrote that line by hand, it would work fine
[18:27:03] mikecmpbll: you've ended up with some gumf in there some how.
[18:27:52] hfp: mikecmpbll: Yes I dumped the current database with a script and just copy pasted the output because it's a bit of a drag to rewrite these records by hand... So the space was a funky space rather than a regular one?
[18:28:06] mikecmpbll: there's a few characters which appear different
[18:28:18] mikecmpbll: the quote, the comma, the space
[18:28:43] mikecmpbll: i didn't bother investigating beyond that as to what they actually were.
[18:28:46] mikecmpbll: i'm sure you can do that.
[18:29:21] hfp: mikecmpbll: Thanks, TIL how to debug encoding weirdness
[18:30:23] hfp: Yep, I rewrote the characters and now it works without encoding: utf8 at the top of the file
[18:31:53] rhizome: you could probably force all that in your export
[18:39:45] j_mcnally: o forgot how awful some AR call backs are
[18:40:12] j_mcnally: if u return false from a call back the transaction rollsback with no message / no stack trace / no exception / just fails
[18:40:22] j_mcnally: talk about a debug nightmare
[18:44:35] fwaokda: not sure if this question will make sense but, does anyone have a reasonable name for a folder to put views in that aren't really tied to a specific model? Or is there a couple of questions i should be asking myself that might help with the naming?
[18:44:50] centrx: Views are tied to a controller
[18:44:58] fwaokda: i was using static_pages, but these pages aren't really static so not sure that makes sense
[18:45:35] centrx: You can simply make a new controller that does not correspond to a model
[18:45:52] centrx: fwaokda, Look up rails generate controller
[18:45:56] fwaokda: centrx, ok so for example... i have a page that is going to receive input from a user in the form of a barcode. then it's going to perform a lookup in the databse for that barcode and then build a message to then tweet out
[18:46:22] karamazov: I can't figure out how to cache this API call https://gist.github.com/anonymous/99b06de8b0b5b39857d7 I know github responds with etags but I don't know how to check the response.
[18:46:40] fwaokda: i just don't know what to name to folder for that, wasn't sure if there was some best practices or rules or something to coming up with a proper name for the folder holding that view
[18:47:14] centrx: fwaokda, I would make a BarcodeTweetController, then your views would be under the barcode_tweet/ directory
[18:47:59] fwaokda: centrx, ahh ok thanks i see how you came up with that i believe. thanks!
[18:50:34] fwaokda: centrx, and for methods I would want to use within that view/controller would i create and store those methods in a model or in the helper file corresponding to that view/controller?
[18:51:26] centrx: fwaokda, Models are for data access, they model your relational database in the form of programming objects
[18:52:01] centrx: fwaokda, So methods unrelated to perform a lookup in the databse for that barcode and other data-related things, belong either in a library under lib/, or in the controller itself.
[18:52:50] fwaokda: centrx, ok thanks... i'll go google/read up on the using & maintaining libraries
[18:59:27] rafaelcgo: guys... my stylesheet_link_tag is returning /stylesheets/admin_manifest.css instead of /assets/admin_manifest.css ... javascript_link_tag is working as expected... any ideias what might be happening?
[19:01:14] tejas-manohar: anyone used new GMail API with RoR
[19:03:41] tejas-manohar: is the new gmail api restful
[19:03:45] tejas-manohar: can i use ruby
[19:10:52] tyrone_: I want to use the mailboxer gem but they have specified foreigner for foreign_key management. I am already using Schema plus though so there is a collision. Can anyone tell me the simplest way to exclude the foreigner gem from dependencies installed as part of the mailboxer gem. I would like to avoid forking the gem if possible.
[19:11:59] rhizome: if that's a problem you really need to solve, maybe using something besides mailboxer is worth considering.
[19:17:06] tyrone__: rhizome, do you have any other suggestions for internal messaging?
[19:17:22] rhizome: i have no idea what you mean by that
[19:19:24] tyrone__: rhizome, I have different users and they need to be able to message other users in the system hence the mailboxer issue.
[19:20:56] liquid-silence: just re-installed my dev machine, think I need to try another editor and not vim
[19:22:05] liquid-silence: maybe its time to give atom a go
[19:22:13] liquid-silence: what do you guys think?
[19:22:29] centrx: no way, use vim
[19:22:58] liquid-silence: centrx yeah but I feel we have these awesome machines with so much ram, and then we use vim
[19:24:10] centrx: You could use pen and paper if you had a quick OCR scanner, it's writing code
[19:24:38] centrx: Most things on most computers need none of these speedy hardware
[19:33:29] rhizome: tyrone__: i'd probably just write it myself
[19:40:19] tyrone__: rhizome, thanks but of course if there was a decent one out there I would have liked to use it. Seems I will have to use something else or write something from scratch.
[19:41:39] ponch_: i am using batman to send to route to a method that is supposed to download a file -- it executes the commands but for some reasons nothing is downloaded .... help please
[19:41:46] ponch_: https://gist.github.com/anonymous/c6b68f604ecc4d25848e ------- code
[19:41:49] liquid-silence: does anyone here still use white background based color schemes?
[19:42:24] ponch_: it hits all of the puts so i'm not sure why it isn't doing what it says it is
[19:42:37] rhizome: what's "batman?"
[19:43:21] ponch_: sorry batman.js is a framework it does frontend backend shtuff
[19:44:23] rhizome: no idea then
[19:44:41] ponch_: well the code im dealing with is is ruby
[19:44:58] ponch_: i was just mentioning that it is called using a batman route
[19:45:20] ponch_: batman.request * not that it matters
[19:45:28] rhizome: how is a batman route different than a rails route?
[19:45:38] ponch_: the code is being called which is confirmed by the puts being called
[19:46:22] ponch_: its just this new thing my company is trying to use
[19:46:32] ponch_: it doesn't really matter the ruby code is being called
[19:46:44] ponch_: shopify uses it
[19:46:53] ponch_: uses batman
[19:47:48] ponch_: so i'm at the ruby code its being called and it works when i use like a direct route by being like localhost:3000/download_attachment but when i click the link which should do the same frickin thing it does nothing
[19:55:31] rafaelcgo: guys... my stylesheet_link_tag is returning /stylesheets/admin_manifest.css instead of /assets/admin_manifest.css ... javascript_link_tag is working as expected... any ideias what might be happening?
[19:58:45] nT4BR: somebody here have knowledgment about soa archteture?
[19:59:05] nT4BR: i want to make some services for manage customers, orders, videos, products and etc
[19:59:16] nT4BR: but how to link all this togheter?
[20:03:29] crankharder: nT4BR: 1) make an API 2) make a client 3) use client
[20:04:04] cek: How do I register another mime type in rails?
[20:04:44] nT4BR: crankharder: but how i can secure the apis, for example, i not want others to access my orders api...
[20:05:13] cek: nm, found it
[20:05:13] nT4BR: and my customers apis, will i need something like a proxy for all my small applications?
[20:05:48] crankharder: nT4BR: maybe, all of that is mostly outside the scope of rails
[20:06:27] nT4BR: crankharder: can you suggest some articles or books about this kind of archteture?
[20:08:03] crankharder: no, i dont really know any
[20:08:14] crankharder: they probably exist though
[20:08:33] koyd: nT4BR: you need to research distributed systems
[20:08:47] koyd: nT4BR: specifically, search also for fault-tolerant distributed systems
[20:09:11] nT4BR: koyd: thank you
[20:09:45] koyd: but be prepared that it's a huge amount of information. try to find something directed to SOA design
[20:10:26] koyd: because otherwise you'll be reading about how the internet works, from ISPs to torrent's DHT system :)
[20:11:22] karamazov: I'm populating a select field with content from an API call but when I submit the name parameter is null. I can't seem to figure out what's wrong. https://gist.github.com/anonymous/9e14a1afa257974e5845
[20:11:54] elaptics: nT4BR: do you already have an application? Or you're starting from scratch?
[20:12:05] stef1a: how can i tell if i need a has_many :through association or just a has_many?
[20:12:54] nT4BR: elaptics: i have an application in production that will be rewrited
[20:12:59] elaptics: stef1a: you'd generally just know. Do you have a particular example in mind?
[20:13:18] stef1a: elaptics: i currently have
[20:13:33] nT4BR: elaptics: this is for an startup that have a growing codebase, and we need a more robust solution
[20:13:51] nT4BR: elaptics: ops, growing number of customers
[20:14:01] stef1a: elaptics: user has_many projects and project has_many submissions, but also user has_many submissions, as there are different user roles... and i'd rather not make a different model for each role
[20:14:28] elaptics: nT4BR: only book I know of that covers rails and SOA http://www.amazon.com/gp/product/0321659368/ref=as_li_qf_sp_asin_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0321659368&linkCode=as2&tag=chamaxwoo-20
[20:15:17] elaptics: stef1a: then if you want to get submissions for users then you'd need a hmt
[20:15:53] elaptics: if you want to go through the projects if that's the controlling thing
[20:16:15] elaptics: stef1a: not quite sure how your roles factor into this though?
[20:17:00] stef1a: elaptics: if user.role is advisor, then user has_many projects. if user.role is student, then user has_many submissions
[20:17:12] stef1a: but in either case, project has_many submissions
[20:17:54] stef1a: i am not sure whether a hmt would helpm
[20:18:04] stef1a: because the roles complicate it a bit?
[20:18:25] elaptics: stef1a: that sounds a bit odd to me
[20:18:28] elaptics: stef1a: what's the app?
[20:19:36] stef1a: elaptics: advisors create proposals for projects they want help on. students apply ("create submissions") for these projects. advisors then see the submissions for projects they posted and either accept or reject applicants' "submissions"
[20:19:59] jenrzzz: does anyone know what causes objects??? #to_s to say that they are an instance of Class? or whatever the correct interpretation of this is: NameError: undefined local variable or method `result' for #<#<Class:0x007f773d7b8868>:0x007f773cbdab18>
[20:20:24] stef1a: (i would use "applications" but that conflicts with Rails' naming conventions... so i have settled for submissions instead)
[20:20:27] maoko: Yay. is it a time to ask a dumb question? ^_^
[20:21:00] maoko: Why postgresql omits indexes with rake db:setup in test db?
[20:21:11] maoko: and primary keys as well
[20:21:38] jenrzzz: maoko: is your schema.rb up-to-date?
[20:22:01] maoko: jenrzzz, yes, made a new one from actual db recently
[20:22:26] cek: Hmm. When client's sending HTTP_ACCEPT with multiple items, rails considers request as HTML, when only first item in HTTP_ACCEPT is sent, it considers it as custom type (what I want). Why's that?
[20:23:02] jenrzzz: maoko: does db:schema:load do what you expect?
[20:23:06] stef1a: elaptics: i think that what i have could work just fine (because it currently is working okay); i'm just wondering whether there's a simpler way to do it / if i might run into trouble later on
[20:23:35] maoko: jenrzzz, yup. Getting test database created, but every single table is missing primary keys
[20:24:11] elaptics: stef1a: so where do projects come from?
[20:24:30] elaptics: stef1a: is a project the proposal?
[20:24:44] jenrzzz: maoko: but the schema specifies the indices with add_index?
[20:25:30] jenrzzz: cek: what are the multiple formats?
[20:25:37] jenrzzz: cek: see http://blog.bigbinary.com/2010/11/23/mime-type-resolution-in-rails.html if you haven???t read it
[20:25:42] stef1a: elaptics: there is another complication: there is a third role, advisors. when advisors first create a project, it is unapproved and students can neither see nor apply to it. the admin users are able to approve or disapprove projects that advisors make. once they are approved, they are up on a list for students to read, and students can apply for them.
[20:25:51] stef1a: sorry, the third role is admins, not advisors.
[20:25:55] cek: jenrzzz: yeah, I read that article , doesn't help.
[20:26:19] elaptics: stef1a: can a user have more than one role?
[20:26:25] stef1a: elaptics: no
[20:26:46] stef1a: elaptics: well, perhaps... i am unsure, but i imagine the only shared role would be advisor and admin
[20:26:55] stef1a: but that is an edge case
[20:27:10] maoko: jenrzzz, can see them there, but none of them are getting into the db.
[20:27:19] cek: jenrzzz: see https://gist.github.com/celesteking/ff75d81991214f5b31d6 . disregard "templ not found" error, I'll fix that.
[20:28:08] jenrzzz: cek: are you using respond_to or respond_with?
[20:28:20] cek: controller.respond_to do |format| format.voicexml do
[20:28:41] jenrzzz: maoko: gist plz
[20:28:51] jenrzzz: maoko: also, what DBMS are you using?
[20:29:21] elaptics: stef1a: it sounds like your users are quite distinct roles I would probably have separate models for the roles. They could all use the same user or account model as the thing that deals with the login
[20:29:47] elaptics: stef1a: that would make your models and associations simpler
[20:29:56] jenrzzz: cek: did you register your application/voicexml+xml MIME type in config/initializers/mime_types.rb?
[20:30:11] cek: Mime::Type.register 'application/voicexml+xml', :voicexml, %w(text/x-vxml)
[20:30:47] maoko: jenrzzz, here it is https://gist.github.com/maokomioko/e3f7e10efd2f8663bb0b postgresql 9.3.4
[20:31:40] stef1a: elaptics: what if a user has more than one role, in a rare edge case? would i just stick the record in two of the tables?
[20:31:49] jenrzzz: maoko: so what exactly isn???t working when you load the schema? activerecord doesn???t create foreign key constraints unless you use something like foreigner
[20:32:07] cek: I just don't get why "accept: 'application/voicexml+xml'" is considered as XML and "accept: 'application/voicexml+xml, application/srgs+xml, application/srgs, text/x-vxml, */*'" as HTML.
[20:32:27] cek: that's stupid. there's no q and first item should win.
[20:32:36] cek: additionally, I don't specify format.html for processing
[20:32:56] maoko: jenrzzz, activerecord doesn't create primary keys for id columns
[20:33:06] sharpmachine: I have a super quick question. Where is the best place to put site-wide styles? application.css or scaffolds.css.scss?
[20:33:12] jenrzzz: maoko: yeah, that???s expected behavior
[20:33:39] cek: http://stackoverflow.com/search?q=rubyonrails+mime 9 results. Now wonder I'm hitting wall.
[20:33:42] maoko: sharpmachine, scaffolds, applications.css is just a container for all 'required' files
[20:34:07] maoko: jenrzzz, could you please point me to an article or something?
[20:34:23] elaptics: stef1a: if admins are just a kind of super-advisor then I'd consider just having advisor and student models and on the advisor one having an admin boolean which if it was set gives them the admin abilities
[20:34:24] sharpmachine: Awesome thanks maoko
[20:34:39] maoko: sharpmachine, np :)
[20:34:55] elaptics: stef1a: depends on how complex the app will end up being and how the users roles/ui has to change
[20:35:00] jenrzzz: maoko: https://github.com/matthuhiggins/foreigner, https://stackoverflow.com/questions/14717698/why-would-someone-use-the-gem-foreigner
[20:35:08] stef1a: elaptics: got it... thanks so much!
[20:35:18] elaptics: stef1a: np, good luck :)
[20:35:25] jenrzzz: maoko: rails philosophy moves most constraints like that into the application layer
[20:35:32] karamazov: Do select_tags require anything special to send with the rest of the params in a form? I'm seeing the value on my error page but the param is getting a missing error
[20:36:00] jenrzzz: cek: can you gist your controller code?
[20:36:52] cek: https://gist.github.com/celesteking/ff75d81991214f5b31d6 second file
[20:36:53] maoko: jenrzzz, thanks for pointing, looks like it'll be a looong night :)
[20:37:06] rhizome: cek: because http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
[20:37:21] cek: rhizome: no q value in header
[20:37:42] rhizome: keep reading
[20:38:53] cek: could you elaborate? those that come first are considered having higher priority
[20:39:12] cek: so it should stumble upon application/voicexml+xml and go via :xml route
[20:39:51] nanodano: Does rails come with any tools for helping with spam? A catpcha helper? Are there any standard practices?
[20:40:41] jenrzzz: cek: radar wrote this a while ago, maybe you will discover something? http://ryanbigg.com/2009/04/how-rails-works-2-mime-types-respond_to/
[20:40:59] jenrzzz: or maybe now that he???s been mentioned he will swoop in and solve all of your problems
[20:41:57] cek: i'm more inclined that i just hit a bug in rails 3.latest
[20:42:00] rhizome: cek: it would seem that the request is only hitting */*
[20:42:10] cek: rhizome: no shit, man
[20:42:46] rhizome: well la de da
[20:45:57] jenrzzz: cek: what is your request.format?
[20:46:53] cek: #<Mime::Type:0x00000004fbdbb0 @string="text/html", @symbol=:html,
[20:46:53] dstarh: is there a generally accepted practice for assigning setting a variable in application controller that's accessible in all models that won't run into thread safety issues/
[20:47:35] jenrzzz: dstarh: what do you need it for, and what web server/forking model are you using?
[20:47:40] rhizome: dstarh: no, because it's generally bad practice
[20:48:04] dstarh: we have a multi tenant app and many times we'll have to pass the current brand down to the model layer for decisions to be made about certain features that are brand specific
[20:48:17] dstarh: using passenger
[20:48:26] rhizome: down from where?
[20:48:26] jenrzzz: ???current brand????
[20:48:33] dstarh: from the controller
[20:48:59] terrellt: So make a service object that takes a context and deals with models appropriately.
[20:51:35] dstarh: might be easier to understand if I substituted current user instead of current brand
[20:52:01] jenrzzz: cek: i think you might have the best luck specifying the format in your URL with .voicexml or something. Accept header parsing is gross
[20:52:36] cek: jenrzzz: the problem is that its hitting the controller with wrong format type
[20:52:52] cek: so it's somethign wrong up in the parse chain
[20:53:09] dstarh: we deal with nutrition services and when someone requests a meal some of the meals nutrients are targetd to that specific user. Currently we're having to pass the user down a few layers to the model where calculations are taking place but it'd be nice not to have to do that and for example call User.current
[20:53:43] jenrzzz: cek: expected behavior I think. the format parser will always return Mime::HTML if the Accept header includes */*
[20:54:05] jenrzzz: https://github.com/rails/rails/issues/9940
[20:54:25] jenrzzz: cek: https://github.com/rails/rails/pull/14540
[20:54:30] stef1a: elaptics`away: but still, it makes more sense to have just one projects model instead of a proposals model and a projects model, right? the only difference is whether the project has been approved, so i could easily have an approved bool column in the projects table
[20:54:49] dstarh: actually something like this wouldn't be terrible http://stackoverflow.com/a/8291218/138883
[20:55:15] jenrzzz: dstarh: pulling that behavior out into a service object is probably a better way
[20:58:48] hobodave: hey guys, I'm working on upgrading a Rails 3.2 app to Rails 4.0 and I've encountered this error that I'm not sure how to address. This happens when I run our specs: https://gist.github.com/hobodave/eb0b7004ad32dedd1123
[20:59:27] rhizome: hobodave: what is "< Model"?
[20:59:57] hobodave: a subclass of ActiveRecord::Base it looks like
[20:59:58] crankharder: it's just that localized_content.rb is getting loaded before getaways.rb
[21:00:13] crankharder: try require 'getaways' at the top of localized_content
[21:00:33] jenrzzz: crankharder: autoloader should handle that for him
[21:00:38] hobodave: let met ry that again crankharder, I did that and the error changed so I reverted it
[21:00:44] crankharder: should. isn't.
[21:00:53] jenrzzz: hobodave: try changing it to ::Getaways::LOCALIZED_ATTRIBUTES maybe?
[21:00:59] jenrzzz: to look from the top scope
[21:01:02] apneic: I want to write a regex matcher to match any string of characters up and until a "#" which may or may not exist. For example, in "abcdefghijk#lmn", I want to match "abcdefghijk". In "opqrstuvwxyz", I want to match "opqrstuvwxyz". So far I have something like / (.*)#? /, but in both cases it matches the whole string. If I use / (.*)# /, it doesn't match the second string at all. Any ideas?
[21:01:03] hobodave: error changes to
[21:01:08] hobodave: ./app/models/getaways.rb:1:in `<top (required)>': superclass mismatch for class Getaways (TypeError)
[21:01:18] hobodave: I'll try that jenrzzz
[21:01:23] jenrzzz: apneic: http://rubular.com
[21:01:35] apneic: jenrzzz: I've been using that, it's my knowledge of regex that's limiting me.
[21:01:54] hobodave: no change jenrzzz
[21:02:10] apneic: oh hold on a sec
[21:03:20] hobodave: any other ideas?
[21:03:48] apneic: jenrzzz: I got it, thanks
[21:04:16] jenrzzz: hobodave: wtf is Getaways supposed to represent?
[21:04:54] jenrzzz: why is it plural? why is LocalizedContent an inner class?
[21:05:19] hobodave: I can't answer all that
[21:05:34] hobodave: it's a huge app in production use
[21:05:41] hobodave: I don't understand all the inner workings of it :)
[21:05:46] hobodave: hell even the PMs don't
[21:06:00] hobodave: it represents something very domain-specific to the business
[21:06:19] hobodave: we have this LocalizedModel which seems to provide localized versions of models
[21:08:40] hobodave: any ideas how I can fix this?
[21:09:48] hobodave: no idea why its plural, only model that is lol
[21:10:10] jenrzzz: i???m googling
[21:10:16] jenrzzz: but don???t really know
[21:10:33] hobodave: I suspect the autoloader changed somehow
[21:10:49] jenrzzz: i???ve never used classes for namespacing models and I???ve never had the namespace be an ActiveRecord model
[21:11:22] hobodave: maybe the autoloader is now aware that it's within the Getaways class when it sees Getaways::LOCALIZED_ATTRIBUTES and doesn't attempt to hit the autoload path
[21:11:39] hobodave: don't see anything in the UG notes though
[21:11:49] rhizome: someone doesn't like i18n
[21:11:56] hobodave: let me try to enable eager_load for test
[21:12:18] j_mcnally: sounds like a java developer set this up
[21:12:43] jenrzzz: rails I18n isn???t enterprisey enough
[21:12:52] jenrzzz: needs more FactoryFactories
[21:13:06] rhizome: please. i'm eating.
[21:13:29] j_mcnally: hobodave: have you tried https://github.com/tenderlove/enterprise ?
[21:13:40] jenrzzz: rhizome: maybe you should refactor your LunchManagerImpl
[21:14:27] cek: jenrzzz: I knew I was hitting bug.
[21:14:36] cek: that patch is against 4.x sadly
[21:14:42] jenrzzz: cek: upgrade!
[21:15:25] hobodave: eager loading made that error go away
[21:15:34] hobodave: moving onto others
[21:15:36] j_mcnally: interesting
[21:15:46] rhizome: the enterprise cannot wait
[21:17:10] jenrzzz: hobodave: oh what you had eager loading off? that???ll do it
[21:17:46] j_mcnally: jenrzzz: isnt that the default in development tho?
[21:17:58] hobodave: this is test
[21:18:04] hobodave: running specs, trying to anyway
[21:18:13] j_mcnally: my test.rb has
[21:18:13] j_mcnally: config.eager_load = false
[21:18:18] hobodave: I didn't have that set at all, I only set it when rails yelled at me
[21:18:27] hobodave: it said set dev & test to false and prod to true
[21:18:47] jenrzzz: i think you may have just buried the actual problem
[21:19:08] j_mcnally: needs more `require_dependency` i mean this is enterprise and all.
[21:19:26] stef1a: what's the difference between update_attributes and save? why can save only be used at creation / not in an update action?
[21:19:39] hobodave: jenrzzz I'm sure I did :)
[21:19:45] j_mcnally: stef1a: umm thats nto true
[21:19:59] nobitanobi: Hey guys, I have had some race conditions due to Sidekiq jobs trying to increment an attribute of one of my models, and I came up with this solution: https://gist.github.com/novito/3c0e4e5432534b3bd042 - What is the performance impact of reloading an object?
[21:20:02] j_mcnally: stef1a: u can call save on a model at any time to persist it to the db
[21:20:02] jenrzzz: hobodave: actually though, you might want to explicitly call ActiveSupport::Dependencies.load_missing_constant or something like that
[21:20:47] jenrzzz: stef1a: #update assigns the attributes and then saves the model. #save just saves the model
[21:20:55] stef1a: j_mcnally: when i do save, it appears to not actually update the object's params... i need to do update_attributes for the changes to actually be reflected in the db
[21:20:56] j_mcnally: nobitanobi: it will just do the find again
[21:21:07] j_mcnally: stef1a: one of ur callbacks in blocking
[21:21:12] stef1a: jenrzzz: thanks -- that makes ses
[21:21:25] stef1a: sense. also, j_mcnally, isn't jenrzzz right?
[21:21:28] nobitanobi: j_mcnally: ok :) Do you know of other strategies to fight against race conditions when incrementing an attribute, that doesn't require do the Find again?
[21:21:45] j_mcnally: stef1a: well yes and no
[21:21:57] j_mcnally: @mymodel.something = "cool"
[21:21:58] hobodave: woohoo test suite is running!
[21:22:01] j_mcnally: @mymodel.save
[21:22:21] j_mcnally: is equal to @mymodel.update_attributes("something", "cool")
[21:22:58] stef1a: j_mcnally: ah i see. so by just calling save i was not assigning the attributes that were entered in the form.
[21:23:12] j_mcnally: ahhh yes that is correct
[21:23:24] j_mcnally: stef1a: u actually need to pass your updated params into the model
[21:23:37] j_mcnally: stef1a: @mymodel.update_attributes(some_params)
[21:23:40] jenrzzz: nobitanobi: what DBMS are you using?
[21:23:46] stef1a: hahaa yeah, now it seems obvious
[21:24:22] jenrzzz: nobitanobi: so what is the race? multiple sidekiq workers trying to increment the same counter?
[21:24:30] nobitanobi: two sidekiq threads
[21:24:58] jenrzzz: when does that happen?
[21:26:02] nobitanobi: I have an Order which has_many Ads. When I change the attribute ad_status of Ad, I call that function that does the increment at the Order level.
[21:26:18] nobitanobi: This is to have a control in the Order level of how many ads have been processed, how many have failed,...
[21:27:15] nobitanobi: jenrzzz: this is in the after_update callback of an Ad https://gist.github.com/novito/8039a809bd6b892c8119
[21:27:55] jenrzzz: oh, it does it in a callback? where does sidekiq fit in here?
[21:28:15] nobitanobi: well, the Sidekiq thread is managing that object
[21:29:05] nobitanobi: jenrzzz: it's ok though, doing the reload does its job
[21:29:06] jenrzzz: i???m still not entirely clear on the problem. do things get double-incremented from a single job?
[21:29:27] nobitanobi: jenrzzz: when a thread gets there, it finds the value at 0, and increment it to 1
[21:29:33] nobitanobi: but the other thread also finds it to 0
[21:29:42] nobitanobi: so at the end the value should be two, and its just one
[21:30:04] jenrzzz: these are from different sidekiq jobs?
[21:30:32] nobitanobi: two threads trying to do the same thing basically at the same moment
[21:30:34] j_mcnally: nobitanobi: are you sure u dont want some sort of batching
[21:30:51] j_mcnally: nobitanobi: the best non sidekiq-pro solution ive found is SuperWorker....
[21:31:04] j_mcnally: https://github.com/socialpandas/sidekiq-superworker
[21:31:34] j_mcnally: nobitanobi: sound like u should be running the task in series rather than parallel maybe>?
[21:31:46] nobitanobi: j_mcnally: thanks for that recommendation
[21:32:01] nobitanobi: I can run them in parallel
[21:32:08] nobitanobi: the process of one Ad is independent of the process of another Ad
[21:32:14] j_mcnally: it would seem that the issue stems from one worker reading it.. another updating it... and the original version being out of date
[21:32:29] nobitanobi: j_mcnally: I think that is right
[21:32:44] nobitanobi: however, doing the increment_count atomic operation and reloading the object makes it work
[21:32:45] jenrzzz: nobitanobi: are you sure that???s what???s happening? #increment_counter should get an exclusive lock with it???s UPDATE
[21:33:00] jenrzzz: nobitanobi: i think maybe the in-memory AR is just out of date
[21:33:13] jenrzzz: in which case #reload is the right way to d oit
[21:33:13] nobitanobi: maybe just reloading it
[21:33:25] nobitanobi: crap that might be it
[21:34:04] nobitanobi: jenrzzz: good catch
[21:34:18] nobitanobi: j_mcnally: I am going to take a look at the superworker. I am actually debating on buying the Sidekiq pro.
[21:34:32] j_mcnally: jenrzzz: nobitanobi: but theres still a race confition.
[21:34:51] karamazov: Is this the recommended way to use ENV variables? http://richonrails.com/articles/environment-variables-in-ruby-on-rails#.U8BYJ41dXIU
[21:34:55] j_mcnally: jenrzzz: nobitanobi: even if u reload, it could still get swapped before u have time to save again
[21:35:21] nobitanobi: j_mcnally: but I really need to do this in parallel
[21:35:27] nobitanobi: because each Ad is independent of the other Ads
[21:35:36] jenrzzz: j_mcnally: not really though. it???s pretty deterministic that one of the models will get out of date if another thread updates it in the DBafter the model has been loaded
[21:35:37] nobitanobi: they just need to tell their parent Order, that they have finished/failed/.
[21:36:25] jenrzzz: nobitanobi: you might want to get an exclusive lock on the Order model in the worker
[21:36:37] jenrzzz: if you add lock: true to your finder
[21:36:39] j_mcnally: nobitanobi: i would lock the row when i first read it and release the lock after i save
[21:37:02] nobitanobi: jenrzzz: j_mcnally I have never done that. Let me see
[21:37:18] j_mcnally: jenrzzz: did we just become best friends?
[21:37:25] jenrzzz: i thought we already were
[21:37:53] nobitanobi: what would happen if the record is locked and another thread comes and tries to access?
[21:38:05] jenrzzz: it will block until it can get its lock
[21:38:06] j_mcnally: nobitanobi: it will wait till the configured lock timeout
[21:38:16] rhizome: i hate the check_box api docs
[21:38:26] nobitanobi: j_mcnally: jenrzzz thanks, I will take a look.
[21:38:53] jenrzzz: rhizome: blame W3C
[21:40:14] j_mcnally: rhizome: the rails ones?
[21:41:40] rhizome: yes. i have a complicated nested form and i can't figure out why all the checkboxes are checked.
[21:42:19] j_mcnally: rhizome: gist?
[21:44:11] louism2wash: Hey guys, I see that jquery comes bundled with rails by default. Is there any reason I should be serving it from my domain rather than that downloading it from google?
[21:45:52] rhizome: looks like gist isn't allowing file types to be selected
[21:45:53] rhizome: https://gist.github.com/rhizome/23f67d88b27295545283
[21:46:27] rhizome: louism2wash: what's a reason not to serve it from your domain?
[21:46:44] louism2wash: rhizome: take some load off my server
[21:46:52] rhizome: how much load is it?
[21:48:05] louism2wash: rhizome: it's probably inconsequential, more asking just to see if I am missing something?. serving it from your own domain removes an external dependency. Any other reason to serve it yourself?
[21:49:00] jenrzzz: it???s an extra 29k in your application.js
[21:49:03] j_mcnally: rhizome: the problem is the id
[21:49:07] jenrzzz: inconsequential unless you are facebook
[21:49:16] j_mcnally: rhizome: the 3rd argument for check_box is a boolean for checked
[21:49:25] j_mcnally: rhizome: if ur id > 0 it will be checked
[21:50:04] j_mcnally: value goes in the hash
[21:50:13] rhizome: that's the direction i was sniffing. hmm
[21:50:38] j_mcnally: = pos.check_box :lexicat_id, {:value => lexicat.id}, (some_expression_of_truth)
[21:51:23] rhizome: ACTION tries
[21:52:50] j_mcnally: rhizome: the docs are really bad
[21:54:36] j_mcnally: rhizome: :)
[21:55:03] j_mcnally: rhizome: this is why i use simple_form https://github.com/plataformatec/simple_form
[21:55:16] j_mcnally: rhizome: i dont have to deal with all this crap
[21:55:25] rhizome: i can't get them to be unchecked
[21:56:00] j_mcnally: is there a codepen for erb and rails?
[21:58:00] j_mcnally: rhizome: give up and use check_box_tag ?
[22:01:36] rhizome: http://stackoverflow.com/a/4140544
[22:04:03] rhizome: i feel like i'm editing a different file than is running
[22:14:03] rhizome: word booty
[22:15:48] rhizome: i was on the right track, but instead of :value, I needed a :checked statement in the braces
[22:16:46] rhizome: <%= pos.check_box :lexicat_id, { :checked => pos.object.persisted? }, lexicat.id %>
[22:17:06] rhizome: well that took entirely too long.
[22:19:28] j_mcnally: rhizome: ogod call
[22:24:26] rhizome: i always have to learn this stuff from scratch every time.
[22:31:31] rhizome: when using UJS on a form with a lot of separate sections, is it common to call submit() on every change for the whole form, or to do it in fragments?
[22:32:32] rhizome: i guess fragments would involve more or less dedicated actions, or maybe careful parameter construction.
[22:32:35] rhizome: ACTION spitballs
[22:46:41] alessandro1997: I'm having huge trouble serving assets in my Rails application .Loading a 2KB image on my VPS (served directly by nginx, not Rails) takes me 42ms. Loading it on Heroku might take more than 1 minute sometimes. The strange fact is that at this point the application is just a bunch of static pages served through High Voltage. All my assets are precompiled locally.
[22:55:45] MyTallest: Does anyone have any experience with the push-core gem for doing Apple Push Notifications?
[22:57:12] rhizome: just ask your question
[22:58:16] Limix: Hi, wondering what the best way to store and retrieve config type data is in a rails app. Example, I want to store the timestamp of the last time I queried for something.
[22:59:06] rhizome: querying for something is config data?
[22:59:38] MyTallest: I'm trying to use push-core but it's not working. I looks like it's not creating the request in the push_messages DB but I don't get any errors on the console?
[23:00:12] rhizome: MyTallest: console is the only place errors would appear? which console?
[23:01:12] Limix: rhizome, so what???s the best way to store a timestamp of the last time the app queried a remote service for invoices?
[23:01:41] MyTallest: Sorry the terminal I started rails server in.
[23:01:58] Limix: I would like to be able to do this basically: Config.last_invoice_query, then Config.last_invoice_query = Time.now
[23:02:22] rhizome: Config is a model or something?
[23:02:58] Limix: It can be anything, this is the general concept, should I make it a model?
[23:03:16] rhizome: i have no idea what you're trying to do, so..."maybe"
[23:04:15] karamazov: I'm trying to test my oAuth using a setup directly from intridea but keep getting "Uninitialized constant OmniauthMacros" I think it might be an issue with my spec_helper? https://gist.github.com/anonymous/4060b9502f4250e8fd20
[23:05:22] Limix: ok so I am syncing invoices from an external service. I want to only query for changed invoices. I am going to use sidekiq to background work. I want to only query for updated or new invoices based on timestamp. In the workers, I want to use some time of globally accesible property of ???timestamp??? so I don???t get old invoices.
[23:05:45] Limix: time=type*
[23:06:35] Limix: I guess I can create a Config model and query that, but I don???t like the idea of having to update the schema each time I add a new prop
[23:08:25] rhizome: what's wrong with changing the schema?
[23:09:31] Limix: that???s one issue, other issue is how can I enforce only a single record?
[23:10:14] Limix: just wondering if this is the standard way of doing this
[23:11:10] rhizome: you would probably use a singleton
[23:14:46] Limix: here we go: https://github.com/stephencelis/acts_as_singleton
[23:14:52] Limix: that???s what I???m trying to do
[23:15:46] Limix: or this: https://github.com/stephencelis/kvc
[23:22:47] karamazov: Do I need to set anything special for rspec to look in spec/support for files?
[23:34:58] tewlz: karamazov: typically no, have you tried running the tests to see if it works?
[23:35:51] karamazov: tewlz: Yeah...I added these to my spec files https://gist.github.com/kinopyo/1338738 and am getting an uninitialized constant error on OmniauthMacros
[23:36:13] karamazov: It seems like rspec isn't reading the OmniauthMacros module in spec/support
[23:37:43] tewlz: karamazov: you have to require 'spec_helper' if you want to initialize the stuff in your test
[23:38:20] karamazov: tewlz: In the module?
[23:38:53] tewlz: karamazov: in the test. rspec is running top_spec - if you don't tell top_spec what stuff to load it won't automagically load stuff by default
[23:39:40] karamazov: tewlz: I have that added - here's my setup based on the example https://gist.github.com/anonymous/4060b9502f4250e8fd20
[23:40:29] tewlz: karamazov: heh, well you didn't have it in the code you just gave me. Is it in the top_spec, too? Because it needs to be.
[23:41:30] karamazov: tewlz: It's in authentication_spec?
[23:42:03] karamazov: I've renamed top_spec to authentication_spec
[23:44:51] karamazov: rspec doesn't like config.include(OmniauthMacros)
[23:45:53] tewlz: I see that, trying to figure out why
[23:46:51] karamazov: heh sorry that was just my thoughts getting out of my fingers
[23:46:59] tewlz: karamazov: you have inconsistent camelcase on Omniauth
[23:47:24] tewlz: inside tests you're calling OmniAuth while you're defining modules with Omniauth
[23:47:31] tewlz: try fixing that and see what happens
[23:47:44] tewlz: in the examples I've seen everything is OmniAuthMacros
[23:50:17] karamazov: tewlz: That wasn't the issue
[23:50:45] tewlz: karamazov: it was one of the issues, maybe not the only one. Repost your code
[23:51:01] karamazov: tewlz: Definitely a contributing issue
[23:53:05] karamazov: tewlz: There she blows https://gist.github.com/anonymous/c4f835ff29a24e0e702e
[23:53:18] tewlz: karamazov: also I found this. https://www.omniref.com/ruby/gems/utensils/0.0.16/symbols/OmniAuthMacros
[23:53:32] tewlz: notice the config.before
[23:54:30] karamazov: tewlz: That looks like a relatively clean solution