« Back to channel list

#RubyOnRails - 16 April 2015

« Back 1 day Forward 1 day »
[00:00:23] Radar: jake_g: Do you have an example of one of these snags?
[00:02:25] jake_g: Radar: Theyre just minified js
[00:03:08] jake_g: yeah haha
[00:04:16] jake_g: bricker: alright, thats kinda what I gathered but that PR looked old and it looks like sprockets 3 just came out so I was wondering if I was misreading it or if they changed the versioning or something weird
[00:04:32] Radar: jake_g: The PR was committed to the 4.x branch.
[00:04:45] Radar: tbh nobody really knows what Sprockets does or how it does it.
[00:04:56] Radar: Their documentation is Josh-Peek-typical (i.e. non-existant)
[00:05:22] jake_g: haha alright, thanks
[00:06:52] Radar: ACTION rage-forks Sprockets to submit a PR
[00:19:04] sevenseacat: lol at sprockets rage
[00:20:02] bricker: aww I missed it
[00:20:56] et09: ryans talking trash to me
[00:21:50] Radar: which Ryan?
[00:22:12] sevenseacat: ACTION points at one of the 4000 Ryans involved in ruby
[00:22:22] bricker: What about the Bryans
[00:22:33] sevenseacat: theres a few of them too
[00:22:33] Radar: And the Brians
[00:22:40] Radar: And the Rhyans
[00:22:43] Radar: (yes they exist)
[00:22:45] bricker: Radar: psshhh what kind of a name is "Brian"
[00:23:00] sevenseacat: you all have such common names.
[00:24:03] sevenseacat: now that ive finished dismissing the peasants, I need caffeine.
[00:24:40] Etriaph: How do I new a model provided by an engine?
[00:24:55] Etriaph: m = Module::Model.new?
[00:25:07] Radar: Etriaph: !try
[00:25:07] helpa: Etriaph: Why don't you try it and find out for yourself?
[00:25:16] Etriaph: Radar: Tried, it blew up
[00:25:18] makerops: dending on how it's coded
[00:25:21] Radar: Etriaph: !didntwork
[00:25:21] helpa: Etriaph: 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.
[00:26:08] et09: Radar: did you actually have a problem with sprockets or something?
[00:26:25] Radar: et09: Yeah, they can't document for shit.
[00:26:39] sevenseacat: ACTION waits for the bombshell that et09 is actually josh peek
[00:26:40] et09: i filed an issue on it earlier today
[00:26:51] et09: http://extras.mnginteractive.com/live/media/site36/2011/0112/20110112__20110113_D01_AE13HUSTED~p4_300.JPG
[00:28:29] Etriaph: I get a NoMethodError with: undefined method `finder_needs_type_condition?' for nil:NilClass
[00:28:56] et09: Etriaph: a nil object where an object with method finder_needs_type_condition? is supposed to be
[00:30:34] et09: probably bad initialization code in the module
[00:30:44] et09: or possibly an unmet dependency
[00:37:05] rhizome: broken STI?
[00:37:17] Radar: Etriaph: stacktrace please
[00:39:43] Etriaph: https://gist.github.com/bewitchingme/403e0cbdcd28cdee67fa
[00:40:30] sevenseacat: so whats on app/controllers/default_controller.rb:3:in `placeholder'
[00:40:48] Etriaph: s = Gleam::Setting.new
[00:40:51] ebbflowgo: if I'm using jruby, what is the best practice to store my library jar files in rails?
[00:42:54] Etriaph: Just trying to init the model.
[00:46:14] grindmodeon: Hey Radar, hows it going?
[00:46:42] Radar: grindmodeon: it's going well :) Writing some Go code at the moment
[00:47:16] grindmodeon: Radar: so I'm coming along with the rails learning, about to start writing the rails app I need and hopefully it wont take me more than a week or so. Do you know of a simple guide/book that I can get better at ruby itself with?
[00:47:33] grindmodeon: I'm struggling with rails a tad because I'm not that familiar with ruby yet.
[00:48:06] Radar: grindmodeon: The Well-Grounded Rubyist is the book I always recommend to people
[00:48:53] grindmodeon: Radar: have anything I could read in like an hour or two tho?
[00:49:03] sevenseacat: patience, grasshopper
[00:49:05] Radar: grindmodeon: The Ruby Koans are good to go through.
[00:49:14] grindmodeon: I know I can't get it all that quick but I know some python and tons of PHP so I think I can pick it up quick
[00:49:31] sevenseacat: you won't pick up ruby in an hour or two.
[00:49:58] grindmodeon: well I've picked up the basics already lol
[00:50:02] grindmodeon: I can write basic ruby
[00:51:11] Radar: grindmodeon: Tell me what Hash.new(10) does.
[00:51:36] Radar: And how it's different from Array.new(10)
[00:52:02] Radar: Also what the difference is between a = "a string"; a += " another string" and a = "a string"; a << " another string"
[00:52:16] grindmodeon: not sure on the Hash lol
[00:52:31] Radar: This is the stuff an hour or two with Ruby Koans can teach :)
[00:52:58] grindmodeon: hmm ok sweet, should be enough to get me going for my app I think
[00:54:42] grindmodeon: Radar: to read the Ruby Koans, I just open the .rb files?
[00:54:50] Radar: grindmodeon: run rake test
[00:55:09] sevenseacat: step 1: follow the instructions
[00:55:24] Radar: Just Read The Instructions :D
[00:55:57] rhizome: rolls off the tongue better than "ritfum"
[01:19:54] bobbyd88: hey what is the recommended way to keep one div static in between page refreshes?
[01:20:51] et09: bobbyd88: a single page application e.g. angularjs/backbone/emberjs
[01:20:59] et09: learn it, love it
[01:21:41] sevenseacat: bobbyd88: that question is a bit odd
[01:22:27] bobbyd88: I want to have a music player that keeps playing as you navigate the site
[01:22:37] bobbyd88: I was thinking I could pull this off with pjax/turbolinks
[01:22:46] sevenseacat: oh yeah, welcome to 1998 :sunglasses:
[01:26:13] bobbyd88: if you wanted to google that what would you type? I keep getting this in my results http://stackoverflow.com/questions/20143057/how-not-to-reload-footer-on-page-navigation but have trouble getting it to work. Maybe there is a different way. Especially since it seems pjax got absorbed into turbolinks in rails4
[01:28:39] sevenseacat: i'm not actually very familiar with using that functionality in pjax/turbolinks
[01:29:50] bobbyd88: I was thinking SPA is kind of overkill for this
[01:30:10] Radar: ACTION lobs that particular grenade and gets back to work
[01:32:21] ftj: I'm writing a little web service with rails that uploads files to S3 and stores a pointer to that file in the database ?????any opinions here on whether the S3 interaction code should go in the model or controller?
[01:32:27] MrPunkin: Hey guys I have a custom getter / setter defined on a model, however calling object[attr] always returns null, even if the @attr instance variable is set. Can anyone tell me how to properly set the attribute so it can be accessed that way? if I try and use self[attr] = I get an unknown attribute error.
[01:33:07] sevenseacat: ftj: if I was doing it, I'd use something like CarrierWave to handle the file uploading, including the S3 integration
[01:33:19] sevenseacat: and not worry about it at all :D
[01:34:04] sevenseacat: MrPunkin: attributes['your_attribute_name'] ?
[01:34:20] sevenseacat: if its a db attribute
[01:34:32] ftj: sevenseacat I'm building this thing partly as a learning exercise for this kind of thing, but I'll definitely check out carrierwave (I've used paperclip once before)
[01:34:55] MrPunkin: sevenseacat: it???s not a DB one. That???s the problem
[01:35:07] MrPunkin: sevenseacat: any idea how I can set it for a non-DB attribute?
[01:35:18] sevenseacat: MrPunkin: then dont call attributes at all, just set/get the instance variable
[01:35:48] MrPunkin: sevenseacat: right, I???m using a gem though that needs access to this data and it uses [] on the object to get it. I???m not in a position to change that reference
[01:36:20] MrPunkin: that???s what I???d call it ;)
[01:36:49] sevenseacat: I'm not sure I understand the problem - your gem thinks you have a db field that you don't?
[01:37:07] sevenseacat: why isnt your gem using the accessors :/
[01:38:20] sevenseacat: I mean there's probably a way to make it work, but its hacking around a problem that sounds like it shouldnt exist
[01:38:25] MrPunkin: This gem is built to reference attributes on models changing. It???s the audited gem. I want two fields that aren???t persisted in our DB to be tracked as audited, however that means being able to reference the data via object[attr] which right now I can???t.
[01:39:31] MrPunkin: and the only reason I want them that aren???t in our DB to be tracked is because they are actually on a related ActiveResource model, not our local model. However, maybe it would be easier to simply create mimic columns on my local DB and update the ActiveResource model when those change, rather than creating non-persisting attributes on my local model.
[01:42:14] sevenseacat: https://github.com/collectiveidea/audited/issues/1 this discusses that same idea, a long time ago
[01:44:22] MrPunkin: sevenseacat: thanks. Doesn???t appear to have a solution though that made it.
[01:44:49] sevenseacat: it does talk about possible patches that work though, so maybe its worth putting together a patch and submitting it
[01:45:06] MrPunkin: I found a rather easy one I think.
[01:45:07] sevenseacat: because the gem really should be using the accessors
[01:45:09] MrPunkin: that directly addresses it.
[01:45:40] MrPunkin: https://gist.github.com/mrpunkin/0cc92b756783b81bad37
[01:45:58] sevenseacat: ah interesting
[01:46:02] MrPunkin: actually??? even better would be to use the getter rather than the instance variable
[01:46:34] sevenseacat: i have a feeling it might have unintended side effects for other code though
[01:47:24] MrPunkin: Maybe instead I???ll write an overwrite of their method to patch it to use the getter rather than []
[01:47:32] MrPunkin: that way it only affects the auditing part
[01:47:33] sevenseacat: that would be a better idea
[01:54:27] Etriaph: Is there anything that jumps out at you as odd at: https://gist.github.com/bewitchingme/56af531c5323e6adcef3
[01:55:59] Etriaph: What would that be specifically? :D
[01:56:00] sevenseacat: all of the t. calls, except timestamps
[01:56:17] sevenseacat: they should be flipped, ie. t.string :origin, afaik
[01:56:46] Etriaph: The hell? This was generated with a rails g model
[01:57:03] sevenseacat: http://guides.rubyonrails.org/active_record_migrations.html#creating-a-table
[01:57:12] Etriaph: Wait, I know what I did.
[01:57:17] sevenseacat: did you invert them when you called rails g?
[01:57:27] sevenseacat: i've done that before
[01:57:36] Etriaph: Been a few months since I've been sitting at a desk doing something, surgery
[01:57:51] Etriaph: Thanks for hitting me over the head haha
[01:58:03] ftj: So I'm defining my routes this way with Rails 4's fancy param: option
[01:58:04] ftj: resources :file_uploads, param: :uuid
[01:58:06] sevenseacat: np - had to double check myself by referencing the docs lol
[01:58:13] ftj: but when I redirect to @file_upload, it still tries to use the id
[01:58:20] ftj: not uuid
[01:58:33] sevenseacat: ftj: thats not what the param field is for
[01:58:50] sevenseacat: ftj: the param option means that in your FileUploadsController you'll have params[:uuid] instead of params[:id]
[01:59:10] sevenseacat: if you want to overwrite what gets used in generating the param, you have to overwrite to_param
[02:00:52] sevenseacat: ACTION is a fountain of pretty useless knowledge
[02:00:54] ftj: look at that little piece of magic. thank you! :)
[03:10:54] dandaman: question about angular and rails(forgive me btw, I'm still new to angular). I want to have a link_to my_model in one of my custom directives. Can I do this with angular or will I have to just build my own a tag and use a link passed into the directive?
[03:12:55] Radar: HELPA HS SPOKEN
[03:13:48] dandaman: Radar: yes to building the a tag myself?
[03:13:59] Radar: dandaman: Shrug. I don't know much about Angular.
[03:14:24] dandaman: ill go in #angularjs and ask
[03:48:34] Etriaph: OK. Quite confused now. I create an engine with rails plugin new <mod> --mountable, gem it in a fresh rails app using gem 'mod', path: '/path/to/gem' run bundle install and try to Mod::Model.new and I get https://gist.github.com/bewitchingme/6772cb34b4ef993cec0b
[03:48:51] Etriaph: Migration ran successfully after rake mod:install:migrations and rake db:migrate
[03:49:00] Etriaph: Can provide any code as needed.
[03:49:36] sevenseacat: how is Mod::Model defined
[03:52:36] Etriaph: https://gist.github.com/bewitchingme/5791c9023a1487fff434
[03:52:52] Radar: app/controllers/pages_controller.rb:3:in `placeholder'
[03:52:56] Radar: What is this
[03:53:09] Radar: Why do you have a field called class on your tabe?
[03:53:15] Radar: That would override Ruby's class method.
[03:53:25] Etriaph: Oh..............
[03:53:26] Radar: Which is Not A Very Good Idea (NAVGI)
[03:53:36] Radar: don't worry
[03:53:38] Etriaph: Radar, I could kiss you
[03:53:40] Radar: when I was new here I started a model and called it Thread.
[03:53:43] Etriaph: But I won't :D
[03:53:48] Radar: Etriaph: Just donate to my Paypal account instead? radarlistener@gmail.com
[03:53:51] Etriaph: Oy, that would hurt
[03:53:59] Etriaph: Perhaps :D
[03:55:17] hazelux: any vim users in here? Do you guys know how to change the highlight color in visual mode?
[03:56:38] lathiat: i know you can change between two modes, :set bg=dark or :set bg=light
[03:58:38] Etriaph: No wonder I'd get this ruby process that would keep running and running
[03:58:49] Etriaph: I made it mad
[04:10:11] pipework: Lol, imagine having to use something like MyAppNamespace::Class.select to get values.
[04:10:12] Etriaph: All is well now.
[04:10:29] pipework: Cause you certainly would have a fun time with #select
[04:10:35] pipework: Err, #class.
[04:55:29] VaibhavRajput: I have 'resources :signatures'. I want to add some parameter like :limit, :offset, :keyword to the 'index' only route. May I know how to do this?
[05:00:41] hazelux: VaibhavRajput: Are you trying to do filtering/search?
[05:03:06] hazelux: VaibhavRajput: you don't need to add it to the routes. You are probably looking for scopes: http://guides.rubyonrails.org/active_record_querying.html#scopes
[05:03:14] VaibhavRajput: hazelux, my url is signatures/foo/10/100 and I should be able to access params[:keyword], params[:limit] etc.
[05:05:30] hazelux: VaibhavRajput: the Railscast is a bit dated, but maybe you find it useful: http://railscasts.com/episodes/37-simple-search-form
[05:05:45] Etriaph: Get this (Could not find bcrypt-3.1.10 in any of the sources) when I try to perform: rails generate devise:install
[05:05:50] Etriaph: Anyone seen this issue before?
[05:05:58] Etriaph: (And I do have that gem installed.)
[05:06:55] hazelux: Etriaph: did you recently update your gems?
[05:07:13] Etriaph: I ran bundle install, completes with no issue
[05:07:45] Etriaph: Even shows bcrypt at that version level.
[05:08:03] hazelux: hmm. weird.
[05:46:48] Etriaph: Is it possible to render an action from an engine from a controller contained in the host?
[05:47:01] pipework: Etriaph: sure
[05:47:08] egray: hello, I have a form object of Contact::Ticket::Copyright, and i want simple_form_for to use input names of copyright[subject] etc, right now it generates from the class name, which is fine, but id prefer it to use the sorter name
[05:47:13] pipework: It might not be as straightforward as you'd like though.
[05:47:17] Etriaph: render :action => 'start', :controller => 'public' and then what?
[05:47:19] pipework: Your best bet is to probably not.
[05:47:44] pipework: Etriaph: Try it, look at source. If I had a bit more time, I'd halp, but the most I can do is confirm that it is within the realm of possibility.
[05:48:20] sevenseacat: you dont render actions; you render views
[05:52:09] Varun_krishna: Hi guys I am getting an Oauth2:Error whileusing google-oauth2 gem https://gist.github.com/Varun-Krishna-P/17f07f0da3bbfe1da8b0
[06:00:21] Etriaph: sevenseacat: I want to use the layout of the host with the output from an engine; is that possible?
[06:02:28] pipework: Etriaph: Yes!
[06:02:32] sevenseacat: i'm not sure.
[06:03:56] Etriaph: Without making XHR calls if possible :D
[06:06:07] Varun_krishna: rvanlieshout: Hi
[06:06:25] pipework: Etriaph: As long as your paths for looking up views/templates includes the host's app/views or app/views/layouts, respectively, you should be set.
[06:06:41] pipework: Though you may or may not want to investigate whether you need to stop calling isolate_namespace
[06:07:23] sevenseacat: that will be the problem i think - i dont know if the engine's view path will be in the main app's view lookup list
[06:07:52] Etriaph: Uh, it does.
[06:08:13] Etriaph: Apparently. I set root on the host to the root of the engine and it worked.
[06:08:21] Etriaph: 'mod/public#start'
[06:08:24] sevenseacat: then it should be straightforward, render the view you want to render
[06:08:39] sevenseacat: thats not what you asked
[06:08:51] Etriaph: No, it's not.
[06:08:58] sevenseacat: thats routing
[06:09:00] Etriaph: I'm trying to change it so I can use the host layout
[06:09:22] sevenseacat: you're looking at the wrong level
[06:09:55] Etriaph: If the engine could get a reference to the host application's layout I think it would work out fine.
[06:10:22] Radar: what's wrong with render layout: 'application' in your controller?
[06:10:41] Etriaph: Because application on the host and the mounted engine are different.
[06:10:43] sevenseacat: now you're looking at the entirely opposite side that you originally asked about
[06:11:09] sevenseacat: now you're asking to render an application layout from inside an engine, whereas before it was rendering an engine view from the main app
[06:11:16] Etriaph: sevenseacat: I know.
[06:11:30] Etriaph: But would the latter not be cleaner?
[06:11:32] sevenseacat: which do you actually want to do?
[06:12:02] Etriaph: I want to control layout from the host. Which side does the negotiating is what I'm trying to know how to do
[06:12:12] sevenseacat: theyre not equivalent, so cleanliness isnt really relevant
[06:12:57] sevenseacat: the engine is in control of rendering itself.
[06:13:11] xibalba: I'm reading what's new in rails 4.2 and in the section 2.1 Active Job I'm reading "Active Job passes object references as URIs (uniform resource identifiers) instead of marshaling the object itself." and wondering what problem does this solve?Is there a particular issue here with marshalling? Newb here so I'm not certain
[06:15:47] solars: hi, I need to copy datamapper records to an active record model (1.5 million). This seems to be terrible slow and takes 2 days. Is there a way I can speed things up or do I have to copy in sql?
[06:16:29] rvanlieshout: how often do you need to do that solars?
[06:16:48] solars: rvanlieshout, once, but I don't have much time left
[06:17:10] rvanlieshout: and how long are you already working on making this faster?
[06:17:11] rhizome: connection_execute
[06:17:51] solars: rvanlieshout, I'm not, that's why I'm asking
[06:18:04] solars: the question is if there is a way on the rails side
[06:18:09] mc: copying data from a sql through one abstraction method via another abstraction method to sql again...
[06:18:12] solars: that helps significantly
[06:18:33] solars: mc, sorry?
[06:19:00] mc: i'm just thinking, because i dont get what you're actually doing there
[06:19:00] rhizome: solars: you want to get as close to copying tables in raw sql as possible, it's about 500x faster than manipulating rails models.
[06:19:22] Radar: solars: use COPY from PostgreSQL
[06:19:31] Radar: or ... whatever it is in MySQL. Is it LOAD DATA INFILE?
[06:19:44] rhizome: sounds like they need some ETL logic in between
[06:19:50] solars: Radar, yes of course, but that was not my question
[06:20:16] Radar: solars: Sorry, I misread your question as wanting to import data very quickly into a database.
[06:20:24] solars: there are some ruby filters, otherwise I wouldn't do it like this, the question is just if I can speeds things up, by for example not preloading the complete model, etc
[06:20:26] Radar: Clearly that is not what it wrote, even though that's what it looks very close to being.
[06:20:40] mc: designing AR v1.0 to match the DM models and then using migrations to adapt to AR 2.0 models wouldnt have been a good path?
[06:20:46] solars: but I guess there are not too many ways, so I have to sort that out and do differently
[06:20:47] Radar: solars: define "preloading"
[06:21:45] solars: preloading in the sense of loading collections into ruby objects, collection size, chunk size etc. I'm already using the DM in chunks method but it's extremely slow
[06:21:51] sevenseacat: personally, i think if its really a once-off import, the time doesnt really matter
[06:22:16] solars: sevenseacat, you are right yeah, but in this scenario it does
[06:22:18] sevenseacat: that being said, it does seem awfully slow
[06:22:55] Radar: 2 days is a bit shit.
[06:23:00] solars: I never would have thought that loading a DM model and saving it in an AR model is so extremely slow
[06:23:05] sevenseacat: got some code or something so we can see why its so slow?
[06:23:12] solars: there is nothing else it does right now besides setting a var
[06:23:26] sevenseacat: have you profiled it to see why its so slow?
[06:23:32] mc: FAWIW it could even be one of your databases that is slow. or the network connectivity there
[06:23:36] solars: I reduced it to copying attributes, there is nothing more in the code
[06:23:38] rhizome: seriously, my 500x number comes from experience
[06:23:56] sevenseacat: it could be just about anything
[06:24:15] mc: and even if you need logic the road of (ab)using views may get you home quicker. atleast if its the same server
[06:24:19] sevenseacat: rhizome: and i'd believe it
[06:24:50] solars: I think I'm better off just using sql .. instead of tweaking around
[06:25:03] solars: if others have the same experience
[06:25:05] Radar: solars: You might want to go with something lower-level, like the Sequel gem
[06:25:23] solars: hm yeah but then I can as well use sql
[06:25:24] sevenseacat: if you dont need the AR model for anything, take it out of the equation.
[06:25:28] solars: and loop over the result once at the ende
[06:25:29] rhizome: sequel is going to have much more of a learning curve than working it out in sql
[06:25:36] Radar: solars: That would allow you to establish a connection to both DBs at the same time, perform the manipulation you want, and insert data into Database #2.
[06:25:44] mc: so again, why are you doing this? copying to another server? changing structure? something else?
[06:25:45] Radar: rhizome: Sequel is easy to learn.
[06:25:52] solars: luckily it's in the same db
[06:25:56] solars: just two tables
[06:26:00] rhizome: i've used it. i'm just comparing.
[06:26:33] sevenseacat: this is why i dont help people who give you 10% of their requirements
[06:26:58] Radar: solars: INSERT + SELECT combo in raw SQL then
[06:26:59] solars: sevenseacat, there needs to be a transformation, and it cannot happen on the same table. the transformation can be done with advanced sql calculations though, that's why it is an option
[06:27:00] Radar: problem solved
[06:27:02] Radar: next problem
[06:27:05] mc: or ask a question without any background why they want to go that road
[06:27:08] sevenseacat: Radar: indeed.
[06:27:25] rhizome: in other words, the "T" in "ETL"
[06:27:51] solars: guys, as I've said there are filters on the app, that I would like to use, but apparently cannot
[06:28:10] rhizome: what do you mean by "filters?"
[06:28:21] solars: before/after filters that transform the data
[06:28:33] pipework: I don't think we're all talking about the same thing.
[06:28:54] solars: nevermind, I'll write the calculations in sql
[06:29:01] rhizome: you will be better served in this one-time activity by translating those in to raw sql
[06:29:27] solars: rhizome, thats what I was talking about yea
[06:47:18] norc: Hi. Im running Rails 4.2.0. I made a small change to a view, now the whole server seems to be busted. When I try to access localhost:3000/ the webpage says "We're sorry, but something went wrong.". The only thing the logs say is: "Started GET "/" for fe80::1%lo0 at 2015-04-16 08:45:51 +0200"
[06:47:24] norc: No error messages to be found anyhwere.
[06:47:36] norc: I tried stopping spring / server and restarting it, but nothing changed.
[06:48:03] norc: The entire rails application does not work anymore, with no error messages or exceptions to be seen anywhere.
[06:48:17] rvanlieshout: norc: running in production?
[06:48:23] norc: rvanlieshout: Development with WEBrick
[06:48:23] rvanlieshout: and what if you revert that change?
[06:48:34] norc: rvanlieshout: Tried, still not working anymore
[06:48:52] rvanlieshout: and you're unable to access the server if you've stopped it?
[06:49:01] norc: rvanlieshout: Correct.
[06:49:14] norc: Just results in a timeout if I stop the process.
[06:49:36] norc: Err, connection failed actuallz
[06:50:02] rvanlieshout: and if you start it in the foreground again and access it with curl
[06:50:54] norc: rvanlieshout: Okay everything is working again...
[06:51:15] norc: I think this might be the time where I look into deleting all the cache files in my browser and the rails server.
[06:53:18] norc: rvanlieshout: Should I dismiss this?
[06:57:36] norc: rvanlieshout: This sudden bizarre behavior that appeared and disappeared
[06:58:01] norc: Because I cannot find any details as to what happened or went wrong anywhere.
[06:58:03] toomus: HI. Is it possible to make something like helper function, but with some javascript code inside, to use in js.erb files?
[06:58:59] norc: toomus: Just define your javascript functions in assets/javascript/
[06:59:57] toomus: ahh ok :)
[07:06:16] rvanlieshout: norc: i wouldn't worry about it too much.. unless it happens more often
[07:29:08] morenoh149: where are a project's gems stored?
[07:29:50] norc: rvanlieshout: And I just caued the issue again.
[07:30:03] rvanlieshout: morenoh149: bundle show <gem>
[07:30:35] rvanlieshout: norc: if you get an sorry something went wrong issue in development something really is wrong
[07:30:44] rvanlieshout: it's the server failing in some way
[07:30:56] norc: rvanlieshout: So that would be a WEBrick issue then?
[07:31:46] norc: (I mean the really discerning thing is nothing putting out any exception / error / warning message. STDOUT/STDERR is empty (aside from the Started GET "...")
[07:31:54] norc: Log files are empty
[07:32:41] rvanlieshout: try it with a different server
[07:32:44] rvanlieshout: something like 'passenger start'
[07:33:27] norc: rvanlieshout: I think I just narrowed it down.
[07:48:29] jrnkk: Hey guys, I have a question about concurrency in relation to ActiveRecord, especially when running N+1 rails threads where I do Model.find_or_create_by() , sometimes this results in multiple records with the same attributes because they get executed in parallel, how would I go about solving this?
[07:51:57] krz: jrnkk: you want to make sure the execution is unique?
[07:52:17] tbuehlmann: jrnkk, sounds like a race condition, rails won't save you from that. in that case you have to insert some constraints in your database to avoid creating invalid/double records
[07:52:19] krz: run it in a single instance. perhaps a cron instance
[07:52:29] jrnkk: @krz I want to make sure that find_or_create_by with that particular hash of attributes doesnt happen more than once
[07:52:41] krz: jrnkk: then run it in a single instance
[07:53:27] krz: you can also consider applying a mutex on the block of code
[07:53:57] jrnkk: @krz single instance won't cut it... too slow processing the queue, @tbuehlmann 's approach solving this in constraints on the postgres level might be a solution
[07:54:32] krz: how big is the queue?
[07:54:51] jrnkk: think 1000 a sec
[07:55:17] krz: 1000 records?
[07:56:15] jrnkk: 1000 messages added to the queue a sec, each message will generate around 4 records but some messages have influence on existing records (think measures in timeframe reports)
[07:56:48] krz: if you want to stick on the app level. i.e rails. you can go towards a state approach
[07:57:03] krz: you keep a record of the state on the record. then throw it to a background process
[07:57:10] krz: i.e. sidekiq
[07:57:55] krz: then you have a cron job that executes every minute to check for records with a specific state and queue the job via sidekiq
[07:58:04] Axighi: anybody see me ?
[07:58:13] sevenseacat: Axighi: howdy.
[07:58:25] jrnkk: mmm, not sure if I know what you mean. I need to uniquely create the records, not sure how keeping state on those records might help
[07:58:26] krz: perhaps you can have the cron job execute every 30 secs. you might need to performance test
[07:58:54] krz: oh you are creating.. kk
[07:58:55] jrnkk: right now it's 'solved' by a cron job that checks for double records
[07:59:57] jrnkk: going to test with the db constraints first now, will report back ;) thanks guys.
[08:00:42] krz: jrnkk: also for your consideration: https://github.com/kenn/redis-mutex
[08:00:47] krz: and https://github.com/dv/redis-semaphore
[08:01:18] jrnkk: thanks, using sqs w/ shoryuken at the moment
[08:02:09] jrnkk: mutex'es will solve the problem, but at a cost, which is handling multiple messages at once
[08:02:17] krz: oh. nice to see some ruby love for aws sqs
[08:02:39] krz: jrnkk: and some integrity checks every so often, to remove stale locks
[08:03:10] zvive: Say I want to tie two users together as husband/wife for instance... would I do something like this: belongs_to :spouse, :class_name => 'User', :foreign_key => :spouse_id ?
[08:03:17] jrnkk: thanks krz for your help so far :)
[08:03:47] krz: zvive: sounds like you need a many to many self referencial table
[08:03:58] aawe: zvive: Yes, but I hope you never use that relation in a real app.
[08:04:09] krz: assuming a couple can be remarried more than once
[08:04:20] aawe: married monogamy is not the only alterntive
[08:04:21] tbuehlmann: zvive, either that or create an association table for that. using that you could enhance it later on. for example a mother<-->daughter relation using that table
[08:04:59] zvive: Well, it's a wedding app... I could just join everything on the wedding event, so that the wedding joins both spouses but if they marry later on, they would be tied to the other spouse through another wedding event.
[08:05:32] krz: referencing*
[08:13:23] Axighi: I am back
[08:20:11] vasilakisFiL: not rails related, but how can I understand if a timestamp is in utc or has a timezone? 2012-08-22T13:20:00.001 <--- does this timestamp has a timezone or is it in utc? what T means in the middle?
[08:20:58] sevenseacat: that time does not specify a timezone.
[08:21:39] neanderslob: hi all, I'm attempting to specify special css for particular views. I found a way here on stack overflow: http://stackoverflow.com/a/15715767/2540204 but I'm finding it a bit confusing
[08:22:10] neanderslob: does anyone have any experience in (or recommendations for) doing this?
[08:22:35] workmad3: vasilakisfil: !g iso8601
[08:23:25] emilkarl: What can be wrong if Rails 3 doesnt update style changes on reload in dev mode?
[08:24:23] workmad3: emilkarl: two things - either sprockets has gotten confused and thinks the file hasn't changed (so it's being served from sprockets cache)... run 'rake tmp:clear' to clear that out, restart server and try again
[08:25:10] emilkarl: hmm???that didnt work
[08:25:12] workmad3: emilkarl: or 2 - you've made a typo or other mistake (such as not enough specificity in the selector) in your style, so it's not getting applied by your browser
[08:25:48] emilkarl: well the changes isnt in the file
[08:25:50] aawe: or 3. you have precompiled assets in public/assets
[08:25:54] aawe: remove them
[08:26:03] emilkarl: i remove public/assets folder
[08:26:11] emilkarl: nothing happened there
[08:27:07] sevenseacat: are you looking at the right file?
[08:27:19] emilkarl: I addad a bg-color to an element
[08:27:23] sevenseacat: how have you verified that?
[08:27:23] emilkarl: which is visible in the browser
[08:27:36] emilkarl: and then I removed that same bg and its still there...
[08:27:44] emilkarl: i am sure of it...
[08:27:46] sevenseacat: did you save the file?
[08:28:00] emilkarl: it has to be something with the cache.
[08:28:05] emilkarl: but I cant fingure out what
[08:28:05] sevenseacat: then clear it
[08:28:09] emilkarl: rake tmp:clear
[08:28:13] emilkarl: should do it right=
[08:28:34] emilkarl: this one? rake assets:clean
[08:28:46] sevenseacat: that will remote public/assets
[08:29:17] emilkarl: but nothing else
[08:29:57] emilkarl: still notjing
[08:30:49] emilkarl: it seems to be that it is an all.css file
[08:30:52] emilkarl: and and application.scss
[08:31:00] emilkarl: I made that changes in application.scss
[08:31:24] emilkarl: and looking at the compiled css, application is updated but all.css includes the old style?
[08:31:50] sevenseacat: all.css isnt something rails generates by default
[08:31:54] sevenseacat: so whats in your all.css ?
[08:31:56] emilkarl: http://pastie.org/10095569
[08:32:10] emilkarl: nope it omes from a spree theme.
[08:32:46] emilkarl: my app includes both all.css and application.scss
[08:32:51] sevenseacat: so you're including all of your stylesheets twice?
[08:33:01] sevenseacat: or you're writing styles that are getting overwritten by all.css ?
[08:33:02] emilkarl: it seems so
[08:33:26] emilkarl: seems like all.css doensnt update it self everything application.scss is changed.
[08:33:36] sevenseacat: all.css has nothing to do with application.css
[08:34:32] emilkarl: looks like all only is update when I run assets:precompile
[08:34:46] sevenseacat: all will update itself whenever you change any of the files it depends on.
[08:34:51] sevenseacat: dont precompile your assets in development.
[08:34:58] sevenseacat: or you'll just run into more problems
[08:35:15] aawe: emilkarl: now, because you have run precompile, you have a public/assets folder
[08:35:15] sevenseacat: now go and clear them again
[08:35:31] emilkarl: no I have cleared
[08:35:37] emilkarl: its strange
[08:35:59] emilkarl: application.css is only included if I require tree in all.css
[08:36:06] sevenseacat: you're expecting this all.css to magically include your application.css that is in an entirely different place
[08:36:26] emilkarl: let me explain
[08:36:30] aawe: emilkarl: just open your public/ folder and see for yourself
[08:36:34] aawe: the assets folder is there
[08:36:39] emilkarl: yes I can see it
[08:36:46] sevenseacat: great, now delete it.
[08:36:58] emilkarl: it doesnt matter???.listen 1 sec please
[08:37:32] aawe: "please help me solve this problem without using the real solution, please let me explain why I will not try the real solution"
[08:37:45] emilkarl: all.css includes all the css from application.scss inside itself. But not with my latest updates, it also makes application.scss load by itself.
[08:38:10] sevenseacat: no, I'm stepping out of this conversation.
[08:38:18] emilkarl: if I remove require_tree . from all.css, it doesnt load anything from application.scss
[08:38:20] sevenseacat: minaswan and all.
[08:38:39] emilkarl: not in itself or as a single file
[08:39:35] emilkarl: I havent runned precompile
[08:39:36] aawe: emilkarl: sprockets works like that when you have a public/assets directory
[08:40:37] aawe: just remove it
[08:40:40] emilkarl: so it sohuld include an old version application.scss inside it self and then application.scss (the updated one) as a single file?
[08:40:50] emilkarl: just remove all.css from assets?
[08:41:11] aawe: just remove public/assets
[08:41:20] emilkarl: didnt make any change
[08:41:22] emilkarl: same result
[08:41:56] emilkarl: I have no public/assets folder anymore but still the same result
[08:43:08] aawe: what is this result?
[08:43:29] emilkarl: same as before
[08:43:37] aawe: have you restarted the server after removing the public/assets folder?
[08:43:54] emilkarl: now it works
[08:43:57] emilkarl: after 3 times
[08:44:02] emilkarl: with the same process?
[08:44:19] emilkarl: I tried rake assets:clean tmp:clear
[08:44:25] emilkarl: nothing happened
[08:44:30] emilkarl: remove the folder by hand
[08:44:54] emilkarl: now lets see if I make a change, if changes or stays...
[08:45:15] emilkarl: and now it changes
[08:45:57] emilkarl: it doesnt include the application.scss styles into all.css anymore either
[08:54:48] op84: hi there - i created a js.erb file which i include as my first required js file??? i???d like to set all global variables like lets say rootPath = ???<%=root_path%>??? in there??? but i get an exception that its not defined?
[09:00:35] mlangenberg: Does SecureRandom.uuid provide enough ???uniqueness??? to use as filenames in for example file uploads?
[09:01:22] thebastl: can anybody tell me what the technical reason for the asset pipeline getting rid of the folder structure (merging folders and subfolders images/bla javascripts/bla) is? (its clear in cases where the files get merged)
[09:02:02] workmad3: mlangenberg: quick rephrase - "Does the UUID algorithm that statistically isn't going to generate a single collision even if we were generating thousands of them a second between now and the heat death of the universe provide enough uniqueness?"
[09:03:06] tbuehlmann: workmad3, luvit
[09:03:07] mlangenberg: workmad3: lol, well it???s only 122 bits, right?
[09:03:39] workmad3: mlangenberg: yes, which is a shit-load if all you want is uniqueness :P
[09:05:12] jrnkk: http://stackoverflow.com/questions/1155008/how-unique-is-uuid
[09:06:06] jrnkk: key phrase: "only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%"
[09:17:53] Pupeno: Does anybody know if EngineYard support hosting Rails app with a naked domain (that is, unlike Heroku... yeah, I know it can be done, but with horrible limitations)?
[09:37:50] arup_r: How can I make url inside mailer views.. I have to create order links inside the email templates.. Like this -
[09:37:57] arup_r: I have only the order number
[09:38:07] arup_r: access inside the email view template
[09:38:22] arup_r: How would I add this part -- ?
[09:42:17] mikecmpbll: arup_r: order_url(@order)
[09:42:34] arup_r: If I call `app.root_url` in my rails production console getting NoMethodError: undefined method `root_url' for #<ActionDispatch::Integration::Session:0x0000000888e958>
[09:42:41] arup_r: http://stackoverflow.com/questions/1397644/testing-routes-in-the-console
[09:42:46] arup_r: I thought I'll use it
[09:43:00] platzhirsch: Is there a way to make def show; @server = Server.find(params[:id]); end redundant in Rails 4?
[09:43:05] arup_r: ok mikecmpbll : let me try
[09:43:07] platzhirsch: so I don't have to write it? ;)
[09:43:12] norc_: Hi. Is there any OSX user around that could quickly help me reproduce a bug?
[09:43:26] Radar: platzhirsch: No, Rails will not write your code for you.
[09:43:29] Radar: platzhirsch: You can put it in a before_filter
[09:43:33] Radar: norc_: Yes.
[09:44:08] platzhirsch: Don't say Rails will not write your code for you. It does
[09:44:24] norc_: Radar: Comment out the ipv4 entry for your localhost and the ::1 localhost entry of your /etc/hosts.conf, start any rails server at localhost and try to access it.
[09:44:46] Radar: seems bad
[09:45:02] Radar: norc_: Shouldn't that break?
[09:45:24] Radar: norc_: works for me even after commenting out
[09:45:33] arup_r: I don't have access to the `app` object in my console.. Why? :(
[09:45:54] Radar: arup_r: steps to reproduce or ban
[09:46:01] norc_: Radar: Curious. Are you using webrick? Which version?
[09:46:14] arup_r: Radar: ban means ?
[09:46:23] mikecmpbll: arup_r: seems like you do have access to it
[09:46:25] norc_: Radar: It shouldnt break, but its breaking when it uses fe80::1 for me
[09:46:31] Radar: +b arup_r!*@*
[09:46:34] Radar: arup_r: That is what ban means.
[09:46:37] Radar: -b arup_r!*@*
[09:46:53] Radar: arup_r: I am tired of you asking for help in here and providing no details.
[09:46:54] arup_r: Radar: what's the point you have to ban me ?>
[09:46:58] Radar: Steps to reproduce, or ban.
[09:47:08] mikecmpbll: arup_r: provide more information up-front, rather than having to be asked for it.
[09:47:25] arup_r: Radar: can you show me the ban policies you write.. Official link pleas..
[09:47:35] mikecmpbll: arup_r: see topic
[09:47:46] helpa: If you're going to tell someone to "Just google it" or "RTFM", tell them what terms to use on Google exactly, or link them to the place in the documentation.
[09:47:53] helpa: Don't piss off Radar.
[09:47:56] helpa: Radar is the GodKing of #rubyonrails. Obey him and all shall go well.
[09:48:00] Radar: There you go.
[09:48:08] arup_r: https://gist.github.com/aruprakshit/73f2934808d0236f6e3a
[09:48:09] Radar: Now can we see the steps to reproduce the problem please?
[09:48:23] arup_r: Radar: you just shown that you have power to ban me..
[09:48:24] Radar: Looks like you have access to app just fine.
[09:48:32] helpa: Next question, please!
[09:48:41] arup_r: Why getting the error ?
[09:48:44] Radar: There's no root_url defined for your app probably because it's in Spree.
[09:48:56] Radar: And probably because you didn't define a root for your app in config/routes.
[09:49:03] Radar: see you all tomorrow :)
[09:49:33] arup_r: Radar: good night
[09:50:23] arup_r: Don't say ever.*ban* if someone ask questions..
[09:50:35] arup_r: This channel is to ask questions only
[09:50:52] arup_r: if you have problem down it.. someone will make a clone line this
[09:51:15] mikecmpbll: arup_r: you need to provide better information up-front. consider writing your questions out in one go.
[09:51:54] arup_r: mikecmpbll: yes.. I know. I gave the SO link.. which exactly I tried in my rails console.. and didn't work.. What else I would provide...? tell me..
[09:52:17] arup_r: What I have shared I know that's all.. If I had I would..
[09:52:43] arup_r: *banning* for too many questions doesn't make any sense..
[09:53:57] arup_r: someone writing books.. to teach.. and when come back to ask if he/she with confusions.. then the author itself has the prtoblem..
[09:54:05] arup_r: this is kind of......
[09:54:11] arup_r: anyway leave it..
[09:54:57] mikecmpbll: i think it was entirely based on :[10:45:34] <arup_r> I don't have access to the `app` object in my console.. Why? :(
[09:55:04] arup_r: mikecmpbll: I will try now your suggestion.. Lets see .. it seems will worj
[09:55:13] arup_r: Its ok.. mikecmpbll
[09:55:16] mikecmpbll: in isolation, this doesn't constitute a question
[09:55:23] arup_r: that came under pressue
[09:55:55] arup_r: mikecmpbll: humm.. context was there... that's not the first question..
[09:56:02] arup_r: leave it..
[09:56:06] arup_r: be happy..
[09:57:14] arup_r: bannig someone for asking too many questions insulting... and when it comes from Author.. insult *reversed* back..
[09:57:20] mikecmpbll: [10:56:03] <arup_r> leave it..
[09:57:26] mikecmpbll: [10:54:12] <arup_r> anyway leave it..
[09:57:47] arup_r: I am trying to forget.. but not.. :( But I'll now
[09:59:07] mikecmpbll: i'm weighing up writing an api for this database or just connecting each app directly to it ..
[09:59:33] Pupeno: Is it me or is Nine Fold no longer Rails centric?
[10:00:34] mikecmpbll: Pupeno: to a degree, i think
[10:01:03] mikecmpbll: "We will be sunsetting our Rails app deployment feature set [...]" https://ninefold.com/news/2015/02/17/containers-servers-and-ninefold/
[10:01:35] mikecmpbll: i've never used it though.
[10:01:36] Pupeno: mikecmpbll: ah... good find. Thanks.
[10:02:00] Pupeno: I used them once, I like them... I suppose now it's just choosing between Heroku and Engine Yard
[10:02:42] mikecmpbll: or start using containers :p
[10:05:33] arup_r: mikecmpbll: I have this <a href=""><%= @order.state == 'canceled' ? 'cancellation' : 'return' %></a> ... How would I use the order_url(@order) ?
[10:06:06] arup_r: in href I tried href="#{order_url(@order)}"
[10:06:23] arup_r: didn't work..
[10:06:42] mikecmpbll: arup_r: not really a great way, but what did that give you?
[10:06:48] mikecmpbll: shoulda werked.
[10:07:14] arup_r: It seems string didn't interpolated..
[10:07:21] arup_r: what's the otherway
[10:07:53] mikecmpbll: <%= link_to @order.state == 'canceled' ? 'cancellation' : 'return', order_url(@order) %>
[10:09:56] arup_r: ok.. My brain stopped working somehow.. Really upset.. :( mikecmpbll: thanks
[10:10:10] mikecmpbll: heh, can happen.
[10:10:22] norc_: Since the other guy hasnt responded anymore, Ill restate my question.
[10:10:26] mikecmpbll: mine too, because i thought yours should've worked
[10:10:39] mikecmpbll: when obviously it wouldn't have
[10:10:43] norc_: Anyone around with OSX who can help me quickly reproduce a problem? (Preferrably with Rails 4.2.1)
[10:13:45] universa1: norc_: it would help if you'd say what your problem is...
[10:14:05] Otterpocket: If I am using sti and I have Animal < Dog and I want my Zoo to has_many animals does the has_many only need to specify has_many :Animals ?
[10:14:38] universa1: Otterpocket: so animals are subclasses of dogs?! weird biology you've there.
[10:14:46] mikecmpbll: norc_: yeah, you're not really giving anyone any emotional investment in your problem :p
[10:15:18] Otterpocket: universa1, no sorry other way round lol
[10:15:19] arup_r: mikecmpbll: thanks it worked
[10:15:24] mikecmpbll: arup_r: great, no problem.
[10:15:38] norc_: universa1: Alright. Id like you to force OSX to resolve localhost to the fe80::1%lo0 only, bind a webrick server to localhost
[10:15:45] norc_: and access it with your webbroser.
[10:16:03] norc_: in development mode
[10:16:16] universa1: norc_: why should i do that?
[10:16:44] universa1: norc_: again: waht is the problem?
[10:16:47] norc_: For me it ends up showing "We are sorry something went wrong" (In development mode!), showing absolutely no error logs in STDOUT/STDERR either.
[10:17:07] arup_r: one more question.. How would I give my static pages link ? like this
[10:17:07] universa1: norc_: so you did that with an empty app?
[10:17:14] norc_: And I have narrowed it down to only occur when requests are piped through that IPv6 address (which happens randomly with the other entries due to round robin behavior)
[10:17:19] norc_: universa1: Yes.
[10:17:20] mikecmpbll: arup_r: same way
[10:17:25] arup_r: inside the mail view templates
[10:17:43] Otterpocket: universa1, I'm assuming I dont have to specify has_many :dogs, has_many :cats etc ?
[10:17:43] mikecmpbll: arup_r: use the route helper for your static pages
[10:18:03] universa1: Otterpocket: !try --- but yes, specifying has_many :animals should be enough.
[10:18:03] helpa: Otterpocket: Why don't you try it and find out for yourself?
[10:18:21] norc_: universa1: Things work fine then ::1 is used or But when a requests comes in through fe80::1%lo0, everything breaks without showing any details as to where, why or what.
[10:18:39] Radar: arup_r: For the record, it's in the channel rules that you MUST provide good information when asking questions.
[10:18:40] norc_: (That address doesnt make much sense really, but it is a default localhost address in OSX)
[10:18:40] universa1: norc_: only with webrick?
[10:18:40] Radar: arup_r: !rule3
[10:18:40] helpa: arup_r: Clearly explain what is happening and create a Gist (http://gist.github.com), (formatted neatly please: http://bit.ly/1q75oia) of the code that is causing the problem you are encountering, as well as any useful output like stacktraces.
[10:19:06] norc_: universa1: I can try unicorn and see what happens then.
[10:20:01] norc_: universa1: Though I expect the issue to be in webrick, since it never invokes the controllers in my applications.
[10:20:09] norc_: No routing is done
[10:20:18] norc_: It just gets stuck on accepting the HTTP request.
[10:20:32] universa1: norc_: nobody uses webrick (chuckle) ;)
[10:21:32] universa1: webrick is only used because it's there by default from ruby stdlib, but it is not recommended for anything more than a plain hello world app ;)
[10:22:00] norc_: So unicorn/puma for development?
[10:22:00] mikecmpbll: eh, it serves me fine for nearly everything i need in dev :)
[10:22:14] norc_: Because Im just talking for development here.
[10:22:16] universa1: norc_: whatever you use in production ;)
[10:22:24] norc_: I stage and deploy to an apache proxy with unicorn behind it.
[10:22:36] universa1: norc_: so i would use unicorn in dev, too
[10:22:42] Radar: +1 unicorn in dev
[10:22:56] norc_: Either way, Im gonna narrow down this bug because its a serious one.
[10:22:58] vedu: Hello. I have a rails app that I use an API. on 404, 500 errors the HTML error page is displayed. I would rather want a json response
[10:23:08] norc_: There is no reason for webrick to possibly not even work with a simple hello world app.
[10:23:11] Radar: vedu: !ncnh
[10:23:11] helpa: vedu: If you don't provide any code, it becomes really difficult for us to help you. Providing code to reproduce the problem increases your chances of getting great, accurate help immensely.
[10:23:26] Radar: I would expect you to know better by now, vedu .
[10:24:27] norc_: Alright Ill try out unicorn and come back. Modifying the hosts file will disconnect me for a short while (OSX for the win!), so brb
[10:25:13] universa1: norc_: currently not at home, so no mac ;)
[10:25:14] mikecmpbll: can't really see what code would be relevant to that question.
[10:26:42] mikecmpbll: vedu: there's a couple of approaches (that i know of), you can change the middleware that handles exceptions and make it route through your app, then provide routes & controller for errors, or you can use rescue_from in your ApplicationController
[10:27:54] vedu: mikecmpbll: oh. nothing as simple as changing the public/404.html
[10:29:06] mikecmpbll: vedu: in that case you'd still be returning html. both options i presented are easy to do though.
[10:29:17] mikecmpbll: there may be other ways i don't know of.
[10:30:40] norc: universa1: Alright unicorn just doesnt work with the fe80::1%lo0 as expected. (How this works at all gives me Apple headaches).
[10:30:52] vedu: mikecmpbll: yeah true. just found a SO answer. thanks :)
[10:31:03] norc: So its definitely webrick related.
[10:42:00] gaussblurinc1: hi! does anybody use heroku for rails apps? I confused with async in it, how to configure rails app on heroku for async request handling
[10:43:26] doge__: nope just you
[10:45:27] gaussblurinc1: doge__: well, which service you use for apps deployment? your own server machine?
[10:47:12] doge__: gaussblurinc1, could you be any more spesific about the problem you are having
[10:47:47] doge__: "I'm confused" doesn't say much and we don't know what you have tried already
[10:56:44] gaussblurinc1: doge__: I have two 'dynos' workers configured as: web 'bundle exec unicorn -p $PORT -c ./config/unicorn.rb', not sure that their count can dramatically increase app performance
[11:06:32] gaussblurinc1: doge__: and the main problem is New Relic metrics Request queueing that takes too much time
[11:22:43] shortCircuit__: is there any way I can use the bootstrap styles inside public/index.html in rails without accessing the cdn links, I mean normally like bootstrap is included with a stylesheet tag in application.html.erb
[11:31:27] norc: How can I get the action in a callback for before_action?
[11:44:25] norc: Nevermind figured it out. action_name is what I want. :)
[11:53:26] cheeti: hi, can u tell me the htaccess path in rails 4?
[11:59:10] shortCircuit__: when I do <link rel="stylesheet" href="vendor/assets/bower_components/pure/pure-min.css" type="text/css"/> in public/index.html I get routing error :(
[11:59:50] universa1: shortCircuit__: that is because you don't have a vendor/assets folder under public.
[12:00:11] cheeti: hi, can u tell me the htaccess path in rails 4?
[12:00:19] universa1: cheeti: what?!
[12:01:01] tbuehlmann: I agree, what?!
[12:01:11] cheeti: universa1 htaccess path in apache, i want to edit that for IP Canonicalization Test
[12:01:53] shortCircuit__: I tried ./ and ../ and ../ ../ nethier of them were working I beileve the correct one was ../vendor
[12:02:10] universa1: shortCircuit__: you're doing it wrong.
[12:02:36] universa1: shortCircuit__: use the asset pipeline. or put files directly into the public folder.
[12:03:08] shortCircuit__: ok , I will try the asset pipeline. first.
[12:03:10] universa1: cheeti: still what? rails does not use .htaccess.
[12:04:45] cheeti: universa1 i want redirect my website when user type my website ip in addressbar, how it is possible?
[12:05:00] universa1: cheeti: you do not need .htaccess for that
[12:05:15] universa1: cheeti: that is something you can directly do in your apache vhost, where you proxy off to rails.
[12:05:39] solars: hi, if I want Rails.logger.error to also forward to Rollbar.error - is there a built in way/setting how to append this or should I just extend the rails method?
[12:05:44] universa1: cheeti: you should be able to do some request host checking there.
[12:06:00] cheeti: universa1 could you please tell me how?
[12:06:04] universa1: solars: you would extend / replace the current Rails.logger
[12:06:11] shortCircuit__: daaa, gosh, I will put the folder under public
[12:06:14] universa1: cheeti: no. i don't use apache, but google should have it.
[12:06:19] solars: universa1, alright, thank you
[12:06:20] universa1: shortCircuit__: why?
[12:06:27] cheeti: universa1 ok thanks
[12:06:51] universa1: shortCircuit__: what have you tried?
[12:07:30] universa1: shortCircuit__: <%= stylesheet_link_tag "pure-min" %> <-- guessing here.
[12:08:45] shortCircuit__: umm, well, I am inside public folder.. and a simple index.html file. I can't do link_tag .. can I use .html.erb in public folder ?
[12:09:03] universa1: shortCircuit__: what the hell are you doin?!
[12:09:17] shortCircuit__: well, I will tell you then
[12:13:19] shortCircuit__: I have a task of bridging angularjs (and grunt) with a simple rails application. and there are three possible ways I have thought off and presented it to my senior. 1) place all the files in public directory and use the existing api . 2) configure sprockets to serve angularjs (dunno how if possible) 3) turn off sprokets and use grunt for everything (dunno how) .. so I was trying the first one.. I took a sample application with article cevent
[12:15:23] shortCircuit__: and my brain is about to explode, because I am sweating sitting in an AC room at 19degree
[12:16:43] universa1: shortCircuit__: you can incldue angularjs with rails using the asset pipeline, but you wouldn't need grunt anymore than.
[12:17:18] universa1: shortCircuit__: you could keep the angularjs app as a separate project, independent of rails
[12:18:19] shortCircuit__: I have done one thing previously, I ran a rails app on a separate server and angular on a separate server. but then there's cors but more imortantly there are two servers to maintain
[12:18:49] shortCircuit__: so now I have to make two versions of the same application, one with sprockets and one with grunt
[12:19:00] universa1: shortCircuit__: for the second part i think you would just place everything required for the angularjs app into the public folder, and have apache / nginx serve it, and proxy everything api related to the rails version
[12:19:08] universa1: shortCircuit__: why do you have to make two versions?
[12:21:26] shortCircuit__: its a demo, I mean once we will have the sprockets completely turned off and let grunt do all the precompiling.. and in another I have to use sprockets and then I guess, the application.html will have angular like syntax and inside javascript I will have angular controllers and stuff..
[12:22:22] shortCircuit__: oh three actually, because this BS i have to put up with, so that angular and rails runs under the same server but are two separate applications.
[12:22:22] universa1: shortCircuit__: decide for one way to develop the stuff. to me both sound somewhat reasonable, though i've only used the asset pipeline in a rails / angularjs project
[12:22:37] norc: I want to make some additions to ActionController::Base, but dont want to make an extra gem out of it. Where would I ideally put this?
[12:22:49] shortCircuit__: ok. yeah that is why I am trying to do both and se the pros and cons of either
[12:22:51] universa1: norc: application_controller.rb
[12:23:21] universa1: shortCircuit__: ok. so the for the asset pipeline stuff you should find examples on google how to do that.
[12:23:23] norc: universa1: Modifying the base class in application_controller.rb?
[12:23:39] universa1: norc: no, modify application_controller.rb, all your controllers inherit from it.
[12:23:47] universa1: no need to modify ac::base
[12:23:49] norc: universa1: Oh bugger. How did I not know this. :)
[12:24:06] universa1: norc: you probably just didn't notice ;)
[12:24:15] norc: universa1: Yeah, the price for using generators all the time.
[12:25:13] shortCircuit__: I will try for a few days and set them up and show you..
[12:25:16] universa1: shortCircuit__: for the grunt way: the target directory for your app would be the public folder of the rails app, but you can not use any asset dependencies from the rails app, which wouldn't have any, since it's mostly a pure api
[12:25:52] universa1: shortCircuit__: and then you would have nginx / apache serve the static files (your angularjs app) from the public directory, and proxy api requests to your rails app
[12:26:18] universa1: shortCircuit__: but this essentially means the api server and the angularjs app are completely separated :-)
[12:28:16] shortCircuit__: yeah, I mean I am thinking, that since both the applications are running under localhost:3000, I can do localhost:3000/articles.json, right? what is proxying api requests?
[12:29:27] universa1: shortCircuit__: the apache / nginx server handles the static files, like precompiled assets, etc... ...but it passes requests that involve rails off to your rails server instance (most often this is a unicorn or puma instance)
[12:30:00] universa1: shortCircuit__: the rails server then handles the requests, sends the response back to nginx / apache, which in turn sends it back to the client
[12:30:33] universa1: shortCircuit__: but for files in RAILS_ROOT/public you usually configure the vhost in such a way, that the rails app is never hit, and that nginx / apache directly handle the request.
[12:30:46] universa1: serving static files is something they're incredibly great at compared to rails.
[12:31:00] universa1: simplified speaking ;)
[12:31:25] shortCircuit__: I have actually never done this before.. feels a little complicated...
[12:31:34] universa1: shortCircuit__: which part?
[12:33:01] shortCircuit__: I mean, if I am using grunt and suppose converting sass to css. now I am having a grunt-connect which runs a server at port say 9000. all this inside my public/ folder, then how to call the rails api ...
[12:33:54] universa1: shortCircuit__: the generated files would end up in RAILS_ROOT/public/ -- you would thens tart your rails server and in development mode it will serve the files from the public folder
[12:34:07] universa1: shortCircuit__: you don't need the grunt-connect server in that scenario
[12:34:34] universa1: shortCircuit__: http://railscasts.com/episodes/405-angularjs -- for the rails asset-pipeline way.
[12:35:55] emilkarl: How would you validate uniquess but only compare with records with a ceratain state for example.
[12:35:57] shortCircuit__: there should be an asciicast for pro episodes... :P , k I will watch that.. I have downloaded the videos at home.
[12:37:03] solars: hi, if I have a post action that is used from a webservice, do I have to set protect_from_forgery with: :null_session or do I have to exclude it completely? I'm getting :InvalidAuthenticityToken
[12:37:14] tbuehlmann: emilkarl, only validate a record if it has some state or validate uniqueness for all with that same state?
[12:38:28] shortCircuit__: solars, I think you should send the authencity token from the server and then set it in the post form and send it .. I am not sure though ..
[12:38:49] emilkarl: I want it to check uniqueness for the record I create at any state. But I only want it to compare with records has state=???complete???
[12:39:07] solars: shortCircuit__, it's a webservice, there are no forms
[12:39:21] solars: I think I can just skip it
[12:39:33] emilkarl: tbuehlmann: is that weird?
[12:39:43] tbuehlmann: emilkarl, then this might be it: `validates :field, uniqueness: {scope: :state}`
[12:40:26] tbuehlmann: I didn't understand it then
[12:41:15] emilkarl: lets say I have 3 orders. 1 is completed, with kit: 5, then order 2 and 3 would not be able to use kit: 5, but they could each have kit: 6 until any other complete order becomes kit: 6
[12:41:44] emilkarl: any of them is complete..
[12:43:02] exadeci: Hello, how would you fit User-> has_many :courses has_many :lessons, through: :courses with the 3 ids in a table ? |user_id|lesson_id|course_id| ?
[12:45:18] universa1: exadeci: what?! that is not how the has_many association works in rails. you would have a user_id column on courses, and a course_id column on lessons.
[12:45:57] universa1: exadeci: but my guess would be that you want a many to many association between users and courses, and not a one to many.
[12:47:50] mikecmpbll: emilkarl: what happens to the other kit: 6 ones when one of the kit: 6 ones becomes complete?
[12:48:28] emilkarl: mikecmpbll: I am trying to figure this out???they wouldhave to become invalid
[12:48:54] emilkarl: what I want to avoid is uncompleted orders ???locking??? kit numbers for others
[12:49:06] mikecmpbll: emilkarl: then don't have a validation at all.
[12:49:30] emilkarl: but for completed orders i would not want to allow the same kit number to be used at all.
[12:49:34] universa1: welll, validates_uniqueness_of :kit_id, if: -> { self.state == "completed" }
[12:49:40] emilkarl: but I think its better to validate uniquess for all records
[12:50:23] emilkarl: and then kit numbers for uncompleted orders will have to be cleared by a task or something
[12:50:55] exadeci: universa1: I did a bad translation what I meant with lesson is instead a subject so that would be a has_and_belongs_to_many ?
[12:51:10] norc: So I have written some code to hook into certain actions and create a record of a model Foo. Is using "created_at" to denote the time of the action a safe thing, or should I use my own column?
[12:51:27] universa1: exadeci: so a student enrolls into many courses
[12:51:37] universa1: exadeci: and a course has many enrolled students?
[12:51:41] mikecmpbll: norc: it's perfectly safe but then you lose the information about when the row was created.
[12:51:55] mikecmpbll: norc: often times it's nice to be able to know that.
[12:52:12] vedu: Sorry if it is a noobish question, but I want to set RAILS_ENV variable in my /usr/bin/env . I Trying to edit it via nano but in vain
[12:52:55] emilkarl: universa1: will that validate uniquess of kit between all records when self is complete? not only records that is completed?
[12:52:55] norc: mikecmpbll: I see. So for concurrencie sake I should supply a date of the action. ;)
[12:53:06] norc: Rather than assuming that the time of creation is the same_
[12:53:15] mikecmpbll: norc: not sure what you mean by that.
[12:54:02] universa1: emilkarl: ohh yeah, my bad.
[12:54:08] norc: mikecmpbll: Well I basically have hooks using "after", where I use Foo.create(user: current_user, action: action_name, controller: controller_name). So the moment of creation is the same as the time the action occured.
[12:54:20] emilkarl: universa1: but I think I will skipp uniqueness check
[12:54:30] mikecmpbll: emilkarl: just add a scope, too.
[12:54:34] emilkarl: until I have talked it through with the people who wants it
[12:55:12] exadeci: universa1: I should have named it professor then (I have a student model and a user that should be instead professor) sorry for the confusion. A professor has many subjects and tied to this subjects he has many courses
[12:55:44] exadeci: so I wanted to make a table linking a professor and his subjects to all his courses
[12:55:44] emilkarl: but self shouldnt be scoped. it should validate the number at all times, but only against records that is completed.
[12:56:01] emilkarl: that was the idea anyways, but i dont think it might be nessecary
[12:56:14] universa1: exadeci: !fake
[12:56:14] helpa: exadeci: Please do not use fake values, as they can be confusing or misleading. Sometimes both.
[12:57:12] universa1: exadeci: so what is your actual problem?!
[12:57:23] universa1: exadeci: !associations
[12:57:24] helpa: exadeci: http://guides.rubyonrails.org/association_basics.html - Active Record Association Basics by Mike Gunderloy
[13:03:19] exadeci: universa1: ok, well I have professor that has one or many subjects and linked to his subjects there are classes, so for example you would have a professor teaching mathematics to the class 1 and 3 and the same professor teaching physics to class 1 and 2. The 3 models/tables already exist but they were not linked together a professor had subject and classes
[13:03:19] exadeci: but no specific link
[13:10:35] solars: the correct way 'finding' a record in rails 4 without getting an exception (nil instead) is Model.find_by id: - is that right?
[13:10:45] solars: or where().first?
[13:10:59] tbuehlmann: solars, correct
[13:13:48] goodcodeguy: so I have a completely newb question. I constantly struggle with the "right" place to store environment variables for Rails Apps, I end up having the same variables stored in /etc/environment, /etc/default/nginx and ~/.bashrc of my deploy user. Now I have those environment variables in those three locations but it still isn't recognizing my secret_key_base on a new app I'm deploying...Can anyone give me some advise on the "correct" place to
[13:13:48] goodcodeguy: be putting these environment variables to ensure they get loaded correctly?
[13:14:11] solars: tbuehlmann, hm I just noticed a difference, if you have a different ID column than .id - find() and find_by id: is not the same - is there something like find() that uses the specified id field but does not raise?
[13:15:40] aawe: goodcodeguy: only keep them in one place
[13:15:50] aawe: goodcodeguy: what does your server script look like?
[13:16:06] tbuehlmann: solars, yes, find_by. find will use the primary key
[13:16:26] goodcodeguy: aawe: server script?
[13:16:34] aawe: goodcodeguy: how do you run your server
[13:16:46] goodcodeguy: nginx, passenger
[13:17:21] solars: tbuehlmann, not sure if I follow - I mean is there something like find() that uses the defined key, but does not raise an exception? find_by does not work
[13:17:32] aawe: goodcodeguy: https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#about_environment_variables
[13:17:36] tbuehlmann: solars, what do you mean "defined key"?
[13:17:43] mikecmpbll: solars: find_by(id: 1)
[13:17:51] mikecmpbll: incase you weren't sure how find_by worked :)
[13:18:43] aawe: goodcodeguy: apparently passenger 4.0 and above reads environment variables from bashrc
[13:20:27] tbuehlmann: I'm with aawe, keep the id
[13:20:32] aawe: solars: because you gain nothing from breaking the rails conventions
[13:20:34] goodcodeguy: aawe: yeah, I'm reading that, which basrc should I put them in then? Would my deploy user be the one running passenger do you think?
[13:20:40] aawe: and you gain lots from following them
[13:20:43] mikecmpbll: aawe: hey, not absolutely nothing :)
[13:21:10] solars: mikecmpbll, hm yeah.. still not so nice.. in this case I don't understand why there is no option besides the one that raises an error :/
[13:21:17] mikecmpbll: solars: what's not nice?
[13:21:22] mikecmpbll: solars: it's a solution to your problem.
[13:21:41] solars: aawe, tbuehlmann sometimes it's not as easy as sticking to conventions, if you have large legacy databases or other applications that interfere
[13:21:42] aawe: goodcodeguy: I think root
[13:21:59] tbuehlmann: solars, yep, I feel you
[13:22:14] aawe: solars: ouch
[13:22:19] solars: mikecmpbll, I mean compared to a way to silence the exception.. of course it is a solution :) just complaining
[13:22:22] goodcodeguy: aawe: thanks, I'll play with that, if it doesn't work I may just start using this passenger_env_var in nginx, that actually feels a bit cleaner to me to be honest
[13:22:40] mikecmpbll: solars: how is silencing an exception better than using a method that doesn't raise an exception? i've no idea what you're on about any more.
[13:22:51] aawe: goodcodeguy: it's safer to hide the env vars in /home/root/.bashrc than in the nginx conf
[13:22:52] workmad3: solars: you also have database designers that actually like the idea of third-normal-form databases, and so don't want to introduce a meaningless primary key called 'id' when they could use a primary key that's actually part of the data-set
[13:22:53] solars: aawe, besides that - conventions are nice, but they should also not restrict you
[13:23:13] goodcodeguy: aawe: hmm, ok
[13:23:37] solars: workmad3, that's just one scenario that you can imagine. in a corporate scenario it can be a bit more difficult.
[13:23:49] workmad3: solars: sure, that's one that just rolls off the brain ;)
[13:24:14] aawe: solars: you can do self.primary_key = 'banana_type' in your model
[13:24:39] solars: aawe, yes, if you would have followed the conversation, that is what I'm doing :)
[13:24:53] aawe: solars: sorry, missed that. anyhow: http://ruby-journal.com/how-to-override-default-primary-key-id-in-rails/#model
[13:25:17] solars: mikecmpbll, nono, I meant it's a pity that rails doesn't provide a find() method that does not raise by default
[13:25:32] solars: aawe, I'm doing that already, thanks for the link though
[13:25:44] mikecmpbll: solars: *shrugs*, i just wrote one for you
[13:25:55] mikecmpbll: make a PR? :)
[13:26:23] solars: haha yeah and I did not complain about your method, but about rails :) for me it would be nicer to have find() and find!() for example
[13:27:04] mikecmpbll: solars: yeah, find's behaviour is one of those quirks :)
[13:27:37] workmad3: mikecmpbll: btw, your find_by_pk method should probably have been 'def self.find_by_pk(id); find_by(primary_key => id); end' ;)
[13:27:44] solars: if it'd work like that it could just use the defined primary key if one is there - with the workaround you posted I have to know that it was overriden.. so again might be a mess to refactor :)
[13:27:49] mikecmpbll: workmad3: right you are!
[13:28:04] mikecmpbll: workmad3: i like to write buggy code on purpose just to test you
[13:28:27] mikecmpbll: solars: you don't have to know that it's overriden
[13:28:33] workmad3: or even 'alias find! find; def find(id); find!(id) rescue nil; end'
[13:28:42] workmad3: (in a class << self block)
[13:28:44] mikecmpbll: solars: you just use it all the time
[13:28:53] solars: mikecmpbll, if you are starting with .find() everywhere in your models, you have to
[13:28:58] mikecmpbll: no, you can still use find
[13:29:05] solars: workmad3, that's what I did now :)
[13:29:18] workmad3: solars: hopefully not *exactly* that :P
[13:29:24] solars: not exactly yeah haha
[13:29:26] workmad3: solars: because you should be more careful with what exceptions you catch ;)
[13:29:45] tbuehlmann: btw, exceptions aren't really the fastest thing in rubyworld
[13:29:51] mikecmpbll: hoorah for confusing every other potential rails dev who approaches that project
[13:29:54] solars: I just wrote custom methods for it
[13:30:01] solars: still would prefer find() and find! in rails
[13:30:01] workmad3: tbuehlmann: s/exceptions/anything/ ;)
[13:30:09] tbuehlmann: wouldn't go that far :)
[13:30:29] workmad3: tbuehlmann: ok... fair enough... addition is reasonably quick :P
[13:30:50] tbuehlmann: fast as lightning
[13:35:26] workmad3: solars: I can kinda sympathise btw... but at the same time, .find's behaviour is so well established now that I'd be hesitant against changing it because, as mikecmpbll pointed out, it would confuse the hell out of a majority of devs, and it would be a massive, subtle upgrade requirement in all sorts of projects and gems that rely on the existing behaviour of .find
[13:35:58] solars: workmad3, yeah I completely agree.. and I think that this is the reason for the current state
[13:36:08] workmad3: solars: which doesn't make it impossible... but does make it pretty unlikely to ever happen, considering it's a fairly innocuous deviation from more recent rails norms
[13:38:52] wollner: I am trying to solve a problem using routes concerns and scope
[13:38:59] wollner: https://gist.github.com/anonymous/cbaa2f8c410a10964772
[13:40:21] mikecmpbll: wollner: ah, i had this issue before but can't remember how i solved it :d
[13:40:26] wollner: any help ou suggestions to overcome this issue is welcome
[13:41:09] emilkarl: If you nest forms with fields_for, how do I translate fields names for the error messages? activerecord->errors->models->order->attributes->address->street?
[13:41:12] wollner: mikecmpbll: seems like rails is missing this feature..the first solution would be simply not using modules, but that makes my code less organized
[13:42:02] mikecmpbll: wollner: in fact, my problem wasn't the same but similar and i couldn't solve it: http://stackoverflow.com/questions/27783424/remove-namespace-from-nested-resource
[13:43:42] wollner: mikecmpbll: yeah in my case I would simply remove the 'ads' module from all controllers and remove it from scope
[13:57:54] Axilla: ugh working with a designer that doesn't understand responsive design makes me want to gouge out my eyes
[13:58:07] Axilla: just had a designer come to me and say, "The text is jumping out of the column on large monitors"
[13:58:15] Etriaph: axilla: Oy.
[13:58:19] Axilla: No, the image you're comparing it to just doesn't fill the width of the column
[13:58:39] Axilla: the image is responsive up to its max width so it doesn't pixelate
[13:58:54] Axilla: he keeps coming back with design changes based on a flawed understanding of responsiveness
[13:58:59] Axilla: *face desk*
[13:59:14] Axilla: ./endrant
[14:00:39] Axilla: or he sends me designs
[14:00:47] Axilla: and shits all unaligned.. he's using sketch
[14:00:54] Axilla: and starts his alignment in the fing gutters
[14:01:39] Axilla: or just arbitrarily in the middle of a column because that's how he wants spacing, now how a responsive design wants it.
[14:14:36] norc: Hi. Whenever Im running unicorn, the worker process dies if ActiveRecord takes too long for a query to complete (talking queries that take 15-20s). Is there any way to prevent this?
[14:14:45] norc: http://pastie.org/10096097 is from the logs whenever I hit the problem
[14:14:53] norc: WEBrick is unaffected by this and works
[14:16:55] norc: (The query itself does not transport huge amounts of data either, it just takes long to complete for the time being)
[14:17:14] tbuehlmann: norc, are you sure it's about a long running query?
[14:17:26] norc: tbuehlmann: Fairly certain.
[14:18:23] tbuehlmann: well, you can configure the timeout for unicorn
[14:18:41] tbuehlmann: in unicorn.rb, call `timeout 30` for 30 seconds
[14:19:09] norc: Alright, Ill give that a try
[14:20:07] norc: tbuehlmann: That seems to have done the trick. Thank you :)
[14:21:01] norc: Based on what I just found about the configuration of timeout, that must have been it, since the master will send a SIGKILL (which is what the worker received based on the log) when it takes longer than that time to complete.
[14:21:52] norc: Although contrary to the documentation I never got a H13 error
[14:22:03] norc: Buut Im stupid. Nevermind
[14:25:00] tubbo: does pow automatically run `bundle` or something when you start the server?
[14:25:09] tubbo: err, when you visit your app for the first time
[14:25:25] rvanlieshout: you can't start your server without running bundle
[14:25:56] tubbo: rvanlieshout: i did that, i'm just trying to track down something strange going on. every so often when i switch branches i get a dirty Gemfile.lock
[14:26:11] tubbo: as if i ran `bundle` to rebuild the lockfile...but i never did
[14:42:57] exumbra: hoping someone can help me with a troubleshooting issue... i have a 'whitepapers' controller/model/route all setup and working in my local dev environment. Pushed to my staging server (AWS) and the whole thing is buggy... sometimes it works, sometimes it doesn't
[14:43:01] mr_foobar: I have an issue after updating from sprockets 2.12.3 to 3.0.0 or 3.0.1. The line in the app layout "undefined method `[]' for nil:NilClass" is the cause.
[14:43:31] mr_foobar: More precisely, the problem is in less-rails (2.6.0) lib/less/rails/template_handlers.rb:37
[14:44:06] mr_foobar: the line config_from_rails(scope)[:path]
[14:44:25] DasLumberJackYa: g'day rails masters
[14:44:34] mr_foobar: why does config_from_rails(scope) return nil in my project?
[14:44:41] mr_foobar: DasLumberJackYa, hi
[14:46:21] mr_foobar: config_from_rails(scope) returns scope.environment.context_class.less_config, which is nil. Where should that value come from?
[14:47:29] exumbra: why would a controller sometimes process but other times it does not? ... tailing production.log
[14:48:03] xploshioon: what are the step to follow if i want an action that can be accesed like and API, just an action that will a POST request and have to send a json back
[14:48:32] xploshioon: my app is a web page, but need to verify something in a phone app
[14:48:35] DasLumberJackYa: exumbra: process means? controller as in an action from a controller or ....
[14:49:23] exumbra: DasLumberJackYa yes, i have a controller that works fine in development, but pushing it to production is sporadic
[14:49:28] DasLumberJackYa: xploshioon: create route, create controller, create action (function), render rabl gem
[14:50:45] DasLumberJackYa: exumbra: production can get messed up from asset pipline or database settings, not to familar with that problem wish I could help you, errors would be great to know
[14:51:10] exumbra: DasLumberJackYa sometimes the view associated with the controller method loads, sometimes it doesnt load anything (whitepage)... when there is a whitepage, nothing is added to production.log
[14:51:45] mr_foobar: are my messages received?
[14:51:52] exumbra: DasLumberJackYa is there a way to 'reset' the asset pipeline in production then?
[14:51:55] DasLumberJackYa: can you see errors in the browser console? what is rails server telling you as well?
[14:52:24] DasLumberJackYa: exumbra: it has something to do with pre compiling assets I would have to look it up, im no expert
[14:52:51] exumbra: DasLumberJackYa when nothing loads in the browser, nothing is posted to production.log, so there isn't much available to debug :(
[14:53:35] DasLumberJackYa: exumbra: are you familiar with the rails server and watchign the output? or looking at a browsers console in dev mode?
[14:54:21] exumbra: DasLumberJackYa no... can you reference me to a resource to get familiar?
[14:54:37] xploshioon: ok @DasLumberJackYa, ill read about it, thanks
[14:56:14] DasLumberJackYa: exumbra: https://developer.chrome.com/devtools/docs/console <- using console in chrome, also when you launch your webrick server by typing rails s in your terminal and go request a page from you app, the terminal with have out put which you can watch
[14:58:08] exumbra: DasLumberJackYa ah! "Failed to load resource: the server responded with a status of 404 (Not Found)"
[14:58:31] DasLumberJackYa: exumbra: now you can figure it out
[14:59:20] DasLumberJackYa: exumbra: the url in your browser should matcha route. in your terminal hit ctrl+shift+tab to get a new tab and the type rake routes
[15:00:24] DasLumberJackYa: exumbra: ctrl+shift+t is a new tab isorry ubuntu term
[15:00:35] exumbra: DasLumberJackYa I gotcha
[15:02:57] exumbra: DasLumberJackYa are you familiar with activeadmin ?
[15:03:09] DasLumberJackYa: exumbra: no sorry
[15:03:26] exumbra: DasLumberJackYa no worries... i think that is my problem.
[15:04:20] DasLumberJackYa: looks like a neat gem
[15:05:13] DasLumberJackYa: I was wondering if any had an idea of the best way to do this -> I have a large form (20 + fields) the user fills it out. I want them to be able to click a button that duplicates the form and has all the fields prefilled. This would obvisouly have to work with rails i.e. hav the correct names on the fields
[15:06:46] DasLumberJackYa: The form also has ryan bates nested form gem in use and all the nested forms would have to be copied as well
[15:12:26] aawe: mr_foobar: HELLO!
[15:13:00] mr_foobar: aawe, so my messages are received, thanks.
[15:13:05] aawe: there are ~600 users in this channel, no need to see if there's anybody here.
[15:13:55] mr_foobar: aawe, no it's not that but i wasn't sure if my messages arrived at the server and were shown to users
[15:16:10] gaussblurinc1: well, I have a block in controller: respond_to |format|; format.all {render nothing: true, status: :not_found}; end. How to test it?
[15:17:09] aawe: gaussblurinc1: get :actions; expect(response.code).to eql(404); expect(response.body).to be_empty
[15:17:31] aawe: in a controller spec
[15:19:41] gaussblurinc1: aawe: ok, but this .all format not alone in respond_to, it also has .html and .json. get :actions, {format: :any_except_html_or_json}?
[15:20:26] aawe: gaussblurinc1: or format: :mickeymouseforpresident
[15:21:55] gaussblurinc1: aawe: format: :currentpresidentwithwhitedusttobelikemickeymouse
[15:23:17] bricker: gaussblurinc1: you should just choose a few to test
[15:23:47] bricker: gaussblurinc1: also, Rails will automatically respond with a 404 in production (UnknownFormat) if the requested format isn't supported, so maybe you don't need this code at all
[15:27:24] gaussblurinc1: bricker: thanks for information. so, leave it alone with formats and only choose specific ones that I need?
[15:29:55] bricker: gaussblurinc1: yes
[15:37:05] bricker: good, indeed.
[15:40:26] guillaume-rb: Hi ! I have a relation has_many :through and would like to make a validate on the number max of relations. I use this code: https://gist.github.com/GuillaumeLegendre/8609d1a88ee54bb694a7
[15:40:32] guillaume-rb: but when I do this command: event.users << User.create(name: "test")
[15:40:33] guillaume-rb: The error who is throw is: ActiveRecord::RecordInvalid: Validation failed: Event is invalid, Event is invalid
[15:40:33] guillaume-rb: Like you can see on the code what I would like to have is "Max number user has been reached"
[15:40:34] guillaume-rb: Why don't he show me this error and show me two time Event is invalid?
[15:41:19] norc-2: Hi. Given a helper path like from users_path, I would like to obtain the controller and the action this path is routed to.
[15:51:07] DasLumberJackYa: norc-2: the action used depends on the request type
[15:51:19] DasLumberJackYa: type rake routes in your terminal to see the matches
[15:51:59] norc-2: DasLumberJackYa: thats why recognize_route returns only the controller and params then.. Makes sense.
[15:52:45] norc-2: Id be willing to supply the path and method then, I just nees this programmatically.
[15:53:52] bricker: there used to be a hash_for_some_path
[15:53:55] bricker: don't know if it still exists
[16:01:08] kalebe: hi, i use rails_api bundle for a restful app... how could I set it up with nginx and passenger, once rails_api does not caome with a public directory???
[16:02:32] bricker: kalebe: make one
[16:02:38] arup_r: Don't hesitate just star it -- https://github.com/eliotsykes/rspec-rails-examples?utm_source=rubyweekly&utm_medium=email#activejob-examples awesome
[16:06:07] arup_r: Am I visible ?
[16:06:16] kalebe: bricker: just that? create the dir?
[16:07:47] bricker: kalebe: that should be it
[16:32:44] lessless: what to do if a polymorphic table has a difference in one field?
[16:38:57] lessless: bricker, there are two types of insurance products, they differs only in one field. what will be the most idiomatic way to implement this in rails?
[16:40:43] neredsenvy: I had a model named Child so it expected to have foreign keys named child_id however I changed the model name to Childm is there a way to tell it to use child_id as foreign key ?
[16:40:53] neredsenvy: So I don't have to redo all the tables right now ?
[16:42:15] bricker: lessless: answering that requires domain knowledge, scope of your project, business needs, etc.
[16:42:27] bricker: lessless: you could just have the two columns in one table
[16:42:33] bricker: but I don't know if it meets your need
[16:54:07] rhizome: neredsenvy: you shouldn't have a child_id attribute in a Child model/table, but yes, you can configure association to use the foreign keys you want to use
[17:28:38] DasLumberJackYa: pretty quite on the front
[17:32:05] doge__: ssh europe-phonecalls.nsa.gov
[17:41:26] significance: I've taken 90% of the rails tutorial and I still feel like I have no idea what I'm doing - it feels like drudgery fixing a, resetting b, etc. Any ideas on a fun way to improve my rails skills?
[17:42:37] tubbo: significance: make more rails apps
[17:43:21] significance: tubbo: Whenever I do, my code gets very messy and I feel like scrapping the project - any advice on keeping clean code?
[17:43:37] tubbo: significance: make more rails apps ;)
[17:43:57] tubbo: significance: j/k...there's some books you can read...why do you scrap the project when your code gets messy?
[17:43:59] significance: tubbo: Hahaha - will do. Any advice on a good beginner app idea to get started?
[17:44:01] tubbo: why not refactor it until it's better?
[17:44:33] tubbo: significance: i would start with pondering what you need, and then making an app that satisfies that need. it's hard to figure out exactly what to work on if you have a blank slate...
[17:45:12] tubbo: significance: you're way more motivated to finish the app when you're working on solving a problem you actually have
[17:45:23] significance: tubbo: Thank you - I'll work from there. I've got one idea I'll try - thank you!
[17:45:43] tubbo: no problem, good luck!
[17:45:59] significance: tubbo: I'm terrible at UI design, though, and often even my Bootstrap frontends will break with weird sizings. Any ideas on how to get a frontend up that won't break?
[17:46:43] tubbo: significance: ever hear of https://hackdesign.org/?
[17:47:11] tubbo: they've been pretty helpful for me...i'm an engineer primarily, not a designer, so i never really learned the rules of design
[17:47:15] tubbo: there actually are rules
[17:47:19] significance: Oh my gosh! Thank you! I've been looking for something like that.
[17:47:42] tubbo: another helpful site is http://kaikkonendesign.fi/typography/ (which I found thru hackdesign)
[17:47:42] significance: Do you know of any similar resources that I can look at that I can work on in my own time?
[17:48:13] significance: tubbo: That is hugely helpful. Thank you!
[17:48:28] tubbo: maybe listen to a miles davis album or two to grok "the space between" content? ;)
[17:49:49] ght: Question: I have a .each loop in a view that is part of a form, and I need to set a unique ID for a series of text_field form statements so that when they're submitted, I can use the controller to identify which text_field is which. I've done this successfully with a select_tag statment with the following line: <%= fp2u.select_tag "p2u_cl_id-#{p2u.cl_id}", options_for_select(@is_all_users, p2u.is_id) %>
[17:50:22] ght: Is it possible to assign a unique element such as the "p2u_cl_id#{p2u.cl_id}" aspect of the select_tag above?
[17:50:25] significance: tubbo: Hahaha - I'll give that a try. If I want to have an fast UI (for now) that does okay on scaling - do you have any tips?
[17:50:27] ght: to a text_field?
[17:50:39] tubbo: significance: a "fast UI
[17:50:42] ght: perhaps something in html_options or the like for text_field?
[17:50:45] tubbo: significance: a "fast UI"? what's that?
[17:51:09] tubbo: ght: sure, why not :)
[17:51:19] ght: tubbo: What would the syntax be? The documentation isn't clear on this.
[17:51:22] significance: tubbo: Something like Bootstrap or Foundation that doesn't break when I try to resize.
[17:51:25] ght: just any example will do.
[17:51:26] tubbo: ght: typically i set data-attributes, like data: { id: p2u_cl_id } so i don't have to interpolate
[17:51:36] ght: perfect tubbo, how would that work in a text_field statement?
[17:51:49] tubbo: ght: oh yeah you set it in the html_options, like text_field_tag :name, value, id: 'id'
[17:51:50] ght: you just throw in text_field :myparam, data: { id: p2u_cl_id }?
[17:52:30] ght: tubbo: I see. So you would use text_field_tag?
[17:52:50] tubbo: significance: making things responsive is always a trial-and-error process. the basic diffs betwen bootstrap and foundation -> bootstrap is older, but also wasn't designed responsively initially so there's always that cruft. it's also written in LESS.
[17:53:12] tubbo: foundation is written in Sass, and Zurb is a rails shop so it comes built for rails from the get-go
[17:53:49] tubbo: also it was written to solve the same problem as bootstrap but with a more flat UI and responsiveness baked in
[17:53:49] significance: Thanks so much tubbo! I'll start w/ Foundation and work from there.
[17:55:34] BrianKim: hey everyone, im looking into building a rails template to automate some tasks when creating a new app. is it possible to copy in files to the app similar to the way running a generator?
[17:56:51] gizmo: I'm running an older version of rspec (1.3.0, core: 3.0.3) and looking to run all specs but a certain file. I know I can run just one spec with SPEC='./path/to/file.rb' but I don't know how to blacklist specs
[17:59:49] tubbo: brian___: i don't believe templates or copy_file works...
[17:59:53] tubbo: but there is a file() method
[18:01:13] BrianKim: tubbo: right, but that requires the template file including the code you want to copy into the file using <<-CODE???CODE (sorry i dont know the name for that thing)
[18:01:32] tubbo: brian___: it's called a HEREDOC. also a very difficult piece of syntax to google for :)
[18:02:09] BrianKim: tubbo: so the heredoc is the only way to go? :/
[18:02:23] tubbo: brian___: you can actually pass a block into that file() method. i needed to have custom files in my app generator too, so i re-wrote the parts of Thor::Actions that i needed. https://github.com/tubbo/rails-template/blob/master/share/rails-template/generator.rb
[18:03:32] tubbo: that rails-template repo unpacks to /usr/local/share/rails-template, so you can just tell rails to use --template=/usr/local/share/rails-template/generator.rb, and it should find the files in /usr/local/share/rails-template/templates
[18:04:15] BrianKim: interesting. thanks for sharing!
[18:07:10] BrianKim: tubbo: this is awesome. exactly what i needed. thanks again
[18:11:16] tubbo: has anyone dealt with finding out the GeoIP params for a given IP address?
[18:11:34] tubbo: just wondering if the HTTP_GEOIP_* request headers are part of some kind of standard...or if that's something custom?
[18:11:39] gizmo: don't you have to use an external service for that
[18:19:01] toretore: tubbo: you can use the browser's geolocation stuff
[18:19:17] toretore: which, surprisingly, only works with js..
[18:19:59] toretore: tubbo: otherwise, yes, you need to use a database or a service to look it up
[18:20:03] tubbo: toretore: why is that surprising, it's a javascript feature :)
[18:20:11] toretore: it's a browser feature
[18:20:18] toretore: doesn't mean js
[18:20:21] tubbo: toretore: and what language do we use to script the browser?
[18:20:43] toretore: you're missing the point
[18:20:50] tubbo: imho they're hand-in-hand
[18:20:57] tubbo: but yeah i think we have a maxmind service set up
[18:21:08] tubbo: like geolocation does work most of the time just dealing with a weird issue
[18:21:18] toretore: why does it have to be requested through js? it could be implemented in other ways too
[18:21:34] tubbo: toretore: how?
[18:21:42] blitz: geolocation is far from perfect
[18:21:46] blitz: that's why it doesn't work most of the time
[18:22:14] toretore: that's what i thought when you mentioned the headers; i expected that i would be able to request it and the browser would send it in the headers
[18:22:18] tubbo: toretore: so what does that mean, the browser sends a request to the server saying "here's my location"?
[18:22:54] toretore: the server sends a header in the response, saying "please send another request at this uri with geolocation information"
[18:23:01] toretore: (if the user consents)
[18:23:13] toretore: but everything's all about js nowadays, i guess
[18:23:15] xibalba: if i've got a sidekiq worker using the sidetiq recurrence settings, do i at least need to trigger the job once? I've got a mailer that goes out that isn't trigger by any controller actions.
[18:23:18] toretore: fucking html5
[18:23:48] toretore: xhtml2 should have won
[18:23:58] toretore: those hipsters ruined the web
[18:27:04] tubbo: toretore: there's actually few standards.. http://en.wikipedia.org/wiki/Geolocation
[18:27:16] tubbo: xhtml2 didn't win because it was implemented poorly
[18:27:30] tubbo: if it wasn't designed by a million person committee it would have won.
[18:27:48] tubbo: html5 won because a big company with a lot of money wanted to do things on the web and the web wasn't moving fast enough.
[18:27:53] tubbo: that's how you get shit done.
[18:36:25] ght: My placeholder code for this text_field_tag isn't populating, despite me having confirmed the value is present and correct in the table.
[18:36:35] ght: Does this syntax look correct?: <td><%= text_field_tag "aff_pp_email-#{affiliate.aff_id}", nil, placeholder: affiliate.pp_email %></td>
[18:37:05] ght: the affiliate.aff_name in the table colume prior works fine, so affiliate.pp_email should properly print that value.
[18:37:28] ght: But it's not. Is that placeholder syntax incorrect? I'm following the documentaiton found here: http://apidock.com/rails/ActionView/Helpers/FormTagHelper/text_field_tag
[18:38:24] ght: Never mind, now it works, but the default font is light grey. Any way to make the text_field_tag placeholder text appear normal?
[18:40:03] ght: Ok, well, I'll handle that. But last question regarding this: The placeholder text isn't actually populating the value, so if the user updates their profile with the legacy placeholder text in the field and hits submits, it overwrites it with "" since nothing was actually entered in the field.
[18:41:28] DasLumberJackYa: value is what your looking for
[18:42:40] DasLumberJackYa: value sets the field value and placeholder is just visible fluffy stuff that disappears
[18:44:14] norc-1: Hi, I asked a question earlier today but got disconnected midway. Given a method (e.g. PATCH) and a path (e.g. users_path(@user) ), how can I programmatically determine the action and controller this will be routed to?
[18:45:13] DasLumberJackYa: norc-1: you can add a route that under a certain circum stance the controller and action will happen
[18:46:38] DasLumberJackYa: norc-1: If you write a custom route Im not sure how priority will work with scaffolded routing.... You can also set the controller and action to link to in the link builder, but the leets here may know that off the top of their head
[18:46:56] norc-1: DasLumberJackYa: This is pretty much only for routes using resources
[18:47:36] norc-1: I mean some part of rails needs to do this obviously, since thats how servers like webrick and unicorn make sure the appropriate action is called.
[18:47:54] norc-1: Even for custom routes
[18:48:26] norc-1: All I know is the likely place to look for this is ActionDispatch
[18:48:43] DasLumberJackYa: norc-1: yea rails handles it with the active::dispatch i
[18:49:02] DasLumberJackYa: norc-1: are you trying to modify it?
[18:49:41] DasLumberJackYa: It get teh info from the headers
[18:49:50] hutch78: hello everyone :) i am receiving the following error in my cron_error_log.log file... "bin/rails:7: undefined method `require_relative' for main:Object (NoMethodError)"
[18:50:51] hutch78: any insights into this ?
[18:51:08] DasLumberJackYa: hutch78: The method you are trying to use does not exist in the instance... errr maybe you have to declare it in your controller?
[18:51:42] norc-1: DasLumberJackYa: http://pastie.org/10096579 this is some pseudo code of what Im trying to accomplish in a helper
[18:51:58] norc-1: DasLumberJackYa: can? being the core function from cancancan.
[18:52:17] hutch78: I will look into that Das, thanks
[18:52:24] norc-1: do_stuff doing the reverse mapping of what load_and_authorize_resource does
[18:53:05] DasLumberJackYa: norc-1: sorry norc I think this is over my head, would require me to research much
[18:53:41] DasLumberJackYa: the leets are workman, tubbo, bricker and so forth
[18:57:05] jamgood96: I'm trying to use Devise' rememberable module and it is choking on the `serialize_from_cookie` method in rememberable.rb... i debugged it am seeing that both `record.rememberable_value` and `remember_token` are returning the array [true], which secure_compare is choking on as it appears to be expecting strings for those values
[18:57:08] Senjai: norc-1: Dont do conditional link to's, ever
[18:57:12] Senjai: Just use if statements
[18:57:27] Senjai: norc-1: What you're doing doesnt really make sense
[18:57:29] norc-1: Senjai: The point is to save a lot of code all over the templates since I have plenty of links that depend on roles and abilities.
[18:57:47] Senjai: norc-1: Entire views should depend on roles, not just links.
[18:57:48] norc-1: Senjai: I want to put in links, and display these links only if you have the role to do the action behind it in the first place
[18:58:04] Senjai: norc-1: I wouldnt render an entire admin menu, for example, if the user couldnt access any of its links
[18:58:35] norc-1: Senjai: Random example: Some people should have edit links/buttons. They only need to appear if you have the right to do it in the first place.
[18:58:45] norc-1: A custom view for every role doesnt make sense if you have mutiple roles affecting different things in the view
[18:58:53] hutch78: what is the most common way to clear log files ? just delete the file ?
[18:59:11] norc-1: hutch78: Use some logrotate mechanism
[18:59:25] Senjai: norc-1: Roles should be based off of models, not controllers
[18:59:57] Senjai: norc-1: If i had to do something that silly, I would do it like this: https://gist.github.com/Senjai/b142337ee8532413a0f2
[19:00:00] norc-1: Senjai: Cancancan is a model that works with actions in controllers
[19:00:23] Senjai: norc-1: Cancancan works with anything, but it should be used for everything
[19:00:39] Senjai: Generally you want it to be used with respect to models
[19:00:49] DasLumberJackYa: I agree with senjai
[19:01:03] DasLumberJackYa: implimentation seemed weird, but gave benifit of doubt
[19:01:21] norc-1: Senjai: Well in my case I want to have it work on every step. View so you dont get the wrong idea that you could so something, controller that you wont get the right action executed, and the model so that if everything fails you cant get the data in the first place.
[19:02:11] norc-1: Senjai: Though cancancan seems to suggest to do all of this in the controller, since it will serve views of actions that dont make sense. Being able to get an edit page when you cant edit it does not make sense at all.
[19:04:03] norc-1: Senjai: Either way, just figured out that ActionDispatch::Routing::RouteSet accepts a hash where method: "PATCH" yields the proper action.
[19:04:09] norc-1: Which pretty much answers my question
[19:04:36] norc-1: ActionDispatch::Routing::RouteSet#recognize_path( sorry
[19:07:31] norc-1: Senjai: And to be fair, having cancancan mess with how models can be accessed seems like hacks that dont make much sense.
[19:16:12] Senjai: norc-1: If you need a role per link, you're doing it wrong. Simple as that
[19:16:32] DasLumberJackYa: yea realtion should be stored in a table no?
[19:16:38] Senjai: DasLumberJackYa: wat
[19:16:43] norc-1: Senjai: You are missing the point.
[19:16:54] Senjai: norc-1: I dont think I am
[19:17:20] Senjai: We have several clients with 60k+ loc codebases, and have never had to resort to terribleness like that.
[19:17:33] norc-1: Senjai: Lets talk a basic scaffold from rails generators. You have a destroy button, an edit button and a show button. Now there could be a number of roles that define who can read, who can edit, who can create and who can destroy stuff.
[19:17:57] norc-1: Its not linked to a link per se, but the point is you could have multiple roles influencing the content of a single partial
[19:18:25] norc-1: if you had the role "admin" you might see everything, a link to create, destroy, edit and show. if you had the "editor" you might be able to create end edit.
[19:18:31] batasrki: norc-1: if you lock things down server-side, *not* showing a link on the client is a nice-to-have
[19:18:41] norc-1: batasrki: Precisely!
[19:18:43] Senjai: norc-1: Sure, but its tied to a model. Typically you have: can :read, or can :manage. You rarely ever have someone who can :edit but cannot :update, or someone who can :update, but cannot :destroy
[19:19:01] batasrki: norc-1: but then why bother with this conditional link_to thing and are arguing for it
[19:19:21] batasrki: locking things down server-side probably does involve a DB check, meaning a model
[19:19:26] norc-1: batasrki: Because I dont want to specify the controller and action every time I throw in a link.
[19:19:39] Senjai: norc-1: Did you read my gist?
[19:19:44] Senjai: You dont have to care
[19:19:48] Senjai: just delegate the arguments to link to
[19:19:54] batasrki: norc-1: that makes 0 sense. What are you linking to if you aren't specifying a controller and action?
[19:20:04] norc-1: Senjai: Its essentially what Im doing but fine...
[19:20:16] Senjai: norc-1: No, link_to can take many different arguments
[19:20:25] Senjai: You have it hard coded for one case
[19:20:28] norc-1: batasrki: then I wont use that link... its basically a magic link for resources managed by cancancan
[19:20:45] norc-1: Senjai: Didnt you read the part where I said it was some pseudo code?
[19:20:57] norc-1: The whole point was never how to pass on arguments to link_to, but how to obtain the method of the controller.
[19:21:06] norc-1: Since I have solved that problem a long time ago, you keep arguing Im doing something wrong.
[19:21:27] tubbo: batasrki: '#' :)
[19:21:27] Senjai: norc-1: !rule3.2
[19:21:27] helpa: norc-1: NO FAKE CODE. If you're under an NDA, we cannot help you with your problem. Go hire a consultant.
[19:21:49] batasrki: tubbo: hahahahahahhaha
[19:21:58] Senjai: norc-1: Why do you need the controller? link_to :edit, @project
[19:22:03] norc-1: Senjai: Its nice to ride on semantics, but the point of the fake code was to show I never cared about help on how to make links.
[19:22:06] norc-1: My question was rather specific.
[19:22:25] norc-1: Senjai: Why do you care why I have a specific question. Obviously I have a goal in mind.
[19:23:19] Senjai: Sure, my point is that method shouldn't need to exist, that's all
[19:23:51] tubbo: norc-1: since everything is an expression in ruby, you could also do `= link_to 'something', action if can? :action`
[19:23:55] tubbo: norc-1: i don't know what do_stuff is
[19:24:18] norc-1: tubbo: And that precisely is what Im trying to avoid. I dont want to repeat the action and controller absolutely every time
[19:24:29] norc-1: since this would be something I would have to repeat quite often and can be obtained programatically
[19:24:33] tubbo: norc-1: ahh that makes sense
[19:24:47] Senjai: norc-1: conditional_link_to permission, whateverargstobepassedintolink_to
[19:25:06] Senjai: norc-1: There is actually a rails thing for thi http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_if
[19:25:09] Senjai: and its terribru
[19:25:16] tubbo: oh yeah i forgot about link_to_if
[19:25:27] Senjai: tubbo: Because you never want to use it ever :P
[19:25:48] tubbo: that would look odd anyway
[19:25:53] Senjai: If course
[19:25:55] tubbo: link_to_if(can?(:action), 'text', :action)
[19:25:55] Senjai: Just use an if statement
[19:26:20] DasLumberJackYa: I though there was a popular gem that handled all of this for you with simple statments
[19:26:36] batasrki: moreover, if there's a thing that you're doing repetitively, shouldn't it be in a partial?
[19:26:46] tubbo: norc-1: it would be *really* cool if you could build off link_to so that all you'd have to do is authorized_link_to 'View Account', my_account_path
[19:27:01] tubbo: and it would just *know* that my_account_path is right. it's pretty much what you got right now.
[19:27:04] Senjai: DasLumberJackYa: It is simple, you never need to check different roles for every link, as mentioned before. 99.99999% of the time, you only care for :read, and :manage
[19:27:05] norc-1: tubbo: http://pastie.org/10096636
[19:27:26] norc-1: tubbo: that does it basically. you do have to provide non-default verbs since it it doesnt know how to route it otherwise
[19:27:34] DasLumberJackYa: Senjai: makes sense to me
[19:27:42] norc-1: tubbo: and yeah, that was the goal the whole time :D
[19:27:49] Senjai: norc-1: WAT?, def cond_link_to(thing_I_care_about, *everything_else)
[19:28:11] hutch78: Im still having no luck... Ive verified that my controller reference works
[19:28:24] bricker: hutch78: what's the problem?
[19:28:30] tubbo: norc-1: does this work? https://gist.github.com/tubbo/14e07bbd2892a55ebab4
[19:28:34] norc-1: Senjai: Lets not be code beauty nazis. Im sure you can survive it not everyone adheres to your standards, thoughts, work processes and beliefs.
[19:28:56] tubbo: norc-1: i'm just curious...was thinking maybe that method could be written more clearly so it's easier to understand what it's all about
[19:28:57] DasLumberJackYa: its heating up!
[19:29:36] tubbo: DasLumberJackYa: sorta...not what norc-1 wants though i think
[19:30:16] tubbo: DasLumberJackYa: the problem is already solved, you just do `link_to 'text', post if can?(:read, post)`
[19:30:28] tubbo: but he wanted to not have to type so much
[19:30:47] tubbo: IMHO, a 6-line method with no docs, no usage, and no real reason for its existence better be damn easy to read
[19:30:51] tubbo: if it's not, it's a code smell
[19:30:58] bricker: you're a code smell
[19:31:07] tubbo: ACTION farts brainfuck
[19:31:35] batasrki: I smelt some code
[19:31:46] batasrki: ACTION may not English
[19:31:47] norc-1: tubbo: If you expect me to write a fucking 10 page rdoc novel around it sure :D
[19:31:53] DasLumberJackYa: I love it when everyone start chiming in on the same problem and people get heated, prob solve yes, nice work
[19:31:54] tubbo: batasrki: you smelted some code :)
[19:31:56] norc-1: Whops, sorry about language.
[19:32:41] tubbo: norc-1: that's the point. no need to apologize, i curse all the time. :) what i meant was...if this code is just a little syntax sugar over something a bit more explicit, i'd err toward the side of being more explicit (and just copy-pasting) as long as it's not terrible or super-ugly to look at
[19:33:13] tubbo: norc-1: so that's what i mean...if you're gonna write a helper method that has public, global access and you don't think it's worthy of documentation, why is it even worthy of existence?
[19:33:18] norc-1: tubbo: Yeah what I wrote doesnt quite do whats supposed do since I need to do stuff with the controller name
[19:33:27] tubbo: norc-1: this is, of course, only applicable when you work with large teams.
[19:33:38] tubbo: norc-1: did you ever try passing the entire route into `can?`
[19:33:48] Fire-Dragon-DoL: tubbo: "why is it even worthy of existence?" lol
[19:33:52] tubbo: instead of `can? controller, action` that is
[19:34:39] norc-1: tubbo: No. Let me do some work with this, and come back with a fully working proper solution in a few minutes
[19:34:41] tubbo: Fire-Dragon-DoL: "The fundamental question is that of the {code}'s right to exist." [sic]
[19:35:07] tubbo: norc-1: i was curious as to whether that worked actually :)
[19:35:11] tubbo: i don't use cancancan myself
[19:35:25] Fire-Dragon-DoL: tubbo: do you use any alternative or a custom solution?
[19:36:33] norc-1: tubbo: As I said, give me a few minutes Ill get back to you
[19:37:18] tubbo: Fire-Dragon-DoL: on a smaller project that i wrote myself, i use Authority (similar to Pundit)...at work, we rolled our own solution.
[19:38:23] jglover: Seems to me that having lots and lots of pure CRUD controllers is beneficial for readability and work flow. What are some disadvantages, if any?
[19:38:59] Fire-Dragon-DoL: jglover: I suppose, some boilerplate?
[19:40:37] Fire-Dragon-DoL: tubbo: Authority looks exactly like the custom one I've built (which uses cancan internally to get the advantage of sql queries already there)
[19:40:53] jglover: Fire-Dragon-DoL: does that have a negative affect on the app besides a larger code base?
[19:40:58] Fire-Dragon-DoL: looks quite nice, it would be great meeting it earlier
[19:41:10] tubbo: well it's not too hard to convert over
[19:41:26] batasrki: jglover: discipline to doing that is probably the hardest thing
[19:41:26] Fire-Dragon-DoL: tubbo: yeah, but the time is wasted now :P
[19:41:33] batasrki: to keep doing that
[19:41:58] Fire-Dragon-DoL: tubbo: I did even the same, I created Authorizers and added the authorizers directory
[19:42:14] jglover: batasrki: agreed. I'm not going to spend any more time redoing the old app, but we're using an engine for a new feature, and I'm going to try to keep to pristine coding practice.
[19:42:23] jglover: *famous last words
[19:42:50] tubbo: jglover: controllers always map to models period :)
[19:42:56] batasrki: I said at the beginning of a green-field project: "We will do things Rails way", now I deal with custom actions and Angular
[19:42:57] tubbo: you at least need a controller per model, and then possibly a few more
[19:43:08] tubbo: it's a code smell if that's not the case
[19:43:24] jglover: tubbo: a code smell? not sure i know what that is.
[19:44:49] tubbo: jglover: http://en.wikipedia.org/wiki/Code_smell
[19:45:30] jglover: tubbo: cool. that is cool.
[19:45:57] Fire-Dragon-DoL: jglover: it's when you work so much that you poo right in front of the computer. You'll understand the smell while you code
[19:46:28] Fire-Dragon-DoL: (ok my joke was horrrible :P )
[19:46:35] jglover: man, now im not sure who to believe!
[19:46:41] jglover: both of those explanations sounds so legitimate!
[19:46:52] bricker: tubbo noooo
[19:46:59] bricker: that is so disappointed
[19:47:02] bricker: I am disappointed
[19:47:06] batasrki: there can be multiple explanations
[19:48:58] norc-1: tubbo: http://pastie.org/10096677
[19:49:04] norc-1: Tested and it works nicely
[19:49:44] norc-1: Will need a bit of patching to work with procs too, but in basic this gets the job done
[19:51:08] babykosh: rails gods: what???s a good ETL gem
[19:51:37] bricker: babykosh: what's ETL
[19:52:45] batasrki: bricker: run away!
[19:53:23] batasrki: bricker: but, http://en.wikipedia.org/wiki/Extract,_transform,_load
[19:53:40] babykosh: why run away?
[19:54:02] bricker: never heard that term
[19:54:16] STONECOLDDEVIN: etl is extract transform load
[19:54:31] STONECOLDDEVIN: i don't know if a single gem would be appropriate for that sort of thing
[19:54:42] centrx: ETL stands for Electron Transport Layer
[20:04:57] batasrki: babykosh: why a gem for ETL? Aren't ETL tasks fairly specific to the application space?
[20:06:05] babykosh: all ways curious to see what is available
[20:07:22] babykosh: but as also it seems more that ???life may be better if you just code it all yourself???
[20:10:20] harisamin: i'm at a loss
[20:10:22] Sigma00: hah, he left
[20:10:29] Sigma00: and look, he didn't even fucking google 'rails ETL'
[20:10:32] Sigma00: http://www.activewarehouse.info/
[20:10:35] harisamin: been trying to resolve this rubyracer issue for a while
[20:10:53] batasrki: harisamin: what's up guy!
[20:10:59] Senjai: Sigma00: Welcome to #rubyonrails lol
[20:11:25] harisamin: had a runnig app that i haven't touched in a whiel, reinstalled the relevant ruby with rvm but still having issues with rubyracer in bundle install, libv8 btw installs jsut fine
[20:11:40] harisamin: batasrki: hey man, long time no see :), i'm volunteering this year at GoRuCo btw :)
[20:11:56] batasrki: how's Glimpse?
[20:12:03] harisamin: its going well :)
[20:12:14] harisamin: got a surge of users from brazil last week which has been good :)
[20:12:39] harisamin: http://pastie.org/10096723
[20:12:39] batasrki: yeah, saw the tweets
[20:12:46] harisamin: that's the erro ri'm getting when trying to install rubygems
[20:12:51] harisamin: sorry i mean rubyracer
[20:13:20] tubbo: gem install rubygems # inception bro
[20:13:22] batasrki: do you have the command line invocations?
[20:13:40] harisamin: i'm not sure, i haven't run this rails app in a bit
[20:13:57] tubbo: harisamin: is there a way you could get rid of 'therubyracer' and instead use node.js as the js backend?
[20:14:09] Sigma00: harisamin: do you have a js engine installed? like node?
[20:14:15] tubbo: harisamin: it would require you having to install node...
[20:14:30] tubbo: but IMHO it's a lot easier to apt-get install -y nodejs than it is to solve dylib errors
[20:14:40] bricker: I agree with tubbo
[20:15:01] bricker: having node installed also comes in handy for many other reasons
[20:15:03] harisamin: tubbo: can't make that change at the moment
[20:15:04] bricker: lots of software uses it
[20:15:18] harisamin: have this dpeloeyd in serveral servers they way it is...need to fix my local env but not sure
[20:15:37] batasrki: harisamin: is this a Linux machine? or a Mac?
[20:16:08] harisamin: its my local mac dev machine
[20:16:42] batasrki: so installing therubyracer on a mac is tricky sometimes
[20:16:43] norc-1: tubbo: http://pastie.org/10096730 - there is a final version that works with all the conventions of calling link_to.
[20:16:57] batasrki: harisamin: run the gem install command at the bottom of that output
[20:17:02] harisamin: batasrki: yeah i've been on this for hours...i think i've tried evyerthing undert he sun
[20:17:10] harisamin: not sure if xcode 6.3 upgrade borked something
[20:17:24] batasrki: harisamin: quite possible. Did you re-install command line tools?
[20:18:33] harisamin: tubbo: that's what my colleague said
[20:18:34] tubbo: hutch78: using a native app client...there are a few graphical ones, as well as weechat or irssi for the command line
[20:18:37] harisamin: she said just comment it out for now
[20:18:41] harisamin: its just bothering the hellout of me
[20:18:52] harisamin: i'm about to do that tubbo
[20:18:53] tubbo: harisamin: that's why it's not standard practice to use it anymore. therubyracer causes more problems than it sovle.s
[20:18:54] batasrki: harisamin: and you set the architecture flag?
[20:19:01] hutch78: tubbo: any reccomendations on which native app client?
[20:19:20] tubbo: hutch78: i use weechat, seems to work for me. has a large plugin/script archive with scripts written in perl, lua, python and ruby
[20:19:25] harisamin: batasrki: i don't think i did
[20:19:28] tubbo: hutch78: does everything i need it to do
[20:19:38] tubbo: hutch78: but it's command-line, if that matters
[20:19:55] harisamin: i forget why we even have rubyracer...is it for the asset pipleine?
[20:20:11] tubbo: harisamin: yeah, it's to compile stuff like coffeescript (which needs JS)
[20:20:38] hutch78: tubbo: i love that, and it looks sweet!
[20:20:38] harisamin: batasrki: how and what do i set? i'm assuming this is just to install rubyracer correct?
[20:21:26] tubbo: harisamin: arch flags might help when installing other gems w/C extensions...it's a good thing to be aware of imho
[20:21:28] harisamin: batasrki: what have u been up to lately? btw i haven't touched mongo in a while...rails too...been doing some more backedn but mostly ios stuff lately
[20:22:15] batasrki: harisamin: working on a video streaming platform, doing some crazy shit
[20:22:24] harisamin: batasrki: oooh nice dude
[20:22:27] tubbo: batasrki: orly
[20:22:29] batasrki: harisamin: last time I had to install rubyracer I used this command, gem install therubyracer -v 0.12.1 -- --with-system-v8
[20:22:50] harisamin: yeah i think tried that alreayd...will give it another shot since i just reinstalled ruby
[20:23:40] batasrki: tubbo, harisamin: http://stageten.tv/
[20:23:51] harisamin: batasrki: no dice...and awesome checking it our irght now :)
[20:24:00] batasrki: harisamin: how about this way, gem install therubyracer -v 0.12.1 -- --with-v8-dir=/opt/boxen/homebrew/Cellar/v8/3.25.30/lib
[20:24:12] batasrki: adjust the path to point to v8 dir on your machine
[20:24:23] harisamin: le tme try taht
[20:24:29] tubbo: harisamin: once you figure out the proper args, you can use `bundle config.therubyracer --with-system-v8` to save off that config for Bundler to use in the future
[20:24:38] tubbo: you need to tell Bundler "how to run gem install"
[20:24:53] batasrki: tubbo: oh, that's useful
[20:25:02] batasrki: because why would bundler know how to do that itself
[20:25:12] batasrki: it's not like it's supposed to handle all that for the dev
[20:26:32] harisamin: batasrki: yeah that din't work either
[20:26:54] harisamin: "ld: symbol dyld_stub_binding_helper not found"
[20:27:05] harisamin: that's the error i keep getting since reinstalling ruby
[20:27:08] batasrki: which means nothing to mee
[20:27:11] harisamin: before i was getting b8 erors
[20:27:15] hutch78: tubbo, i got weechat in my terminal now, so cool
[20:27:19] harisamin: b8...i meant v8
[20:27:20] hutch78: thanks man
[20:27:39] hutch78: how do i mention people though ?
[20:27:40] tubbo: batasrki: bundler doesn't know what flags you want to pass...for example, some people might want nokogiri to build libxml2, some people might want to tell nokogiri to use the system libxml2
[20:28:04] tubbo: i'm sure if it was *always* the same there wouldn't be flags at all, everything would just be handled in a gemspec file
[20:28:21] tubbo: that's why .bundle/config is a thing and in this case, probably a good idea to commit that to your repo
[20:28:27] tubbo: that way people won't have this problem anymore on your team harisamin
[20:29:10] harisamin: tubbo: true, if i can get it to work :), i'm assuming an xcode update messed something up...i dunno
[20:29:34] harisamin: i just need to stop being stubborn and move on for now...but i can't
[20:29:40] harisamin: ACTION slaps himself in the face
[20:35:06] Senjai: Poll: Should we define an association on both models involved, if only one model uses the association?
[20:35:43] smathy: Senjai, yes.
[20:35:54] tubbo: Senjai: YAGNI.
[20:36:13] Otterpocket: I just want to get all of one model in my view, is it bad practice to use Foo.all in a view? should I do this simple thing in the controller regardless?
[20:36:15] Senjai: Anyone against?
[20:36:47] Senjai: Would like a larger sample size
[20:37:23] tubbo: Otterpocket: i'd set it to an ivar just so it doesn't require changing your view if you want to add filters to that for example
[20:37:30] bricker: Otterpocket: put in the controller
[20:37:44] harisamin: hmm i think i might have installed too new of a verison of v8?
[20:37:48] bricker: Senjai: no, don't define an association unless you're using it
[20:37:56] harisamin: gonna lock it down to the version expeted by libv8,
[20:38:06] tubbo: harisamin: yeah you definitely need to do that...
[20:38:06] harisamin: now i need to install taht version of v8 via brew...
[20:38:07] Senjai: bricker: SO if a store has many pages, pages shouldnt belong to store?
[20:38:10] tubbo: which is irritating
[20:38:18] bricker: Senjai: Would you define a method you're not using?
[20:38:21] tubbo: harisamin: you probably want to build that yourself unless homebrew-versions has a formula for it
[20:38:38] bricker: Senjai: it's not whether it "Should" or not, it's whether it NEEDS to.
[20:38:46] harisamin: tubbo: yeah gonna confirm that
[20:39:03] Senjai: bricker: This comes down to the data modeling for the entire application. If a store has many pages, it makes no sense from an application perspective for a page to not know what store it belongs to, meaning the model is incomplete
[20:39:38] bricker: Senjai: You asked my opinion and I gave it to you, don't feel like arguing about this
[20:39:58] Senjai: bricker: I just want to know why people take your viewpoint is all
[20:40:17] tubbo: Senjai: a Page isn't alive. it doesn't know jack shit.
[20:40:21] tubbo: it's just an object
[20:40:40] tubbo: a Page doesn't really need to know what Store it belongs to...unless you actually need to call page.store at some point
[20:40:42] bricker: Senjai: same reason I don't write and test methods that don't get used - it's a waste of time.
[20:40:50] tubbo: a lot of the time i add those in for convenience.
[20:40:55] Senjai: tubbo: But that page would have a store_id, which itself doesnt use nor define what its own property is used for
[20:40:57] tubbo: but not if i'm not gonna use them
[20:41:13] tubbo: Senjai: on the table, it would have a store_id...yes...
[20:41:16] Senjai: tubbo: instead, some other model defines what that property is used for, meaning that model has more information about that property of page then page does
[20:41:16] tubbo: but not in your code, right?
[20:41:23] Senjai: tubbo: SUre, call page.store_id
[20:41:44] tubbo: Senjai: that doesn't "count" because it's not actually defined in your code :) i know it's part of your code, but AR hides that from you so that you don't have to think about the details
[20:41:56] tubbo: you just have to know that stores have many pages and you can call store.pages
[20:42:22] tubbo: Senjai: i can still see you potentially needing to call page.store at some point, but if you don't have to *right now* there's no valid reason for the has_one other than "it looks nice"
[20:42:25] Senjai: tubbo: But there i dont see the reason for page not to know about its store
[20:42:26] harisamin: tubbo: homebrew-versions's formula is older https://github.com/Homebrew/homebrew-versions/blob/master/v8-315.rb
[20:42:44] tubbo: Senjai: i don't see why a page SHOULD know about its store :)
[20:42:45] Senjai: tubbo: I think it makes it explicit to what that model is coupled to in the system
[20:42:50] harisamin: i guess i can just fcopy taht file and change the archive tag myself
[20:42:53] Senjai: I guess thats subjective
[20:42:58] tubbo: Senjai: at that point it's documentation, which is fine btw
[20:43:01] Senjai: Objectively, I agree with everything you're saying
[20:43:11] Senjai: but I think subjectively I may care more about the documentation aspect
[20:43:19] tubbo: totally valid
[20:43:23] Senjai: tubbo: Thank you for bringing me to that conclusion, I cared about it for the wrong reasons
[20:43:27] tubbo: i meant "no valid reason" in the functional sense
[20:45:24] Senjai: tubbo: Aye, I just needed to talk it through to find out why I cared so much
[20:46:58] smathy: bricker, it's more than just a method, it's documentation of the associations.
[20:48:04] smathy: If you get a large project without those associations it's a huge PITA to work everything out, there's no harm in having them, and you often do end up using them later, and they're great signposts for anyone coming into your project.
[20:48:40] garrypolley: It appears sprockets no longer supports LESS, is there a recommend library to use to fill that gap? https://github.com/rails/sprockets/tree/master
[20:53:50] tubbo: garrypolley: less-rails?
[20:54:09] garrypolley: That's what I'm looking at now. If it is a drop-in replacement that's cool.
[20:55:52] batasrki: harisamin: make sure you put on your yak-shaving t-shirt
[20:56:14] batasrki: harisamin: http://teespring.com/maksesoftwarebetter2
[20:59:50] DasLumberJackYa: see ya men, keep on pounding that keyboard, till next time
[21:01:03] bricker: Bug or expected? https://gist.github.com/bricker/a46bb6abce62dc6d6cfa Conditions to `find_by` are ignored if id is passed.
[21:02:11] bricker: arg, it happens with where().first too
[21:02:22] bricker: this is problematic for me
[21:02:23] tubbo: bricker: probably because :id is a primary key and an index
[21:02:31] tubbo: bricker: that query is retarded dude
[21:02:44] tubbo: id has to be unique, so the rest of the statement doesn't even matter
[21:02:57] tubbo: bricker: are you trying to do "id = ? OR state = 'pending'"
[21:02:57] bricker: tubbo: calling me retarded is not helpful.
[21:03:13] tubbo: bricker: YOU aren't retarded, i love you <3
[21:03:21] bricker: tubbo: No, I want to get a record whose ID and state match the given conditions.
[21:04:13] bricker: "Give me a record with ID=123 and state=approved". "Okay, here's a record with id=123 and state=pending". "That's not what I asked for"
[21:04:16] bricker: See what I'm getting at?
[21:04:56] bricker: That's a perfectly valid query.
[21:06:06] harisamin: not worht it...commeitngin it out and will deal with ths later
[21:06:15] harisamin: ACTION slaps himself again
[21:06:24] harisamin: tubbo: batasrki thanks for your help anyways :)
[21:06:29] batasrki: harisamin: no probs
[21:06:37] batasrki: OSX isn't meant for developers
[21:06:43] batasrki: ACTION runs away cackling
[21:06:43] harisamin: batasrki: did u guys build yoru own live deo straming service or didi u integrate with a third party service?
[21:07:39] batasrki: harisamin: we're building our own. Flash, ffmpeg, Wowza is the video architecture backbone, though backbone is too strong of a word
[21:07:59] batasrki: what's another word for brittle crap stacked vertically on top of each other
[21:10:23] harisamin: batasrki: lol...cool nonetheless :)
[21:10:38] batasrki: harisamin: oh, it's pretty cool and I'm enjoying it
[21:10:41] batasrki: but it has its problems
[21:11:41] bricker: tubbo: ahhhhh
[21:11:46] bricker: tubbo: seems it's a problem with enum
[21:11:48] bricker: that's a huge relief
[21:12:03] bricker: I need to pass the integer for the enum, not the string]
[21:12:11] bricker: I remember seeing this was fixed recently
[21:20:08] dcope: hey all, i'm having trouble understanding how to do something 'the rails way'. i have a fragment that depends on a javascript file, but it's not used outside of the fragment.
[21:20:22] dcope: including it in the view fragment itself feels wrong. how do you all handle this?
[21:25:08] bricker: tubbo: since you called me retarded I want to hear you agree that it's a valid and useful query. I'm just going to sit here and wait.
[21:28:00] bourbon: hi, I've got this error: ActiveModel::MassAssignmentSecurity is neither an Exception nor a String
[21:28:16] bricker: bourbon: please gist the full stack trace and error
[21:28:18] bricker: and relevant code
[21:29:07] bourbon: code: http://hastebin.com/wixiwetase.rb
[21:29:50] bricker: tubbo: for example, imagine a URL scheme like this: /posts/:post_id . You want to use :post_id to find the object, but you don't want to expose unpublished content in case someone happens to type in the ID of an unapproved post. So, you'd lookup by both ID *and* state.
[21:30:16] bourbon: http://hastebin.com/wixenazozu.vbs
[21:30:19] bricker: tubbo: Anyways, I assumed AR was ignoring the other conditions but it was actually just not converting the enum as I hoped it would
[21:31:18] bricker: bourbon: it looks like you're rescuing from ActiveModel::MassAssignmentSecurity, which is a module, not an exception
[21:31:28] bricker: bourbon: you probably want to rescue from ActiveModel::MassAssignmentSecurity::Error
[21:32:51] bricker: But that's just my opinion. I'm retarded, according to tubbo.
[21:33:24] tubbo: bricker: so why do you need the second argument if all of your rows have an :id and each id is unique?
[21:33:48] bricker: tubbo: because id is only one part of the query.
[21:33:57] tubbo: it's not AR that will ignore the other conditions, i think it's the database itself
[21:34:03] bricker: tubbo: no, it's not.
[21:34:09] bricker: tubbo: it's not ignoring the conditions anyways, I was wrong there
[21:34:10] tubbo: feels like that could either return the thing you want or `nil`.
[21:34:26] bourbon: looked back at the logs, found problem
[21:34:27] tubbo: bricker: i still wonder why you need any other part of the query if you already have an id
[21:34:35] bricker: tubbo: because the ID is only one condition that I want to match
[21:34:47] bricker: I have two conditions: That the ID is 123, and that the state is "approved".
[21:34:55] bricker: Give me records which match those two conditions.
[21:35:11] bricker: tubbo: If I left off the "approved" part, then I could get a record that's unapproved, which is bad.
[21:35:22] tubbo: i suppose
[21:35:33] bricker: If there are no records that match my two conditions, give me an empty set
[21:35:39] tubbo: seems like it would be easier to do a find(1).approved? or something
[21:35:39] bricker: you know, how SQL works.
[21:36:02] tubbo: i dunno, seems like two different ways of solving the same problem...just never saw someone solve it like that
[21:36:08] bricker: tubbo: Then I'd have a conditional and have to manually raise an error
[21:36:47] bricker: thing = Thing.find(params[:id]); if !thing.approved?; raise ActiveRecord::RecordNotFound; end < not easier imo
[21:37:58] tubbo: bricker: that's if you want to raise the error
[21:38:14] bricker: tubbo: if I'm using find_by!(), then I want to raise the error. Otherwise I'd use find_by()
[21:38:20] tubbo: like if you want to 404 the page given all of your conditions don't match
[21:38:42] bricker: tubbo: In this example, I'd want it to behave as if they typed in an ID that just didn't exist.
[21:39:11] tubbo: bricker: that's, fundamentally, the part i'm confused about
[21:39:19] bricker: tubbo: You don't want to show them something like, "Sorry this post exists but hasn't been reviewed yet". I mean, maybe, if you're Medium.com or something.
[21:39:30] tubbo: that's true
[21:39:54] tubbo: bricker: it should render a bit of JS that periodically refreshes the page until it's approved :P
[21:40:13] tubbo: polling for changes? nope, we're poking for changes.
[21:40:29] bricker: "Please call the editor and ask him to publish this article: (949)-..."
[21:42:06] bricker: Alas, this all started as most things do: It was a bug in my code and I blamed someone else.
[23:00:59] kalebe: I have a module on lib folder, and i want it to be loaded on a model as I callit dependind of what register the model is loaging on the moment... how can i do that ?
[23:02:03] weaksauce: kalebe gist your code? but in general you could conditionally include or extend the module into your model
[23:02:51] weaksauce: include MyAwesomeModule if register == "ox234"
[23:03:29] weaksauce: include MyAwesomeModule if register == "0xDEADBEEF"
[23:03:59] xibalba: 0XDEADBEEF is my SSID
[23:04:21] xibalba: Reminds me of a 1995 cult of the something cow reference
[23:04:27] xibalba: one of those original windows 95 trojans
[23:04:38] weaksauce: they use it a lot in debugging memory dumps because it's easy to spot
[23:04:41] xibalba: bingo; http://www.cultdeadcow.com/
[23:05:06] xibalba: http://en.wikipedia.org/wiki/Back_Orifice
[23:05:08] xibalba: ah memories
[23:05:15] weaksauce: clicked on it. what kind of list did you just get me on xibalba
[23:05:40] xibalba: yeah dont click that now
[23:05:50] xibalba: i meant the back orifice link
[23:06:04] weaksauce: heh. os x it's all good
[23:06:14] xibalba: did you ever use back orifice?
[23:18:05] Radar: Good morning.
[23:20:07] bricker: GOOD MORNING
[23:22:07] x-light: happy friday radar
[23:22:21] x-light: (sorry to all those who aren't at friday yet)
[23:22:49] Radar: screw those Friday denialists
[23:25:52] bricker: It's not Friday in murica
[23:25:55] bricker: it's not Friday
[23:26:33] bourbon: is there a way to set up CORS for the static resources served from /public?
[23:27:13] bourbon: I'd like to allow cross-domain get on any of the stuff in /public/swag because it's just json files that should be public
[23:34:55] Obfuscate: bourbon: I don't know how to do that in rails itself, but it's trivial if you use apache/nginx to serve your public files, which is a better idea anyways.
[23:36:06] bourbon: I'll just do it in nginx... don't think the ops guy will mind it on dev, at least