« Back to channel list

#RubyOnRails - 17 December 2013

« Back 1 day Forward 1 day »
[00:04:50] Vocino: if i wanted to make a template that had all my go-to gems and stuff that i always use for development to start rails projects, what would that be?
[00:04:50] tubbo: Veske: rails routes it to expect an ID, you have to customize the `resources` route so it won't do that.
[00:05:03] tubbo: Veske: why the hell are you doing this? `Post.find(params[:id]).destroy`?
[00:05:14] tubbo: Veske: you should do @post = Post.find params[:id]; @post.destroy
[00:06:11] lethjakman: is there an easy way to declare a helper method in a controller?
[00:06:14] lethjakman: for the view
[00:06:21] Vocino: is there such a thing?
[00:06:25] lethjakman: I tried helper method_name
[00:06:45] tubbo: Vocino: a rails app template.
[00:06:54] tubbo: Vocino: http://guides.rubyonrails.org/rails_application_templates.html
[00:07:04] Vocino: tubbo: perfect
[00:07:16] tubbo: i use an app template personally that overwrites several files after generation, like application.rb, Gemfile, etc.
[00:07:30] tubbo: also adds a .travis.yml, .env and .rspec file
[00:08:10] Veske: kk will try it tubbo
[00:09:12] Veske: but why is it better to do like that? Doesent my version delete it also?
[00:09:38] tubbo: Veske: maybe, maybe not. how would you even know?
[00:09:39] lethjakman: I need to be ablet o inherit a variable and use it in the view (it's a hash of options) is that possible? can't seem to do it in a helper or in a @ since it's nto pulling down.
[00:09:57] terrellt: Vocino: I use a modified version of https://github.com/thoughtbot/suspenders
[00:10:03] tubbo: Veske: you don't give your action a chance to give you feedback, if Post.find(1) fails it returns nil. then, you call `nil.destroy` and it will throw an error.
[00:11:05] Vocino: terrellt: beautiful, thanks!
[00:11:17] Veske: and the routes part, how is it I make the exeption. right now it looks like this: https://github.com/Veske/form/blob/master/config/routes.rb
[00:11:21] tubbo: Veske: a lot of people do destroys like this:https://gist.github.com/tubbo/a5af4dc353da9e5b39b9
[00:11:50] tubbo: Veske: what's this doing here? https://github.com/Veske/form/blob/master/config/routes.rb#L13
[00:12:18] tubbo: Veske: yeah this won't work because your destroy action expects params[:id] to be there.. `match "/posts", to: 'posts#destroy', via: :delete`
[00:13:20] tubbo: Veske: not sure why you *don't* want to pass an ID in...how will you know which record to destroy? :P
[00:13:56] Veske: no i want to pass an id
[00:14:09] Veske: i have no idea how to make it pass one right now..
[00:14:22] tubbo: Veske: it already does, you have `resources :posts`. delete that match route.
[00:14:42] tubbo: Veske: resources creates a destroy route for you, all you need to do is make a 'DELETE /posts/1' http request.
[00:15:23] Veske: but if I delete that line, it gives me the error: No route matches [DELETE] "/posts"
[00:15:54] Veske: it's trying to delete all /posts but not /posts/1?
[00:16:14] tubbo: Veske: restart your server
[00:16:18] tubbo: Veske: no, it can't find the route
[00:16:23] tubbo: Veske: "No route matches"
[00:16:57] Veske: restart server did not fix also.
[00:17:14] tubbo: Veske: what is with the require line in your routes?
[00:17:45] Veske: umm, i dont remember anymore actually but it was for something
[00:17:50] Veske: for some error...
[00:18:00] tubbo: Veske: lies. you never need to do that.
[00:18:11] tubbo: Veske: that's wrong, means that something *else* is wrong
[00:18:27] Veske: allright, trying to comment it out for now
[00:18:58] tubbo: Veske: make sure `resources :posts` is at the top of the file
[00:19:52] Veske: still no luck
[00:20:21] Veske: had to move it to bottom before because the other get and post requests for posts were now working then
[00:22:22] Veske: But I dont get it now if I have the correct routes with resources :posts, how come it does not find it
[00:24:59] tubbo: Veske: run `rake routes`.
[00:25:01] tubbo: is it therE?
[00:26:03] Veske: i have a post DELETE /posts/:id(.:format) there
[00:26:05] Veske: should be right
[00:27:05] Veske: though, i have different prefixes there, theres also a POST method which has posts prefix not post
[00:27:26] Veske: but both are created from the resources so I dont know whats up with that
[00:27:46] f0ster: does anyone know how i can use select month on a form object, e.g. form_for .. |f|, f.select_month ?
[00:28:01] Radar: Veske: How can I reproduce this problem on my machine?
[00:28:04] Radar: Veske: clone the app and then ???
[00:28:46] Veske: umm, make an account, create a post with it
[00:28:49] Veske: and then try to delete it
[00:29:03] Veske: i pushed the current code to git right now
[00:29:07] Veske: copy that one
[00:31:09] Radar: I can verify the problem exists
[00:31:14] Radar: Error is No route matches [DELETE] "/posts"
[00:31:48] Radar: You should be doing post_path(i) rather than posts_path
[00:31:50] helpa: Veske: http://guides.rubyonrails.org/routing.html - Rails Routing From the Outside In - Rails Guide - by Mike Gunderloy
[00:31:51] Radar: Veske: !routing
[00:32:36] j0llyr0tten: question: shouldn't migrations happen _after_ seed data is loaded in rake db:setup ? makes sense, no?
[00:34:07] Veske: but why did it give routing error when it should have given an error about not having params or something?
[00:35:15] bricker: j0llyr0tten: no, because if your migrations haven't run, then writing data to the database won't work
[00:37:51] Radar: j0llyr0tten: no.
[00:37:56] Radar: j0llyr0tten: Migrations happen first.
[00:38:07] Radar: Veske: because posts_path can still be routed to, it's just you were telling it to go to the DELETE method instead.
[00:38:16] Radar: Veske: routing helpers don't take a method name, so the routing helper was still valid in Rails.
[00:40:27] capin: i have a "def pdf" in a controller.rb file, and now i would like to display the pdf in the view, <controller>/index.html.erb
[00:43:11] j0llyr0tten: bricker: hmm, i'll have to modify my seed data so
[00:43:45] bricker: j0llyr0tten: why would you want to seed your data before the migrations have run? It doesn't make any sense.
[00:44:39] j0llyr0tten: where does one put general application helper code, say code that migrations and seeding could reuse
[00:45:28] j0llyr0tten: bricker: to my mind seeding sounds like data after the tables have been set up but before migrations are run
[00:46:06] j0llyr0tten: bricker: plants grow from seeds :)
[00:47:27] skyjumper: seeding sounds like the aussie definition of 'rooting'
[00:55:00] panchisco: Does anyone know how to change the Modified timestamp on a file sent via send_file? I tried this but it doesn't seem to be working. response.headers["Last-Modified"] = 22.days.ago.httpdate
[01:00:50] mischief: terrellt: still no dice :(
[01:01:03] mischief: i didn't try setting full_host yet though.
[01:12:20] makerop: https://gist.github.com/makerops/7998248 why is this nested form/hidden_field making the hidden field an array?
[01:12:52] makerop: well, not an array, but its throwing a 0 on there for some reason
[01:29:56] thomasfedb: Hey. Having trouble using a route helper within my ApplicationController spec. https://gist.github.com/thomasfedb/7998379
[01:46:31] lethjakman: hrm...so I'm in faye but I can't access request so I can't see the CSRF token. anyone know how I should be doing that?
[02:05:31] willmarshall: What is your preferred way to build a JSON API, guys? I need to render data that's a bit beyond @model.to_json, pulling in Paperclip attachment links and stuff from joins
[02:25:47] Radar: willmarshall: Active Model Serializers
[02:26:09] Radar: thomasfedb: no routes.rb file? :(
[02:26:57] willmarshall: Radar: cleaner than something like JBuilder?
[02:27:06] Radar: willmarshall: much.
[02:27:57] Radar: willmarshall: I did a quick spike on Spree + AMS yesterday: https://github.com/radar/spree/tree/ams/api/app/serializers/spree
[02:28:28] willmarshall: This is looking about ideal
[02:46:37] thomasfedb: Radar, https://gist.github.com/thomasfedb/7999152 there you go.
[02:47:01] Radar: thomasfedb: new_session_path is not generated by resource :session
[02:47:09] Radar: thomasfedb: Why is that not resources :sessions?
[02:48:16] willmarshall: Radar: That shit works perfectly, thank you
[02:48:21] maxdoubt: i'm trying to use my locales in show.html.erb, kinda like how its used via the - u.label :locale_object - is there a rails-ism for definition lists <dl> that functions similarly?
[02:48:24] thomasfedb: Radar, http://guides.rubyonrails.org/routing.html#singular-resources - suggests otherwise.
[02:48:41] thomasfedb: Radar, because you can only have one session.
[02:48:44] Radar: thomasfedb: ok, my misunderstanding.
[02:48:55] Radar: thomasfedb: what does rake routes hsow?
[02:49:16] thomasfedb: Radar, "new_session GET /session/new(.:format) sessions#new"
[02:49:30] Radar: thomasfedb: looks good.
[02:50:20] Radar: thomasfedb: I don't understand how this could be happening.
[02:50:26] thomasfedb: Radar, same boat here.
[02:50:33] Radar: thomasfedb: Can you reproduce it within a new application and put the app on GitHub?
[02:50:54] thomasfedb: Radar, I can try. Unless you're happy with this app?
[02:51:05] Radar: thomasfedb: Any app would do :)
[02:51:11] maxdoubt: i was just thinking it'd be nice if show.html.erb could adjust according to locales like forms do??? maybe worth a gem
[02:51:13] Radar: Just need to see it happening on my machine so I can poke+prod at it.
[02:51:20] Radar: maxdoubt: It can.
[02:51:31] Radar: maxdoubt: Show us the code for your show.html.erb please.
[02:52:59] deryl: gem install gist && gist login && cat app/views/<model>/show.html.erb | gist -f show.html.erb -- # this way you can gist from the commandline in the future
[02:53:11] thomasfedb: Radar, https://github.com/thomasfedb/biblios/tree/feature/styles
[02:53:24] thomasfedb: Radar, be sure to use that branch.
[02:53:26] deryl: the -f is just to name it on gist.github.com so you get the fancy dancy syntax hilighting
[02:53:32] Radar: Wilco delta.
[02:54:33] deryl: and yeah i know i did it the long way with the 'cat' i just couldn't remember the full syntax off the top of my head :)
[02:56:27] mischief: omniauth is a bitch behind a reverse proxy.
[02:57:54] thomasfedb: mischief, I'm glad somebody else figured that out
[02:58:11] Radar: thomasfedb: Great, I can reproduce it.
[02:58:13] mischief: it's not 'figured out' really
[02:58:37] thomasfedb: Radar, a step in the right direction.
[02:58:47] mischief: had to hard-code a url in OmniAuth.config.full_host
[02:58:56] maxdoubt: Radar: I don't have an example, just trying to switch from <strong>Object Field</strong> to something like <strong><%= @object '.locale field' %></strong>
[02:58:59] mischief: which is dumb
[02:59:00] thomasfedb: Radar, much better than those "this happens, but only on this computer and on Tuesdays" style bugs.
[02:59:28] helpa: maxdoubt: http://guides.rubyonrails.org/i18n.html - Guide on i18n by Sven Fuchs and Karel Minařík
[02:59:28] Radar: maxdoubt: !i18n
[02:59:37] Radar: maxdoubt: TL;DR: <%= t(:your_name_goes_here) %>
[03:01:12] Radar: thomasfedb: Weird that the SessionsController tests do not fail.
[03:01:16] jmbrown412: Anybody have any good pros/cons on twilio-ruby vs. twilio-rb?
[03:01:20] Radar: thomasfedb: Maybe a bug in rspec-rails.
[03:02:43] Radar: thomasfedb: Confirmed. Switching back to rspec-rails 2.14.0 fixed it.
[03:02:54] Revokee: Anyone had problems with ec2 firewall after deploy and start a rails server (webrick, test purpose)
[03:03:01] thomasfedb: Radar, right, interesting.
[03:03:35] thomasfedb: Radar, now just to find the bug.
[03:09:24] Radar: thomasfedb: controller_example_group.rb
[03:09:25] Radar: Good luck :)
[03:10:55] thomasfedb: Radar, already got that far. But thanks.
[03:11:34] Radar: yay I'm helping
[03:14:01] thomasfedb: Radar, I think it might be this commit https://github.com/rspec/rspec-rails/commit/b4b490c7a5bbcf863331a15fea7b0db6634b733c
[03:14:05] thomasfedb: But we'll see.
[03:14:53] thomasfedb: Actually, no.
[03:17:48] pigggie: I'm trying to create a route for "/style.css" to serve up a dynamic stylesheet, however it doesn't seem the request even gets to Rails and must be caught by something else. I'm guessing it's trying to serve up a static asset by that name, but I'd really like to use that route! Any ideas?
[03:20:05] Radar: pigggie: Can you show us the code you're using to define this route pelase?
[03:21:06] pigggie: get '/style.css', :to => 'override_stylesheets#show', :as => :site_stylesheet
[03:24:40] pigggie: It works if I change that to "/assets/style.css", but not in production (and I'd rather not use that anyway).
[03:27:21] rhizome: you could use get /style and use a respond_to :css
[03:27:35] thomasfedb: Radar, I think I've got a fix. Just making sure now.
[03:27:43] Radar: thomasfedb: that was quick!
[03:27:53] Radar: pigggie: I don't know sorry.
[03:28:37] pigggie: Radar: No problem :)
[03:30:04] pigggie: rhizome: I just gave that a go, and if I request '/style.x' it routes correctly, but '.css' still just gives a "Not found", so I don't think it gets as far as Rails' routing at all.
[03:31:35] thomasfedb: Radar, just got to add a failing test before I fix it.
[03:32:26] pigggie: By the way, from browser's perspective, is their anything wrong with leaving off the file extension in the <link> tag? If I have to, I'll resort to that.
[03:34:25] pigggie: Could it be the web server itself (Puma)? Or is it some Rails middleware...
[03:37:56] rhizome: pigggie: do you have any respond_to for css in there?
[03:38:15] rhizome: also, I've never seen rails error with a plain "not found"
[03:38:27] pigggie: Yeah, that's there.
[03:39:27] pigggie: It's not a Rails error, just a plain text response "Not found"
[03:39:36] rhizome: you got other problems then
[03:39:59] pigggie: Yeah, just can't pinpoint what's intercepting it :(
[03:40:05] pigggie: I'll keep looking though
[03:54:22] makerop: if I have a hidden field in a nested form, why would it render as name="user[orders_attributes][0][street]" rather than name="user[orders_attributes][street]"
[03:59:22] thomasfedb: Radar, changed 2 characters and deleted a line: https://github.com/rspec/rspec-rails/pull/881
[04:00:04] Radar: I like it!
[04:03:35] thomasfedb: Radar, the way that gem is tested is upsetting.
[04:05:29] thomasfedb: Radar, 15minute test suite also...
[04:05:37] Radar: At least it's thorough.
[04:06:21] thomasfedb: Radar, it's not really. But anyway.
[06:06:23] TigerWolf: Why does calling "stub" in rspec produce a mock? https://gist.github.com/TigerWolf/4b8e84714f3594e91a12
[06:06:34] TigerWolf: Using rspec-rails
[06:06:41] arkiver: What is a good alternative to this gem: https://github.com/socialcast/devise_oauth2_providable. Looks like its not being maintained anymore and specs are not running as well.
[06:06:51] TigerWolf: and also mocha
[06:07:26] TigerWolf: arkiver - https://github.com/subosito/omniauth-rails < Omniauth does oauth 2 - not sure if its what your after
[06:08:50] TigerWolf: Actually https://github.com/applicake/doorkeeper is probably what you are after - just not integrated into devise
[06:22:55] arkiver: TigerWolf: I do need something like doorkeeper. Thanks ! :)
[06:36:46] rk_ralils: i am facing the problem to store the multiple checkboxes in single column here is my gist https://gist.github.com/anonymous/8000924
[06:39:03] funburn: my assets:precompile is failing with "Unexpected token: operator (<) (line: 12559, col: 0, pos: 352459)" how do i figure out which file it was precompiling so that I can troubleshoot it?
[06:39:04] rvanlieshout: and what happens?
[06:40:30] rvanlieshout: back in 5 min
[06:41:47] rk_ralils: <rvanlieshout> what
[06:46:14] Lewix: someone told me that rails developer are superficial. I think he's right =)
[06:47:47] chirag7jain: hey does any one knwo what is others in rails panel
[06:48:24] rvanlieshout: rk_ralils: you've shown the code
[06:48:26] rvanlieshout: but what happens
[06:59:05] rk_ralils: <rvanlieshout> in database course_ids are not stored, in terminal it shows message like Unpermitted parameters: course_ids
[06:59:54] rvanlieshout: rk_ralils: then permit that param :)
[07:00:13] rvanlieshout: add the log to the gist please
[07:01:26] rk_ralils: <rvanlieshout> i use this in enq controller params.require(:enq).permit(:pname, :course_ids)
[07:02:05] rvanlieshout: iirc it should be something like course_ids: []
[07:02:07] rvanlieshout: to allow an array
[07:03:05] chirag7jain: hey can anyone help me with this " Completed 200 OK in 1141ms (Views: 219.9ms | ActiveRecord: 64.1ms | Solr: 0.0ms)" I want to know where the remaining time is spent
[07:03:26] rvanlieshout: chirag7jain: there are a lot of things that could consume time here.. use a profiler
[07:04:13] rk_ralils: <rvanlieshout> where i should this can course_ids: [] use in permit, right
[07:04:54] rk_ralils: <rvanlieshout> my log gist https://gist.github.com/anonymous/8001132
[07:05:46] rvanlieshout: rk_ralils: in the permit yes
[07:05:52] rvanlieshout: but don't know if that's the right syntax
[07:08:55] chirag7jain: rvanlieshout: i have no idea abt profiler can you provide some more detail
[07:09:33] rvanlieshout: chirag7jain: http://guides.rubyonrails.org/v3.2.13/performance_testing.html#profiler
[07:12:27] chirag7jain: can i use this with rails server
[07:12:36] rk_ralils: <rvanlieshout> i use this params.require(:enq).permit(:pname, course_ids: [ ]),log error https://gist.github.com/anonymous/8001207
[07:13:35] rvanlieshout: rk_ralils: you should find some documentation about this
[07:13:50] rvanlieshout: it seems the syntax is different
[07:14:22] rvanlieshout: http://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-permit
[07:14:59] rvanlieshout: :pname, { course_ids: [] }
[07:57:15] BrazenBraden: when you are loading in a bit of view through a partial, does javascript run before or after the partial has been rendered?
[08:01:36] rvanlieshout: BrazenBraden: javascript runs on the client
[08:01:39] rvanlieshout: rails on the server
[08:02:03] BrazenBraden: yea.. but is dom ready triggered before partials?
[08:02:17] rvanlieshout: rails just responds with a single answer
[08:02:24] rvanlieshout: it's just something totally different
[08:02:45] rvanlieshout: how that single response is created or what partials are used really doesn't matter on the client side
[08:03:14] BrazenBraden: ok.. so rails delivers all views and partials in a single response after which JS goes *ping*
[08:03:34] rvanlieshout: js only does ping if you tell it to do so
[08:03:59] rvanlieshout: but the first possible thing would be when the browser sees the line of js in the response
[09:07:55] chirag7jain: my app is failing to open with this url http://www.google.com/url?q=http%3A%2F%2Fwww.mirraw.com%2Fdesigners%2Fdhaanya%2Fdesigns%2Fkasu-necklace-necklace-set%3Futm_source%3Dfacebook%26utm_medium%3Dcpm%26utm_campaign%3Ddiscount_jewelry_12dec%26utm_content%3DDesigner%2BJewelry%2B%254010%2525%2BOff%2B%25282013-12-12%2B143%2529%2B%252810%25216011027830499%2521designer-jewelry-10-off%25210%2529%26utm_term%3DCA%2BIN%2BMY%2BAE%2BGB%2BUS%2BF%2B24-60&sa
[09:07:57] chirag7jain: =D&sntz=1&usg=AFQjCNG1SnFr-j7HoryKR_hHw5HR-MiZBg
[09:08:15] chirag7jain: theres a problem in the cookie its setting
[09:08:19] dogweather: I'd say that's a good thing.
[09:08:42] chirag7jain: can some one help
[09:10:40] chirag7jain: rvanlieshout: can you check this out
[09:14:52] chirag7jain: dogweather: ?
[10:04:50] morenoh169: I want to iterate over all my users, and grab 3 posts from each. I have a user has_many :posts. How do I do this in the controller?
[10:08:49] toretore: User.all.each{|u| u.posts.limit(3) }
[10:09:54] Pupeno_w: toretore: that suffers from N+1.
[10:12:05] tbuehlmann: Pupeno_w, that wasn't a requirement, was it?
[10:12:15] tbuehlmann: gogo u.posts.limit(3)
[10:12:20] tbuehlmann: refactor later
[10:13:02] Pupeno_w: tbuehlmann: I think avoiding N+1 is *always* a requirement, like... not having bugs... but hey, maybe it's just me.
[10:13:06] koneko: sounds pro enough
[10:13:10] toretore: ask stupid questions, get stupid answers
[10:13:25] toretore: n+1 isn't a problem until it is
[10:13:32] toretore: sometimes it's better
[10:13:32] Macaveli: Is it possible to give focus to a next element if I tab on a specific one?
[10:13:40] Macaveli: this.next.focus(); is not working
[10:14:09] tbuehlmann: Pupeno_w, just kidding, of course that's not a good practice. depends on how urgent the requirement is
[10:15:02] toretore: Macaveli: tabindex
[10:15:29] Macaveli: toretore, thanks
[10:16:26] Macaveli: Another question why is my friends tab highlight color in Chrome brown and mine blue?
[10:16:47] Macaveli: He uses Windows me Mac
[10:17:56] workmad3: Macaveli: probably a combination of system settings, monitor colour settings, graphics card config and chrome screwing around with colours for you
[10:18:13] Macaveli: I ain't mad :p I like the blue haha
[10:19:35] workmad3: Macaveli: as you may have guessed, I've had many an annoyance with tweaking colours on a MBP laptop screen to get it looking good, and then looking at it on another machine (or hell, just an external monitor on my MBP) and the colours all change and it looks weird
[10:20:14] Macaveli: workmad3, what MBP are you using?
[10:20:25] workmad3: late '08 15"
[10:20:37] Macaveli: I'm running late 2013
[10:20:43] tbuehlmann: why are macs sos trendy anyway?
[10:20:58] workmad3: tbuehlmann: s/trendy/frickin annoying
[10:21:18] Macaveli: They are like p*rn you have good p*rn (Mac) and bad p*rn (Windows)
[10:21:32] Macaveli: everyone likes it good
[10:21:35] workmad3: Macaveli: what's a linux distro?
[10:21:35] koneko: What is linux then?
[10:21:47] Macaveli: Linux is also good
[10:21:47] tbuehlmann: well, won't start that discussion, sorry :>
[10:22:11] Macaveli: Btw I have a friend who can't even deploy his new source code
[10:22:14] Macaveli: cause he's on windows
[10:22:16] workmad3: tbuehlmann: macs are trendy because they're shiney, expensive and well marketted...
[10:22:17] Macaveli: he always sends me mails
[10:22:23] Macaveli: please deploy my rails code
[10:22:23] waseem_: koneko: Linux is Sex.
[10:22:25] tbuehlmann: workmad3, totally agree
[10:22:26] koneko: He tried vagrant?
[10:22:41] Macaveli: koneko, we are using Mina to deploy
[10:23:04] koneko: Oh, never tried it
[10:23:13] workmad3: tbuehlmann: they're also generally well built, and work pretty well as long as you keep inside the apple ecosystem
[10:23:52] koneko: But with Vagrant it's easy to have a linux box on windows and deploy from within it
[10:23:52] workmad3: tbh, I wouldn't mind a newer model MBP... PCI-e flash solid-state storage for your main drive? yes please :)
[10:24:17] tbuehlmann: then install some other *nix distribution? :)
[10:24:23] workmad3: koneko: easy... but if you're using virtualbox, shit performance :)
[10:24:55] Macaveli: Everyone out there you should check out Mina: https://github.com/nadarei/mina Docs: http://nadarei.co/mina/ workmad3 koneko tbuehlmann toretore
[10:25:00] workmad3: and vagrant charges for their vmware plugin :(
[10:25:00] koneko: workmad3, not really, some of my buddies are using it every day, it's headless so it doesn't take that much
[10:25:04] Macaveli: I really love it :)
[10:25:23] workmad3: koneko: it depends what machine you've got and how much memory tbh...
[10:25:25] tbuehlmann: developing right now on windows with a virtualbox linux vm, works like a charm
[10:25:25] koneko: That said, they all have i7s
[10:25:39] workmad3: koneko: decent CPU and 8-16gb RAM, sure it can run fine
[10:26:04] workmad3: not brilliant... but it also won't slow your machine to a crawl either
[10:26:17] Macaveli: I have no complaints about Mac, only that I feel obligated to own an iPad and iPhone just to make my life complete
[10:26:19] koneko: As a compromise between having Windows and struggling with gems that won't work there and having Linux and struggling with testing the UI I think it's okay
[10:26:32] Macaveli: I love that it all works so good together :D
[10:27:30] koneko: I use Arch, but it's because I don't have to care that much about styling and fonts, but some of the frontend devs I work with use vagrant for development because they can test it with Windows fonts rendering and IE if somebody's into that.
[10:28:13] workmad3: yeah, that makes a certain amount of sense
[10:29:21] workmad3: tbh, I'd probably suggest UI guys use an MBP as their main machine... then they can run virtualized windows and linux boxes for cross-platform testing without too many issues (as opposed to trying to virtualize OS X and dealing with hacintosh builds, etc.)
[10:30:22] koneko: Yeah, that's the best option. If you have the dollars.
[10:30:47] koneko: Kroners in my case
[10:31:46] workmad3: Macaveli: heh :) this MBP is the only bit of apple hardware in the house... and it's a work machine, not my own
[10:32:25] Macaveli: workmad3, I had to buy my own mac before the company would believe that Rails works best on Mac. So now I have 2 identical macs
[10:32:31] Macaveli: 1 from the company 1 from me :D
[10:32:43] Macaveli: 1 for fun 1 for fighting (movie quote) :p
[10:32:48] Macaveli: who knows the movie :p
[10:33:03] workmad3: google does
[10:38:01] Macaveli: this is my rifle this is my gun this is for fighting this is for fun
[10:38:05] Macaveli: my rifle is my MBP
[11:04:53] jokke: i'm having trouble with simple_form + twitter bootstrap 3
[11:05:04] jokke: checkboxes look horrible
[11:05:50] jokke: https://paste.jreinert.com/Zkx/
[11:06:13] jokke: i don't know why
[11:06:16] mikecmpbll: those are some spectacular checkboxes.
[11:06:54] mikecmpbll: so what's the difference between your HTML and boostraps
[11:07:07] jokke: well actually
[11:07:26] jokke: i found this on stackoverflow
[11:07:28] jokke: http://stackoverflow.com/questions/18578205/bootstrap-3-simple-forms-checkboxes
[11:07:53] jokke: and after applying the changes suggested there my html looked alright but the checkboxes didn't
[11:08:42] jokke: here's the changes applied: https://paste.jreinert.com/mH3V/
[11:08:56] jokke: (on the uppermost checkbox
[11:09:50] mikecmpbll: look at the css on the checkbox? got some weird shit.
[11:11:34] jokke: https://paste.jreinert.com/ndVOrt/
[11:11:46] jokke: sorry for scrotting that
[11:11:57] jokke: easier that way
[11:16:14] mikecmpbll: haven't a clue, can't see anything untoward from those first few styles.
[11:18:34] sebkomianos: I have a "last_update" attribute on my model and I want it to track the last time the model was updated, however the date/time is not part of the params so I came up with this: https://gist.github.com/sebkomianos/6fda0d4e75f7ad2e6260
[11:18:40] sebkomianos: is this the "rails" way to do it or is there a better one?
[11:18:52] MartinElvar: I am currently writing some controller spec (rspec & capybara) for my REST api. In my test i need to login, so i wrote a spec helper which basicly sends email and pass to my session controller. My problem is that the post method insist on directing the request against the controller i'm current writing the spec in.
[11:19:03] MartinElvar: Is there any way i can force it, not to?
[11:20:18] MartinElvar: Created a pastebin http://pastebin.com/bFabDdc9
[11:34:03] jarr0dsz: hiya, anyone is using locomotivecms? im thinking of moving static generated content to locomotive but need the multisite feature and documentation is very bad
[11:34:30] jarr0dsz: actually cannot find much info on how to setup multisites in locomotive wondered if anyone has done that before and if its worth the effort
[11:53:48] zeromodulus: does anybody do any elance work?
[11:55:51] toretore: haha elance
[11:56:56] zeromodulus: the sweatshops seem to be doing well on elance.
[11:57:42] koneko: haha well
[11:58:18] Pupeno_w: Am I correct in thinking that I don't need to include "# encoding: UTF-8" anymore when using Ruby >= 2.0.0?
[11:59:02] koneko: I'd say correct
[12:00:01] zeromodulus: I need to make some money.
[12:00:25] workmad3: Pupeno_w: utf-8 is the assumed default encoding now, so yes you don't need it for ruby
[12:00:33] zeromodulus: and I have programming skills.
[12:00:37] Pupeno_w: Woohoo! \o/
[12:01:18] workmad3: zeromodulus: so get a job? do some freelancing and contract work?
[12:01:29] zeromodulus: that's the plan, stan.
[12:01:49] workmad3: zeromodulus: no need to sell yourself for a pittance on elance
[12:01:59] Pupeno_w: Sometimes the smallest things make me overly happy... but then again... I been fighting crazy encoding issues much more than any human should, so any small step towards getting rid of everything but UTF-8 makes sense to me.
[12:02:21] zeromodulus: right, I don't think I could compete on elance with the Indians and the Chinese.
[12:02:33] zeromodulus: working for pennies.
[12:03:06] workmad3: zeromodulus: you'd be working for pennies on stupid jobs for people that don't have a clue what they really want and are asking for the moon on a stick
[12:03:22] j0llyr0tten: how do i get images in vendor/assets/stylesheets/images/ into my app in production?
[12:04:11] zeromodulus: workmad3: sounds about right.
[12:06:01] mikecmpbll: j0llyr0tten: that seems a silly place to put images ;d
[12:06:19] mikecmpbll: j0llyr0tten, but that said, it shouldn't be any different from any other asset location iirc
[12:06:20] zeromodulus: I would like a programming job.
[12:06:28] mikecmpbll: images/image_name.gif
[12:07:35] Advocation: https://gist.github.com/Advocation/3783be06b1f4ca4ed7fc - why am I getting "undefined local variable or method `host'" on _host.html.erb? Am I not passing in host correctly?
[12:07:41] Advocation: nub question I know
[12:07:49] Advocation: never really worked with partials before
[12:08:09] mikecmpbll: not object: host
[12:08:26] Advocation: haha, oh geesh
[12:08:27] workmad3: or just 'render 'admin/shared/host', host'
[12:08:27] mikecmpbll: Advocation: any way you should be using render @hosts ;)
[12:08:47] Advocation: oh really? How would that pick up the path to the shared?
[12:08:58] j0llyr0tten: mikecmpbll: vendors put their images there, not me?
[12:09:28] j0llyr0tten: mikecmpbll: vendor css files reference images relative to where they are
[12:09:53] j0llyr0tten: i found the answer on stackexchange but i am unsure why it is not the default
[12:09:56] j0llyr0tten: config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif]
[12:10:06] j0llyr0tten: http://stackoverflow.com/questions/8052865/rails-3-1-asset-pipeline-why-my-images-do-not-precompile-for-production
[12:10:21] mikecmpbll: Advocation: render partial: 'admin/shared/host', collection: @hosts
[12:10:37] Advocation: mikecmpbll: pooh, perfect
[12:10:49] mikecmpbll: or put your _host partial in hosts/_host, unless you have a reason not to!
[12:11:16] Advocation: it's used over several views belonging to different controllers..
[12:11:23] Advocation: should it still go in hosts/_host?
[12:12:11] mikecmpbll: that's how i structure stuff, yeah.
[12:12:33] mikecmpbll: makes sense to me, nothing stopping you rendering it from other places.
[12:13:13] Advocation: ok, fair point, I'll move it
[12:13:18] mikecmpbll: j0llyr0tten: and that works now?
[12:13:20] workmad3: 'render @hosts' with a collection of Host objects will default to looking for hosts/_hosts for the partial
[12:13:38] workmad3: *hosts/_host
[12:13:58] j0llyr0tten: mikecmpbll: just checkin, hold tight!
[12:15:00] Advocation: workmad3: this is inside a namespace, so it's trying to look in /views/host, when I need it to look in /views/admin/host. 'render @hosts' is throwing an error for that reason I think
[12:15:08] Advocation: I'll bear that it mind next time I need it though!
[12:16:54] mikecmpbll: Advocation: yeah i guess it has no way of knowing that unless the model is namespaces too, perhaps.
[12:17:19] Advocation: mikecmpbll: yeah, and I didn't want to put the models in there too. Makes sense though :)
[12:17:47] Advocation: I'm correct in assuming that if I want to access the same model from inside and outside the namespace, I would need two controllers, one inside and one outside?
[12:18:05] Advocation: that's how I've got it at the moment and it's working, just wasn't 100% certain I wasn't missing some trick
[12:18:50] mikecmpbll: Advocation: that's normal if you have different routes and you're doing/rendering different things, yus.
[12:23:16] j0llyr0tten: mikecmpbll: nope, it didn't work due to fingerprinting
[12:23:20] j0llyr0tten: mikecmpbll: http://stackoverflow.com/questions/7375810/rails-3-1-asset-pipeline-turn-off-image-asset-fingerprinting-on-heroku
[12:24:59] mikecmpbll: j0llyr0tten: the problem, I assume, is that your vendor stylesheet is referencing images statically, rather than with the asset helpers?
[12:26:03] j0llyr0tten: mikecmpbll: why would it use an asset helper when it is not a rails specific project?
[12:28:38] workmad3: j0llyr0tten: it wouldn't... which means that in order for you to use it, you need to modify it to use asset helpers
[12:29:08] workmad3: j0llyr0tten: or you turn off file digests in compiled assets and deal with not being able to do cache-busting when assets change
[12:29:24] BrazenBraden: strange question... but how would one modify rails to add a route that is included by default when you say 'resources :blegh'?
[12:29:43] BrazenBraden: so, you have show, edit, update, etc, etc, my_route
[12:32:09] j0llyr0tten: can i selectively turn off file digests in compiled assets?
[12:32:12] mikecmpbll: or put the images in /public/ i spose
[12:36:34] lxsameer: hi guys, where does require_asset look for its given parameter ?
[12:56:01] sebkomianos: what's the best way to update a model with attributes from params and one or more extras?
[12:56:25] sebkomianos: say, for example, the current date and time
[13:01:51] elaptics: sebkomianos: just merge in the couple of extra things in the params hash
[13:02:23] elaptics: sebkomianos: e.g. params[:user].merge(foo: "bar", baz: "quuz")
[13:03:13] chirag7jain: session cookies causing application to fail
[13:03:29] sebkomianos: elaptics: cool, that's what I am currently doing but I wanted to get some validation on whether it's okay to mess with the params hash or not, thanks!
[13:03:54] chirag7jain: does anyone have idea how to debug this
[13:05:02] elaptics: chirag7jain: fail how?
[13:05:37] chirag7jain: i go this url http://www.google.com/url?q=http%3A%2F%2Fwww.mirraw.com%2Fdesigners%2Fdhaanya%2Fdesigns%2Fkasu-necklace-necklace-set%3Futm_source%3Dfacebook%26utm_medium%3Dcpm%26utm_campaign%3Ddiscount_jewelry_12dec%26utm_content%3DDesigner%2BJewelry%2B%254010%2525%2BOff%2B%25282013-12-12%2B143%2529%2B%252810%25216011027830499%2521designer-jewelry-10-off%25210%2529%26utm_term%3DCA%2BIN%2BMY%2BAE%2BGB%2BUS%2BF%2B24-60&sa=D&sntz=1&usg=AFQjCNG1SnFr
[13:05:39] chirag7jain: -j7HoryKR_hHw5HR-MiZBg
[13:06:02] chirag7jain: and then if i try to vist any other page on the site. the application throws a timeout error
[13:06:56] chirag7jain: i have identified the error is being caused by the cookie vars
[13:07:45] universa1: chirag7jain: gist the error trace from the log please.
[13:08:22] Pupeno_w: What's the gem that's going to be used in rails 4.1 to keep a vm running to load tests faster?
[13:08:34] universa1: Pupeno_w: spin
[13:09:28] chirag7jain: i have hosted the app on heroku and its just giving a timeout error
[13:10:31] universa1: chirag7jain: so look in the log what is happening.
[13:10:46] marjinal1st: how can i create a relation between host application model and mountable engine model?
[13:10:55] chirag7jain: the log is just giving a timeout error
[13:11:08] elaptics: chirag7jain: you might have to do more to get to see useful logs, like use one of the logging add-ons
[13:11:42] elaptics: chirag7jain: logentries is pretty good
[13:12:56] rvanlieshout: hmm.. never mind
[13:13:14] chirag7jain: i will try that
[13:13:44] chirag7jain: but can you have a look at this __utmz=19389988.1387269786.954.118.u=f|u=2@1% this is the part of cookie that is causing the error
[13:14:52] elaptics: chirag7jain: without knowing much more about the app it's meaningless
[13:15:06] elaptics: we need code and errors to be able to give you any help
[13:15:32] marjinal1st: how can i create a relation between host application model and mountable engine model?
[13:15:58] elaptics: marjinal1st: you mean like a has_many?
[13:16:35] elaptics: marjinal1st: if so, then something like has_many :foo, class_name: Engine::Model
[13:16:36] marjinal1st: elaptics: yes, in host application I have Admin model, in engine I have Blog::Post
[13:16:56] elaptics: marjinal1st: if so, then something like has_many :posts, class_name: "Blog::Post"
[13:17:10] marjinal1st: elaptics: and Blog::Post model? belongs_to?
[13:18:13] Pupeno_w: What do you guys think about bootstrap? is it useful? do you use another library similar to bootstrap?
[13:18:16] elaptics: marjinal1st: well that's more questionable - if the engine is meant to be relatable, I'd have expected there's some hooks for you to do so in some way. The brute force way is to reopen the class in your application and add the belongs_to in
[13:18:43] elaptics: marjinal1st: not least because the belongs_to means that the blog post needs to have fields to store the relation id in
[13:19:08] elaptics: marjinal1st: I would assume there's likely some polymorphic thing on it that you should use?
[13:20:35] marjinal1st: elaptics: Nope, i'm not using a polymorphic system (through :blabla thing) Do I just need to use "belongs_to :admin, class: "Admin" in Engine model?
[13:21:29] elaptics: marjinal1st: no, because the post model needs the fields in its table for the belongs_to relationship
[13:21:50] elaptics: so does the post model in that engine have a field for the purpose of relating it to some other model?
[13:22:04] pontiki: morning railsanistas
[13:22:43] elaptics: pontiki: morning, I prefer railsist :)
[13:22:44] marjinal1st: elaptics: yes
[13:22:54] elaptics: marjinal1st: and what's it called?
[13:23:13] pontiki: what does the railsist say?
[13:24:22] marjinal1st: elaptics: (maybe it's just i'm a newbie :) ) I just want to relate Admin and Blog::Post model and I want to use @post.admin to get admin info
[13:24:41] elaptics: marjinal1st: what is this engine you're using?
[13:25:28] marjinal1st: elaptics: what do you mean? I've created a rails mountable engine, minimal blog cms
[13:26:33] elaptics: marjinal1st: it's your engine?
[13:26:55] elaptics: i.e. you've created it, not someone else's gem?
[13:27:04] marjinal1st: elaptics: I've created it
[13:28:04] elaptics: marjinal1st: ok, so I'm guessing you haven't added in a way to allow the posts to be relateable to some other random model?
[13:28:23] marjinal1st: elaptics: yes
[13:29:35] elaptics: marjinal1st: what you need to do is add a polymorphic belongs_to to your post model and then refer to it using your application's admin model
[13:29:41] elaptics: marjinal1st: see more info here http://guides.rubyonrails.org/association_basics.html#polymorphic-associations
[13:30:07] elaptics: marjinal1st: e.g. you'd want something like belongs_to :bloggable, polymorphic: true in your post model
[13:30:38] elaptics: then in your admin model, you'd do something like has_many :posts, as: :bloggable
[13:30:57] elaptics: not sure if that'll just work if the engine is mounted
[13:31:07] elaptics: try it and see
[13:31:13] marjinal1st: elaptics: can Admin model get the relation b
[13:31:20] marjinal1st: elaptics: with that way?
[13:31:34] marjinal1st: elaptics: ok, I'll give a try
[13:31:58] elaptics: marjinal1st: admin gets it through what you set up with the has_many
[13:37:39] ace_striker: hey..everybody..
[13:38:40] ace_striker: when i issue this command => "$ rails generate migration add_index_to_users_email" how does rails now which db to choose for it.
[13:38:52] ace_striker: when i issue this command => "$ rails generate migration add_index_to_users_email" how does rails knows which db to choose for it.
[13:39:25] rvanlieshout: ace_striker: it'll just generate a migration file for you to edit
[13:39:50] rvanlieshout: it might try to parse the name and prefill it for you
[13:40:00] rvanlieshout: but just open the generated file and make sure it contains the things you want to migrate
[13:40:29] ace_striker: got it.. i have to edit it myself ..
[13:40:36] ace_striker: thanks rvanlieshout
[13:46:04] khoury: Hey people
[13:46:10] khoury: I have a really strange problem
[13:47:02] khoury: I have a page where my users fill in some information which gets sent to my controller and so on. For some reason, when tailing the dev log, I see that the email field is sent empty.
[13:47:19] khoury: I have no idea why. I fill it in and it's empty every time.
[13:47:59] rvanlieshout: khoury: open a javascript console in your browser
[13:48:08] alex88: khoury: tried to print from the controller? checked the data browser is sending?
[13:48:21] rvanlieshout: khoury: type $('input') or $('input[name=email]') or whatever name your input has
[13:48:30] rvanlieshout: verify that you don't have multiple inputs with the same name
[13:48:38] rvanlieshout: cause in that cause the last would be submitted
[13:48:45] khoury: Yes, I get an error in my controller basicaly saying email in nil
[13:48:53] khoury: Well yes, thats the thing also
[13:48:57] khoury: I have two different forms
[13:49:13] khoury: I let the use click "new user" or "I have an account"
[13:49:13] rvanlieshout: accidentialy nested them?
[13:49:20] rvanlieshout: cause you can't nest forms
[13:49:23] khoury: And with javascript I hide or show two different forms
[13:49:34] khoury: Both have email and password fields
[13:49:41] khoury: but theres no problem with the password field
[13:50:02] khoury: I have a gist over the form, one sec...
[13:50:07] rvanlieshout: what is returned if you execute $('..your form..').serialize()
[13:50:10] rvanlieshout: before you submit
[13:50:26] khoury: https://gist.github.com/anonymous/8005120
[13:50:28] alex88: khoury: paste also the full html output of the forms
[13:50:53] rvanlieshout: khoury: create two forms
[13:50:56] rvanlieshout: not only fields_for
[13:51:22] khoury: hmm ok, but the thing is it's sort of nested.
[13:51:49] khoury: Ads and users basically.
[13:51:49] rvanlieshout: nested in what?
[13:52:02] rvanlieshout: the thing you've pasted are two colums that each could have a separate form
[13:52:56] khoury: ??But then how come all the other fields are sent correctly and not email?
[13:53:19] rvanlieshout: dunno.. browsers can do strange things
[13:53:26] rvanlieshout: and all others would only be password
[13:53:45] khoury: I have like Ads and Users. A user can post an ad and fill in a new user form, or post an ad and fill in login-form. Thats the idea
[13:54:11] rvanlieshout: ah right.. then you might just have to change the name of your fields_for thing
[13:54:13] khoury: But I think the way I have made the form is a bit fucked up
[13:54:20] rvanlieshout: to make the field names unique
[13:54:44] khoury: hmm I will try that.
[13:57:03] ace_striker: it just confuses me ..where the spec with it{should_no be_valid} should pass or not after applying the validation
[13:57:24] universa1: ace_striker: what?
[13:57:40] universa1: expect(subject.valid?).to be_false
[13:57:54] ace_striker: on this gist : https://gist.github.com/igauravsehrawat/8005269 if i don't use @user.save then it gives me no rspec failure.
[13:58:44] universa1: ace_striker: how should the email already be taken if there's no saved record?
[13:59:15] ace_striker: universa1: thanks.. but when i use @user.save there is should_not be_valid ..spec failure..
[13:59:38] ace_striker: i am bit confused on that.
[13:59:58] universa1: ace_striker: actual code which raises the error + the spec output please.
[14:00:16] ace_striker: my mistake ..a sec
[14:00:48] workmad3: ace_striker: it's because you're not setting your expectation on the new (invalid) record
[14:01:09] workmad3: ace_striker: you're still doing 'it {should_not be_valid}' which is running the expectation against the original, valid @user object
[14:01:28] workmad3: ace_striker: while it's 'user_with_same_email' that is invalid
[14:01:33] ace_striker: https://gist.github.com/igauravsehrawat/8005316 this is my validation
[14:02:31] universa1: ace_striker: and workmad is correct...
[14:04:07] khoury: rvanlieshout: that helped with setting another name for the other field. Thx
[14:04:47] khoury: Very strange though how only the email field would be effected, but whatever. Aliens.
[14:06:16] ace_striker: universa1: workmad3 but when i comment out @user.save ..the spec passes ..then also it{should_not be_valid} should raise error ..?? i mean when checking the db i am checking against some values ..so i have to save each entry separately.
[14:07:23] workmad3: ace_striker: right... when you remove the @user.save, then 'user_with_same_email.save' suceeds, which means that when @user.valid is checked it is no longer valid because user_with_same_email has that email address and is saved
[14:12:09] Abhijit: my rvm list known do not list any rails packages on ubuntu 12.04?
[14:12:46] workmad3: Abhijit: doesn't 'rvm list known' show you ruby versions you can install?
[14:12:48] rvanlieshout: Abhijit: that's because rvm is a Ruby version manager
[14:12:50] rvanlieshout: not a Rails version manager
[14:13:21] Abhijit: workmad3, yes it shows ruby versions
[14:13:30] workmad3: Abhijit: right... rails isn't a ruby version...
[14:13:41] Abhijit: rvanlieshout, there is no rails 4 in default repo on ubuntu. how can i install rails 4?
[14:13:55] rvanlieshout: Abhijit: in what ruby version?
[14:13:56] helpa: Abhijit: For a *FREE*, online book on learning Ruby On Rails, please see http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
[14:13:57] workmad3: Abhijit: !railstutorial
[14:14:02] Abhijit: rvanlieshout, 1.9.2
[14:14:17] workmad3: Abhijit: section 1.2 of that does installation
[14:14:19] rvanlieshout: Abhijit: read the tutorial :) Installed 1.9.2 already? Then just 'gem install rails'
[14:17:46] ace_striker: ok..i get it .. block it{should_not be_valid} will show when it is false
[14:18:56] Criten: is there a good way to change what migration rails thinks its on in rails?
[14:19:00] Criten: like through the consoel
[14:19:18] universa1: ace_striker: it {should_not be_valid} is esentially: it "is not valid"; expect(subject.valid?).to be_false; end
[14:19:43] universa1: Criten: you shouldn't ever need to do such a thing.
[14:20:11] rvanlieshout: it uses the schema_migrations table for that
[14:20:31] rvanlieshout: but in most cases you just need to create a new migration
[14:20:59] workmad3: Criten: also, use a database that supports DDL transactions :P
[14:21:26] workmad3: (I'm guessing that the question is driven by a partially applied migration in mysql)
[14:21:27] Cork: is there something like reverse_deep_merge! or do one have to do val1 = defaults.deep_merge(val1) ?
[14:22:05] Criten: I pulled in the production dump into the staging site and i'm trying to run a migration and it's angry at me... I guess i should look who broke the migration history..
[14:22:14] rvanlieshout: Criten: that's something different
[14:22:16] Criten: because something weird hapened
[14:22:30] rvanlieshout: it tries to create a table that already exists?
[14:22:43] Criten: rvanlieshout, exactly
[14:22:51] rvanlieshout: you didn't drop that table when applying the production database
[14:22:52] ace_striker: universa1: actually it{should_not be_valid} simulates @user.save ..am i correct ?
[14:22:58] workmad3: ace_striker: no
[14:23:03] rvanlieshout: it will only contain drop table things for tables that already exists in production
[14:23:18] Criten: rvanlieshout, shouldn't it not matter? because the migration data should be saved in the db?
[14:23:19] rvanlieshout: the schema migrations table will be replaced so rails would assume the migration hasn't been done
[14:23:22] workmad3: ace_striker: it does @user.valid.should_not be_true
[14:23:39] rvanlieshout: Criten: the migration data is replaced by your action.. where you didn't clear your database first
[14:23:48] workmad3: *@user.valid?.should_not be_true
[14:24:01] workmad3: ace_striker: i.e. it calls .valid? not .save
[14:24:17] rvanlieshout: Criten: so drop all tables and apply production db again
[14:24:30] universa1: ace_striker: no
[14:24:46] workmad3: universa1: stop watching videos and pay attention? ;)
[14:24:58] workmad3: universa1: nice that our responses are exactly the same though :D
[14:24:59] universa1: workmad3: was reading the star trek thingie ;)
[14:25:17] universa1: workmad3: hehe ;)
[14:26:20] ace_striker: thanks workmad3 universa1
[14:26:42] universa1: ace_striker: be_valid is some rspec magic, iirc: it strips of the be_ looks for a valid? (not sure about the question mark stuff) method on the subject, calls it and checkts that the result is true if you're calling should be_valid and false if you're calling should_not be_valid
[14:27:31] workmad3: universa1: it adds the ? onto the method it looks for
[14:27:37] universa1: ace_striker: this should work for example: expect(subject).to be_persisted
[14:28:08] Criten: rvanlieshout, i just deleted the one table that it thought was there and all is good
[14:28:17] Criten: well.. the one it was trying to re-create
[14:28:26] Criten: i'm wondering if i'll have this problem on production when i push this..
[14:28:32] rvanlieshout: if the only thing in that migration is the creation of that table then you're good
[14:28:39] workmad3: universa1: there's also the have_ variant, which will change have to has, append a ? and check the resulting method, e.g. doing 'page.should have_content("foo")'
[14:28:42] rvanlieshout: Criten: you won't.. it doesn't already have that table
[14:29:00] Criten: I think it does though
[14:29:16] Criten: because i did reset the db (cleared all tables) then the migration complained again
[14:29:19] Criten: so i just dropped that one table
[14:29:21] Criten: and it worked
[14:29:40] workmad3: Criten: did you add a table that got created in a previous migration? :P
[14:29:43] universa1: workmad3: yeah :-) i remember that one ;) just replacing everything with the newer expect(...).to stuff ;) kinda like it
[14:29:59] Criten: workmad3, i haven't made a migration on this project in a while :P
[14:30:16] Criten: Just trying to update the staging db
[14:30:18] universa1: Criten: read the question: is there another migration which created the same table
[14:30:47] Criten: universa1, as i said.. i'm going to have to go through the history and look at the migrations.
[14:31:19] universa1: Criten: yes, you really should do this.
[14:31:24] workmad3: Criten: grep "table_name" db/migrate/*
[14:32:32] Criten: Just the one
[14:33:19] workmad3: Criten: ok... so how did you drop the database?
[14:33:40] Criten: the schema for this had already been pushed to production just not the frontend stuff... but i'm wondering why it's trying to re-run that migration after i import it to staging
[14:34:00] Criten: workmad3, through rails c > ActiveRecord::Migration.drop_table(:table_name)
[14:34:15] Criten: after i dropped it, it worked fine
[14:34:18] rvanlieshout: Criten: you can verify that
[14:34:24] rvanlieshout: clear your db and apply the production database
[14:34:27] rvanlieshout: then just run migration
[14:34:28] workmad3: Criten: I mean before that... how did you reset your database before re-running the migrations?
[14:35:48] Criten: rake db:schema:dump
[14:36:20] rvanlieshout: workmad3: he / she didn't drop tables that don't exist in production
[14:37:40] workmad3: Criten: that doesn't reset the database
[14:37:48] Criten: I didn't want to reset it?
[14:38:14] Criten: Just wanted to clear it so i could restore from the production dumb
[14:38:22] workmad3: Criten: rvanlieshout said you should reset the database... you then said you'd done that and that you still had the conflicting table there
[14:38:36] workmad3: Criten: right... you wanted to reset it
[14:38:43] workmad3: Criten: schema:dump doesn't change the database
[14:39:15] Criten: oh wait... yeah i ran heroku run rake db:reset
[14:39:31] Criten: Sorry... got a few things going on
[14:39:47] Criten: Anyway.. I got it working regardless... I need to head to a meeting.. i'll investigate this more later
[14:39:50] workmad3: Criten: and did that run successfully? (heroku can be a bit weird with resetting the database)
[14:39:59] Criten: Yeah.. it ran without error
[14:40:01] workmad3: Criten: just seems like your 'problem' is self inflicted ;)
[14:40:16] workmad3: Criten: enjoy your meeting :)
[14:40:16] rushed: multitasking ftw~
[14:41:43] Criten: workmad3, i'm not doubting that it's not self-inflicted at all :P infact it most likely is...
[14:42:13] Criten: I've done this plenty in the past and I've never had a problem migrating a production db to a staging server :/
[14:42:18] Criten: anyway.. have fun everyone :P
[14:42:46] rvanlieshout: Criten: you would only have this problem if you have a table that doesn't exist in staging / production yet
[14:42:50] rvanlieshout: not for table changes
[14:43:35] Criten: what if some dumbass deleted a migration and re-made it? kind of what i'm thinking right now..
[14:44:44] rvanlieshout: restore it from git indeed :)
[14:45:39] workmad3: Criten: well, from what you said... you added a migration that added this table and ran it locally... then you pulled in the production db dump, which would have altered the values in the schema_migration table so that your migration was now regarded as not-run
[14:45:57] workmad3: Criten: so when you then run migrations, your new migration tries to re-run
[14:46:16] Criten: "I haven't created a migration in this project for a while" :P
[14:46:26] workmad3: Criten: you then run db:reset which, afaik, runs migrations back down to 0, still leaving your table there
[14:46:29] Criten: and this doesn't have to do wit hanything local
[14:49:42] lurraca: Is there advantages to using draper vs rolling my own decorators?
[14:51:15] tbuehlmann: lurraca, you don't have to roll out your own decorator gem/engine/library. also, draper has been used by some devs, so you can expect certain quality
[15:03:23] Advocation: If I have a helper within a namespace, and I am calling one of the helper methods from a controller also in that namespace, do I need to reference the namespace in the method call?
[15:04:26] helpa: Advocation: Why don't you try it and find out for yourself?
[15:04:26] crankharder: Advocation: !try
[15:07:19] EspenA: I thought protect_from_forgery was supposed to disable POST without authenticity_token. It only seems to reset session in Rails 3.2?
[15:07:55] epochwolf: EspenA: correct.
[15:08:07] epochwolf: EspenA: Rails 3.2 resets the session on a bad token
[15:08:27] erichmenge: EspenA: http://guides.rubyonrails.org/security.html#csrf-countermeasures
[15:08:37] EspenA: epochwolf: but then the unauthorised post is still executed
[15:08:45] epochwolf: EspenA: oh?
[15:09:12] erpa: if anybody is into turbolinks and uses piwik for tracking - am i the only one who is experiencing strange differences in what/url is beeing tracked (browser-wise)
[15:09:14] erichmenge: EspenA: Are you using cookies for user state?
[15:09:17] epochwolf: EspenA: that shouldn't happen unless you're messing with rails internals or doing something really funky.
[15:09:40] erichmenge: epochwolf: It is actually quite easy to do if you use the cookie store and roll your own authentication
[15:10:02] epochwolf: erichmenge: oh... I see.
[15:10:03] workmad3: or if you forgot to require your post actions to have a valid session
[15:10:12] EspenA: epochwolf: what should occur after session is reset you mean? Considering just a simple POST without any other auth or session info
[15:10:27] erichmenge: okay workmad3 diagnosed it correctly :)
[15:10:32] epochwolf: EspenA: the session is reset before the controller is called.
[15:10:34] erichmenge: EspenA: session reset just clears the session cookie
[15:10:54] erichmenge: if your controller doesn't do any authentication checks it will happily do whatever.
[15:11:00] workmad3: you can configure the protection to raise an exception, iirc
[15:11:12] Advocation: crankharder: I have tried it's - I'm not quite sure how I would reference the helper..
[15:11:17] erichmenge: EspenA: Are you new to Rails? Why not use Rails 4 where it raises an exception by default?
[15:11:46] epochwolf: oh, rails 4 is back to the exceptions?
[15:11:54] epochwolf: All hail rails 4.
[15:11:55] EspenA: erichmenge: were some issues with upgrading
[15:12:06] erichmenge: epochwolf: It was a compromise apparently that they did it the wrong way in Rails 3
[15:12:15] erichmenge: So easy to shoot yourself in the foot.
[15:12:17] Advocation: crankharder: however if I call it without referencing the namespace it throws a undefined local variable or method error
[15:12:20] epochwolf: erichmenge: they did a lot of wrong shit in rails 3.
[15:12:29] epochwolf: and a lot of right shit
[15:12:45] EspenA: erichmenge: yeah "the wrong way", exactly my thoughts as this only stops CSFR when using authentication
[15:12:46] crankharder: Advocation: show your code and the error
[15:12:47] helpa: Advocation: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[15:12:47] crankharder: Advocation: !gist
[15:13:06] erichmenge: I just wonder how many Rails 3 apps out there are vulnerable to CSRF because they think CSRF protection will save them when it isn't configured properly.
[15:13:33] erichmenge: EspenA: Well, I'm not saying it is incorrect because of that specifically.
[15:13:39] erpa: If anybody into turbolinks has a moment: https://gist.github.com/erpe/7995523
[15:13:44] erichmenge: EspenA: You need to protect your routes.
[15:14:22] workmad3: EspenA: it stops a request from a 'bad' source from using any session data, which is arguably a correct response for CSRF protection
[15:14:45] EspenA: erichmenge: this is a public form, a CSFR-token would be the appropriate protection ( I assumed)
[15:14:57] Advocation: crankharder: https://gist.github.com/Advocation/cdf448619c7884f9d29f
[15:15:03] erichmenge: EspenA: Well, if you don't care who posts to it why do you even care if it is cross site protected?
[15:15:46] erichmenge: EspenA: CSRF protection keeps malicious sites from making an unsuspecting user post something to their own account against their will
[15:15:47] EspenA: erichmenge: a good way of figthing off spam robots I think
[15:15:55] erichmenge: EspenA: bots can have session data.
[15:16:01] workmad3: EspenA: spam robots would just post through your form
[15:16:02] erichmenge: If I wrote a spam bot of course I would support cookies.
[15:16:06] epochwolf: erichmenge: most bots aren't smart bot.
[15:16:13] EspenA: epochwolf: exactly
[15:16:14] erichmenge: epochwolf: You think they don't even support cookies?
[15:16:31] erichmenge: I don't know much about it, so this may be correct.
[15:16:40] epochwolf: erichmenge: most bots are just dumb curl scripts.
[15:16:42] workmad3: EspenA: CSRF protection isn't intended or suitable for preventing bots
[15:16:50] AntelopeSalad: if you wanted to build a custom app template, would it be best to put as much as possible as custom generators?
[15:16:51] EspenA: erichmenge: not saying it it is a perfect solution but helps to have a token
[15:17:03] epochwolf: erichmenge: that said, there's a ton of bots that are full browsers
[15:17:05] AntelopeSalad: and then have the app template call the generators, rather than inline the changes in the app template?
[15:17:31] universa1: Advocation: are you sure that code should be in a helper? do you have some line in yoru controllers making the helper methods available in the controller? helper :all or alike iirc. but then helpers are imho for view stuff, not business logic.
[15:17:48] erichmenge: EspenA: Well, wouldn't it be better to have a simple verification on the form? Perhaps like Rackspace had (I'm not sure if they still do) "How many kittens are in this picture?"
[15:17:54] erichmenge: It is cute and not nearly as annoying as a captcha
[15:18:00] workmad3: EspenA: CSRF protection is intended purely to prevent a malicious user from crafting a link or javascript on another site that posts to your site using someone else's session
[15:18:09] EspenA: erichmenge: a great way to kill conversions.
[15:18:21] crankharder: Advocation: did you include the helper anywhere?
[15:18:22] workmad3: EspenA: honey-pot your form
[15:19:16] erichmenge: EspenA: Well then there's no pleasing you ???? But anyway, here you go: In your Application controller: def def handle_unverified_request() raise "OMG no CSRF!!!"; end
[15:19:20] EspenA: workmad3: yeah I often do that. Not in this case but I'm just surprised to learn that a non-verified POST doesn't get killed
[15:19:36] erichmenge: oops, too defs (running on low sleep here
[15:19:40] workmad3: EspenA: the session data, which is what gets compromised in a CSRF attack, is removed from the equation
[15:19:48] workmad3: EspenA: as I said, it's arguably a correct response :P
[15:19:51] EspenA: erichmenge: the rails4 way of handling it pleases me :D
[15:19:58] workmad3: EspenA: killing the entire request is also a valid response
[15:20:16] corp_: I have a class inherited from devise's registrationscontroller. in the create there's super called and then some logic in which, in some cases, I want to redirect to a different page than devise is redirecting to
[15:20:19] workmad3: EspenA: but one that has a tendency to cause a more glaring issue with user interaction
[15:20:20] corp_: can I somehow do this?
[15:20:24] EspenA: workmad3: i agree for the CSFR. I basically just want to verify that the request comes the form (hence using the token)
[15:20:31] corp_: like.. "delete" devises rendering and replace it with mine
[15:20:34] epochwolf: EspenA: you can enable the exception behavior for CSFR protection in 3.2
[15:20:39] workmad3: EspenA: oh, if that's what you want... consider using signed_form ?
[15:20:50] workmad3: EspenA: https://github.com/erichmenge/signed_form
[15:20:55] universa1: corp_: read the devise wiki, it has examples for most of what you ask
[15:21:02] erichmenge: workmad3: Awww ??????.
[15:21:38] workmad3: EspenA: as the CSRF protection doesn't verify that the request came from the form... it just verifies that it came from the correct session ;)
[15:22:00] EspenA: workmad3: looking at it now, interesting. probably will just handle the unverified req though. thanks
[15:22:30] workmad3: EspenA: your choice... just as I said, be aware that it doesn't really fit what you want ;)
[15:22:50] corp_: universa1, already looked, do you have a keyword for me?
[15:24:33] AntelopeSalad: wow rails is ridiculous haha, i can't believe how easy it is to customize the generated views
[15:24:55] erichmenge: EspenA: signed form actually does do exactly what you want.
[15:27:36] EspenA: Another problem with protect_from_forgery im facing is disabling it based on successful auth in a before_filter.
[15:27:54] erichmenge: Why would you want to do that?
[15:28:03] EspenA: API requests
[15:28:15] EspenA: using basic auth.
[15:28:41] erichmenge: Well, you can hook into handle_unverified_request however you like.
[15:28:43] workmad3: EspenA: you mean something that isn't using a session, so it doesn't matter if the session is reset? :P
[15:29:24] workmad3: EspenA: if you have separate controllers for your API, it can also make sense to disable protect_from_forgery in them, btw
[15:29:25] EspenA: workmad3: yeah no session there either. All normal authenticated requests would be fine with just resetting the session thus invalidating the request since session is required
[15:29:57] EspenA: workmad3: i have controller which handles api and normal requests so cant unfortuantely
[15:30:27] workmad3: EspenA: that sucks :(
[15:30:44] EspenA: erichmenge: the problem is that the csfr is prepended and thus handle_unverified_request is executed before my auth is
[15:47:02] Advocation: crankharder: I haven't included the helper anywhere, no - the guides say that they are all included by default.. http://api.rubyonrails.org/classes/ActionController/Helpers.html
[15:48:40] makerops: if i have a has_many :orders in User, and accepts_nested_attributes_for :user in Order
[15:48:59] makerops: do I HAVE to incldue the :user fields, upon order creation?
[15:49:30] makerops: ie, if the use doesnt have an account, i want them to be able to sign up while checking out, but if they do, i dotn need to re-create the user
[15:49:32] jokke: hey, i want to use a drb server in my rails project to communicate with a client
[15:49:54] jokke: what would be the best way to accomplish this?
[15:50:16] rushed: jokke: what problem are you trying to solve with that?
[15:50:17] jokke: the drb server should have access to models
[15:50:29] Morkel: Does anyone know how i can encode UTF8 Literal to UTF8 for example Ada\\xc2\\xb4s to Ada's
[15:50:50] jokke: rushed: asynchronous api calls
[15:51:30] makerops: https://gist.github.com/makerops/8007082
[15:51:32] rushed: jokke: as in hand them off for processing outside the web worker?
[15:51:34] makerops: code in question
[15:52:18] jokke: rushed: not necessarily. I need the rails app to be able to access data from the client in real time
[15:52:29] njero: Hey all... I have an uploader that direct uploads to S3. However, the filenames people upload have spaces and who-knows-what in them. Is there a common pattern for this? URL encoding the upload works but then downloading the file becomes strange...
[15:56:26] jokke: rushed: maybe it helps if i explain a bit more what i'm trying to do: i have a client with a webcam and some sensors. The client sends images to the server whenever motion is detected. It also sends status information about the sensors at regular intervalls. However all the configuration is done in the rails app. For example whether motion detection should be on or off, intervalls between data etc. So it
[15:56:28] jokke: would be cooler if the rails app would just poll the stuff from the client.
[15:56:48] jokke: whenever it needs to
[15:57:34] rushed: njero: track the filename yourself & name the actual file based on the md5 for de-duplication? :)
[15:57:36] jokke: that would also allow real time monitoring of sensor data or even live stream of the webcam
[15:57:45] tubbo: jokke: instead of DRb, why not just pipe data between ZMQ sockets?
[15:58:07] Morkel: Does anyone know how i can encode UTF8 Literal to UTF8 for example Ada\\xc2\\xb4s to Ada's?
[15:58:09] jokke: because DRb is super neat!
[15:58:50] njero: rushed: are you suggesting to store the md5 version of the name on s3? Not sure if that would work because then the downloaded filename in the long run would be the md5 name
[15:58:51] tubbo: jokke: yeah, it's got some good ideas. but in my previous experience using it with Spork as well as on my own personal projects, i felt like it was waaay too complicated for most of the problems we as web devs have to solve.
[15:59:09] tubbo: jokke: the issue is that DRb is a "really heavy socket", and you can do pretty much the same thing with lightweight ZMQ sockets or just a TCP socket for that matter..
[15:59:45] njero: Morkel: I am looking... there is a way but I have forgotten :/
[15:59:48] rushed: njero: the downloaded filename is whatever you set the header to no?
[15:59:51] jokke: i'm checking out zmq
[15:59:51] s2013: k something is bugging me. i am missing something obvious but https://gist.github.com/ss2k/7f8716deb1623a201d8d is giving me an error with expecting $end on the = render summary line
[15:59:58] Morkel: njero: Thanks
[16:00:05] s2013: i cut down the code as much as i could and it is still causing the issue
[16:00:53] s2013: is it cause the text field tags are nested too deep? im not even sure
[16:01:10] rushed: s2013: why are you indenting under your "= text_field_tag"s
[16:01:40] s2013: you mean the %span stuff?
[16:01:48] rushed: s2013: also, why are you building forms yourself using the tag helpers :P
[16:02:03] s2013: what do you mean?
[16:02:50] njero: Morkel: what version of ruby?
[16:02:52] s2013: ah i think i fixed it. i moved the %span under the = text_field_tag
[16:02:53] rushed: s2013: the first one is wrong, the second just means you're working harder then you need to :)
[16:02:56] patch17: Hi, I'm learning Rails and was looking for a guide on how to properly update an app from 4.0.1 to 4.0.2, any suggestions?
[16:03:04] s2013: rushed, how would i do it?
[16:03:12] Morkel: njero: 2.0.0p247
[16:05:43] tubbo: patch17: bundle update rails.
[16:05:49] tubbo: patch17: here's yer guide
[16:06:15] njero: Morkel: you should upgrade to p353 (security)... but the methods I was trying to find a sample for are pack and unpack.
[16:07:13] patch17: tubbo: thanks, I didn't relize it was that easy!
[16:08:15] njero: Morkel: force_encoding('UTF-8') might do what you want though
[16:08:56] njero: rushed: when you talked about the header to me did you mean the Content-Disposition?
[16:10:07] Morkel: njero: no that makes a UTF-8 String with \\xc2 . I think ruby handels this special chars as normal chars and doesent convert it with force_encoding
[16:11:39] rushed: njero: yes sir
[16:12:45] rushed: njero: you should be able to control view vs download with "attachment" and the filename via "filename" ex... Content-Disposition: attachment; filename=zomg_kittens.pdf
[16:13:46] njero: rushed: really smart solution... I have most of the needed parts in place and will give it a shot
[16:27:10] jragon: I'm getting the error: invalid encoding name: uniqcode, it's with pg. I'm not quite sure why. I was converting the SQLite db to PG
[16:27:35] rushed: jragon: uniqcode?
[16:28:00] rushed: jragon: is that like unicode only very special?
[16:28:31] jragon: I'm not sure, it may have been a misspelling of unicode, but in my database yml it's unicode on the production and utf-8 on the other two
[16:28:44] jragon: I think it was unicode originally
[16:29:29] jragon: When I do psql -l the database is shown as encoding UTF8
[16:29:46] jragon: I can use the rails console fine
[16:31:05] rushed: jragon: you might want to prepare a gist with exactly the error you're getting along with it's context
[16:31:17] jragon: In the process
[16:31:32] workmad3: ACTION wishes things would stop calling 'unicode' an encoding
[16:32:14] jragon: https://gist.github.com/Jragon/8007864
[16:32:23] jragon: workmad3: I was just following the heroku guide
[16:32:45] workmad3: jragon: it's not your fault... I'm just ranting ;)
[16:34:05] jragon: I originally had SQLite databases, I then changed to production one to pg for Heroku. (I think I may have spelt unicode uniqcode then). Now I've downloaded a dump of the heroku db using the backup tool and have done 'pg_restore latest.dump -O -d OTIS_development' to put it into the dev db
[16:36:20] Morkel: njero: i found a workaround with the shell. echo -e Ada\\xc2\\xb4s => Ada's
[16:36:55] njero: Morkel: ah, nice
[16:38:44] makerops: https://gist.github.com/makerops/8007967
[16:39:14] makerops: why would that form throw in a superfluous [0] in the hidden field?
[16:39:49] crankharder: Advocation: oh, you're calling it from a controller... helpers aren't available in controllers
[16:40:05] patch17: is there a simple way of changing the name of a Rails 4 app from the command line?
[16:40:19] makerops: patch17, no, oyu have to change a couple things
[16:40:27] crankharder: Advocation: define the method in ApplicationController. if you need it available in a view you can do this: helper_method(:sign_out) in ApplicationController to make it available in templates
[16:41:55] sc00l: I'm trying to test a CSV file download with RSpec, I have a route that exports the data to a CSV file. How can I test the contents of the CSV file? The response body is always empty http://pastie.org/8558601. I'm not sure if I'm going about it the right way, but I want to verify that only certain columns appear in the CSV file
[16:42:23] rhizome: sc00l: File.open?
[16:42:37] patch17: makerops: what couple of things need to be changed?
[16:42:56] Advocation: crankharder: thanks, I've actually found another solution - I'm defining it as a private method in AdminController which is the controller that all controllers in the Admin namespace inherit from
[16:43:01] Advocation: thanks for your help though :)
[16:43:07] makerops: patch17, http://stackoverflow.com/questions/4383670/how-to-change-a-ruby-on-rails-application-name
[16:44:42] patch17: makerops: thanks!
[16:44:45] jragon: rushed: Found this in the dev log: https://gist.github.com/Jragon/8007864 I'm not sure how to use the app trace to help me
[16:44:56] sc00l: rhizome: hmm, now I see `Exception encountered: #<LoadError: cannot load such file -- file>`
[16:45:52] patch17: has anyone tried to use https://github.com/get/rename with Rails 4?
[16:46:07] rushed: jragon: don't specify encodings? and if you do, make sure they exist? :)
[16:47:17] jragon: rushed: It was a miss type. But it's no longer in the database.yml. Is there anyway I can fix it?
[16:47:37] rushed: jragon: where is it broken?
[16:48:01] jragon: rushed: I'm not sure. I get that error everywhere on the site. However, in the console it's fine
[16:49:37] rushed: jragon: so how did it get there? (i.e. is in present in the backup file you restored or from when you created the database)
[16:50:51] workmad3: jragon: and did you restart the server after changing database.yml?
[16:50:56] jragon: rushed: When I changed my production db from sqlite to pg for Heroku I must have spelt unicode wrong. I'm now putting the production database back in to the development database as it has some good data. I used pg_restore latest.dump -O -d OTIS_development to restore it.
[16:51:47] jragon: workmad3: facepalm
[16:51:57] jragon: No I didn't. I no longer get the errror
[16:52:09] workmad3: also, afaik it shouldn't matter if you spelt unicode wrong for production on heroku, as that will rewrite database.yml to use its DATABASE_URL env var
[16:52:12] workmad3: jragon: hehe :)
[16:53:09] jragon: However, I now get: undefined method `[]' for false:FalseClass, which I didn't get before, or on the production db
[16:54:24] rushed: jragon: if you're going to ask about an error it's best to gist the entire error along with it's call stack :)
[16:55:13] rhizome: sc00l: well, you'll want to use the correct path
[16:57:37] sc00l: rhizome: Ok, I see what you are saying, I'm not sure how I actually download the contents of the file to the rails tmp directory
[17:00:00] jragon: rushed: Here we are: https://gist.github.com/Jragon/8008348
[17:00:13] makerops: https://gist.github.com/makerops/8007967
[17:00:23] makerops: why is it rendering the [0] in there?
[17:03:01] rushed: jragon: why does l10 of national_office.rb pass false to Change.top(false)? follow that param all the way down and it's treated like a hash, so you end up with "options[:group_by]" where options = false (because you passed it in) et voila "undefined method `[]' for false:FalseClass"
[17:06:50] jragon: Great! Thanks very much rushed. I was fiddling with a few of the actions, and forgot about the dependencies. +
[17:10:23] hackeron: hey, I have this code in a slim template: a.has-tip data-tooltip='' title=simple_table(data) -- this creates broken HTML because simple_table(data) creates an html table. How would I escape the html in a way where I can use it as a value for the title attribute?
[17:10:49] rhizome: makerops: guessing because "resource" has_many orders
[17:11:54] rhizome: hackeron: you're trying to use a table as a title attribute for an href?
[17:12:16] hackeron: rhizome: yep, it's the markup for creating a tooltip in zurb foundation
[17:12:17] rhizome: i'm not sure that's valid html
[17:12:30] hackeron: rhizome: and I want my tooltip to have a table, so I need to quote the html passed to title=
[17:12:32] rhizome: hackeron: oh, no idea.
[17:13:03] hackeron: rhizome: actually seems to happen automatically in haml templates, but not in slim ones, hmmm
[17:13:04] rhizome: i would just use js for that
[17:13:22] hackeron: rhizome: it is using js, but that's the html markup to add the content of the tooltip
[17:13:50] rhizome: sure, but it's magical js supplied somewhere in the fistful of gems you're using to implement it
[17:14:45] hackeron: rhizome: it's http://foundation.zurb.com - don't think it's that magical, it just provides a good starting block for most common stuff websites have
[17:16:34] crankharder: Advocation: did you include the helper anywhere?
[17:17:06] Advocation: crankharder: no, no need as the methods I was using in the controller are now in the AdminController not the helper
[17:18:17] Chandon: Why does JSON.parse("derp\t".to_json) throw an exception?
[17:19:42] tbuehlmann: Chandon, that's not a valid JSON document
[17:20:04] Chandon: I called "to_json" on it, which should make a valid JSON document.
[17:20:40] tbuehlmann: nope, that's not true
[17:20:46] Chandon: How's that?
[17:20:52] rushed: Chandon: is every valid piece of json a valid json document?
[17:21:32] tbuehlmann: valid JSON documents are objects or arrays, not single strings, numbers, booleans or null
[17:21:52] Chandon: That... sounds plausible.
[17:23:52] hackeron: I want to achieve something like this: <span data-tooltip class="has-tip" title="<img src='img.jpg'>">(view)</span> -- I have this in my slim template: span.has-tip data-tooltip='' title=image_tag('img.jpg') view -- unfortunately what is generated is title="<img src="img.jpg">" - so the use of double quotes breaks the html. Any ideas how to solve this?
[17:24:54] rushed: hackeron: if you want to shove data into the title you need to escape it, and it should probably be in a data-* attribute instead :)
[17:28:31] hackeron: rushed: I didn't make up the markup, I'm using http://foundation.zurb.com/docs/components/tooltips.html -- is there a helper to escape it in rails for attributes?
[17:30:58] rushed: hackeron: j
[17:32:45] hackeron: rushed: that escapes a whole bunch of other stuff (like / becomes \/) and looks even more broken in the browser and still generates broken html
[17:33:25] rushed: hackeron: wat?
[17:36:05] hackeron: rushed: it generates this which the web browser sees as the <a tag being closed - what I see in the browser is the text "> ---- title="<img alt=\"Img\" src=\"/images/img.jpg\" />"
[17:36:51] toretore: what you're doing is stupid
[17:37:07] toretore: and i'm not even sure if it's possible
[17:37:26] hackeron: toretore: it is, it works out of box with haml, but not with slim
[17:37:54] hackeron: toretore: https://github.com/zurb/foundation/pull/946
[17:39:04] hackeron: toretore: the markup for tooltips in foundation is <span data-tooltip class="has-tip" title="html code goes here">extended information</span>
[17:39:38] hackeron: toretore: need to check what haml do different to slim for my to just be able to use image_tag as the value for title
[17:40:18] nobitanobi: I have a question when we do find_or_create_by() https://gist.github.com/novito/8009264 -- Why if the attribute is mandatory it actually creates a User object (even though is not saved in the DB)?
[17:48:44] lethjakman: is it bad to use a global var for $redis ?
[17:49:36] mjc_: lethjakman: generally speaking, global variables can make concurrency more difficult, for one thing
[17:49:47] mjc_: I think the answer to your specific question though is "it depends"
[17:50:41] lethjakman: mjc_: what other ways are there to do that then? I definitely need concurrancy.
[17:50:53] lethjakman: this needs to work in sidekiq
[17:51:49] mjc_: how are you using redis - as a plain cache, or for structured data, or something else?
[17:52:28] lethjakman: mjc_: both. I'm gonna cache some model data as well as some temporary auth keys.
[17:53:05] lethjakman: the problem I'm solving now is the authentication. I want only the currently logged in user to be able to subscribe to a faye channel.
[17:54:07] mjc_: ah, interesting
[17:56:06] mjc_: You might be able to make use of redis-store and/or redis-rails
[17:58:15] mjc_: it's not a perfect matchup though
[17:59:07] mjc_: lethjakman: anytime you want concurrency you either should lock around accessing globals or avoid them entirely
[17:59:18] mjc_: avoiding them is better
[17:59:48] lethjakman: what do you mean lock around?
[18:00:19] lethjakman: should I just initialize a new instance every time I want to use it?
[18:01:19] mjc_: that would work certainly but might not be ideal
[18:01:29] mjc_: one per thread would be best if you can manage that
[18:01:50] mjc_: isn't sidekiq itself backed by redis?
[18:02:24] lethjakman: what would be ideal?
[18:02:32] lethjakman: that's what I'm confused about those are the two options I see.
[18:02:56] lethjakman: hrm I'll mess with it and see if that's possible.
[18:03:06] lethjakman: yes it is actually
[18:06:03] sviesusisalus: hi. i have created some temporary atributes in model, my validation rezuires them to be set, but in other method i dont need them to be validated. how can skip attr_accessor validation in controller ?
[18:09:08] AntelopeSalad: lethjakman: why don't you just cache current_user into redis?
[18:10:03] lethjakman: AntelopeSalad: because I don't want to pull activerecord into faye.
[18:10:36] AntelopeSalad: you could just set the id in redis
[18:10:43] AntelopeSalad: not the entire current_user
[18:11:32] lethjakman: what do you mean?
[18:11:59] lethjakman: $redis.set current_user.id, current_user.token ?
[18:12:01] lethjakman: is that what you mean?
[18:12:18] AntelopeSalad: on user login, set the current user's id into the rails cache (using rails-redis)
[18:12:36] mjc_: lethjakman: I wonder if sidekiq lets you access its own redis connections
[18:12:42] AntelopeSalad: then you can do your lookup in the rails cache to determine if they can subscribe?
[18:12:58] mjc_: AntelopeSalad: good idea
[18:13:11] AntelopeSalad: it's really easy to setup too, i've done something similar
[18:13:11] mjc_: go with AntelopeSalad's idea :)
[18:14:20] lethjakman: mjc_: I'm wondering the same thing, I haven't seen it.
[18:14:30] AntelopeSalad: here https://gist.github.com/anonymous/8009859
[18:14:51] tfitts: has anyone here used ActiveAdmin for any fairly large projects? I'm testing it out and while it seems easy for showing/updating model data, I'm wondering if I'm likely to run into customization issues as I get further along.
[18:14:58] AntelopeSalad: that handles setting up the user (account) in redis when they start a new session
[18:15:06] AntelopeSalad: you can modify it as needed for your use case
[18:15:42] toretore: NO USE ACTIVEADMIN
[18:15:54] mjc_: activeadmin is not a good fit for large projects
[18:15:57] rhizome: activeadmin is fine
[18:16:02] mjc_: it's good for small ones
[18:16:08] rhizome: it's not a CMS though, which is where a lot of people get frustrated
[18:16:16] EminenceHC: tfitts: The only time you should use it is when you need very basic functionality very quickly. For bigger sites it is better to roll your own.
[18:16:28] mjc_: it is very difficult to cache if you run into performance problems
[18:16:38] tfitts: ok, that's the impression I'm getting as I'm starting to test it
[18:17:02] rhizome: you'd have to describe "customization issues" more completely
[18:17:04] mjc_: most of its work is done in the view
[18:17:04] tfitts: my first clue was when it tried loading a million rows on a has_many association so I could apparently filter.
[18:17:40] AntelopeSalad: tfitts: you might want to consider looking into how to override the scaffold's generated code
[18:17:55] rhizome: million rows? pagination?
[18:18:11] rhizome: oh, the search thingy.
[18:18:30] tfitts: rhizome: it was trying to load the user list which is associated with orders and shipments, and customers and a few other things.
[18:18:35] tfitts: so it tried loading all of those.
[18:18:40] tfitts: just to give me a list of users.
[18:19:17] rhizome: you may have set it up less than optimally
[18:19:36] rhizome: like, why even get a list of users through associations?
[18:19:38] tfitts: which I found out how to override by eliminating most of the search options, or at least narrowing the options, but that seems to take out a lot of the point
[18:20:04] tfitts: rhizome: that's the default setup of it. there are forum posts about it crashing peoples servers on the same basic has_many assocations
[18:20:17] jamespeerless: active record base connection.execute(), does that handle multiple sql statements semi-colon separated?
[18:20:59] tfitts: or are you saying I shouldn't setup an association to the shipments a user has with that user?
[18:21:08] EminenceHC: How much does spree commerce cost?
[18:21:15] tfitts: EminenceHC: it's free
[18:21:26] rhizome: tfitts: there's a lot the channel doesn't know
[18:21:47] AntelopeSalad: tfitts: also have you thought about copying your data into a more search-friendly data store?
[18:23:21] rhizome: https://github.com/gregbell/active_admin/pull/1979
[18:25:38] tfitts: AntelopeSalad: not an option, integrating with legacy stuff.
[18:36:25] s2013: so from my understanding if i want to export data into excel format i can just paste in excel xml code or whatever and name it something like index.xls.erb right?
[18:36:45] s2013: and does that index.xls.erb get access to instance variables? id think so but just want to make sure
[18:38:24] rushed: s2013: that sounds dodgy (I don't think xls is a text based format) where did you get that understanding from?
[18:38:58] s2013: railscast
[18:39:06] tfitts: s2013: you can do .csv that way
[18:39:06] s2013: not text but xml
[18:39:18] s2013: http://railscasts.com/episodes/362-exporting-csv-and-excel
[18:40:06] rushed: s2013: right, so that's csv (text, no formatting, etc) not excel so much as something-excel-will-open :)
[18:40:16] s2013: no.. its excel
[18:40:23] s2013: he shows csv
[18:40:25] s2013: but also excel format
[18:40:34] rushed: s2013: xlsx != xls :)
[18:40:49] s2013: but xls and xlsx are both excel
[18:40:52] s2013: xlsx is just newer one
[18:41:22] tfitts: yeah but xlsx is xml that you can output with text and xls is not something you can just write with text.
[18:41:27] rushed: s2013: sure, my bad, you originally asked about xls :)
[18:41:31] s2013: but xls would work fine
[18:42:49] s2013: actually yeah he uses the instance variables so i guess i can use it
[18:57:31] nobitanobi: What is the correct way of making sure that the object result of find_or_create_by is a "correct" object? I mean, that its id is not "nil". Here is the example: https://gist.github.com/novito/8009264
[18:58:33] slash_nick: nobitanobi: check that it is #persisted? (obj.persisted? returns true)
[18:58:48] nobitanobi: thanks slash_nick
[18:58:56] nobitanobi: I was doing @user.id.nil?
[18:59:01] Pupeno_w: What do you guys think about bootstrap? is it useful? do you use another library similar to bootstrap?
[18:59:45] slash_nick: Pupeno_w: there are a few out there... https://github.com/usablica/front-end-frameworks
[19:04:08] mjc_: slash_nick: wow heh
[19:04:24] CorySimmons: How do I test a database table to see if 2 of the same values exist in the same column? The ActiveRecord way?
[19:04:56] CorySimmons: That is, is there something like .not_in(???) ? :)
[19:05:03] CorySimmons: Might be asking for too much Rails magic here.
[19:07:22] slash_nick: CorySimmons: can't you just do YourClass.where(column: "value") and see if there are 2?
[19:07:56] slash_nick: assert YourClass.where(column: "value").one?
[19:08:52] CorySimmons: slash_nick: This is what I'm trying now actually http://pastie.org/private/etiemivci2taw8oot7mqg
[19:09:02] CorySimmons: I see your method will work, but I'm curious why mine wont
[19:09:21] CorySimmons: this is ran with rake db:seed btw
[19:09:58] slash_nick: CorySimmons: that's fine... rhizome, or #exists?
[19:10:10] rhizome: i don't think exists? takes conditions
[19:10:15] slash_nick: doesn't it :)
[19:10:40] slash_nick: Proposal.exists?(subdomain: filename)
[19:10:55] rhizome: so it does!
[19:11:15] CorySimmons: slash_nick: My method doesn't seem to work though. I'm expecting it to print in the console "found one already" if I'm trying to seed that column with a filename that is already in the subdomain column
[19:11:28] rhizome: exists? uses a find, count is COUNT
[19:11:29] slash_nick: CorySimmons: you'd need to "puts"
[19:11:43] rhizome: actually hmm
[19:11:47] slash_nick: rhizome: so count is better, i reckon
[19:12:25] slash_nick: rhizome: how would you use count
[19:12:34] rhizome: jeez, what did apidock do to their SEO so that the only results you ever get are 2.x
[19:12:57] rhizome: exists? uses select
[19:13:06] sedrickcz: Hi guys, is it possible render partial view from something.js.coffee.erb. I have this code: https://gist.github.com/sedrickcz/063bc9c7967310dcdf47 Thanks
[19:13:08] rhizome: probably negligible difference all told
[19:14:00] rhizome: sedrickcz: have you tried it without the escape_javascript?
[19:14:36] sedrickcz: rhizome: yes, i got "undefined method `render' for ...."
[19:14:45] CorySimmons: slash_nick, rhizome: I'm getting 'undefined method for update!' now :\
[19:15:48] bricker: update! isn't a method
[19:16:02] CorySimmons: Is the Proposal in Proposal.update! out of scope now that it's in that conditional?
[19:16:24] bricker: oh, I see I have completely missed context and have no idea what you're talking about
[19:16:48] CorySimmons: update! is a method :(
[19:17:06] CorySimmons: http://i.imgur.com/3JRUzAX.png
[19:17:33] CorySimmons: bricker: I have a seeds.rb file here http://pastie.org/private/vizhtb4sqlih86xvdqifjq
[19:17:44] rhizome: pretty sure you want all that as a hash that you pass .to_yaml on
[19:17:49] CorySimmons: Works fine but when it gets to Proposal.update! it throws an exception that update! isn't a method of that Class
[19:17:56] mjc_: CorySimmons: Proposal is a class
[19:18:02] rhizome: or something
[19:18:07] mjc_: update! is an instance method
[19:18:25] CorySimmons: mjc_: I don't understand. What's the difference between a class and an instance?
[19:18:34] CorySimmons: Oh, an instance is an instantiated class right?
[19:18:49] rhizome: Ruby learnings time
[19:19:46] mjc_: CorySimmons: think of it this way, you need to have a thing (an instance of class Proposal) to update
[19:19:50] CorySimmons: I should be using .save! shouldn't I?
[19:19:57] mjc_: .save! is also an instance method
[19:20:14] terrellt: Ah automated tests, how I love you.
[19:21:03] mjc_: CorySimmons: you need to make a proposal in order to call save or update on it
[19:21:24] mjc_: CorySimmons: http://www.railstips.org/blog/archives/2009/05/11/class-and-instance-methods-in-ruby/
[19:21:25] CorySimmons: Is there any method that will do this without instantiating a Proposal?
[19:21:26] mjc_: this may help
[19:21:36] mjc_: CorySimmons: why wouldn't you want to do that?
[19:22:10] tubbo: hilarious gem name of the day http://rubygems.org/gems/charlock_holmes
[19:22:44] CorySimmons: mjc_: I dunno, lemme study this stuff
[19:23:11] mjc_: CorySimmons: it looks like your current code is supposed to create a proposal if no proposal for that subdomain exists, right?
[19:23:30] rhizome: Proposal.create/new
[19:23:48] Vocino: I would like to display the future date of an item intelligently based on today's date. e.g. https://gist.github.com/vocino/8d616196a5aab575b9a4
[19:23:49] mjc_: he should only do that once he understand why, I think
[19:23:51] Criten: I have my ActionMailer setup for production, but i use a local mailcatcher for local development.. when i view the smtp_settings on our staging site all the setting are default... not what i set them to in production.rb... anyone know why they aren't taking?
[19:23:59] Criten: it works just fine on our production server
[19:24:12] Vocino: Anyone have a link or something I could check out for that?
[19:24:14] Criten: and we are using sendgrid on heroku
[19:24:31] mjc_: CorySimmons: so what is the problem with creating an instance of proposal if you are only doing one?
[19:24:36] CorySimmons: mjc_, rhizome: I was doing .create but my boss wants me to use .save! now instead :\
[19:24:53] mjc_: I mean if you have a million or a billion to do you don't necessarily want to make a new object for each one
[19:24:57] CorySimmons: I think so it will try to create or update :\
[19:25:09] nettoweb: Guys, Im trying to get a dat from from with this: params[:telefone][:origem] but it dont work just in IE, is there some known incompatibility by rails about this?
[19:25:39] sviesusisalus: hi. i have i strange model, that for example has two fields and both needs validation. but one field is set in one action, and the other stays unset. can this be done somehow ?
[19:26:06] Criten: sviesusisalus, does one always get set first?
[19:26:39] Criten: or you can do .blan? || validationstuff
[19:26:56] sviesusisalus: Criten, no, if one is set the other is never touched again. and vice versa
[19:27:23] smathy: sviesusisalus, so you want a validation that checks to ensure that at least one of those two fields is set?
[19:27:26] Criten: but one always needs to be set?
[19:28:57] jragon: I'm having some trouble creating reports: https://gist.github.com/Jragon/8011083 When looping through all the groups, I get every group reference, rather than just the 5 main groups. I tried doing a group_by on groups.id but it didn't change anything.
[19:30:14] sviesusisalus: Criten, something like that. when the filed is set it has to do more validations if not just skip it
[19:31:01] sviesusisalus: smathy, just if field is set it has to complete more validations if not just skip
[19:33:44] sviesusisalus: here is my model https://gist.github.com/anonymous/dff95b0a28b6b849ce00
[19:33:47] smathy: sviesusisalus, right, so either use :if or write a custom validation. Maybe read this (closer?): http://guides.rubyonrails.org/active_record_validations.html
[19:34:38] smathy: sviesusisalus, specifically this: http://guides.rubyonrails.org/active_record_validations.html#conditional-validation and/or this: http://guides.rubyonrails.org/active_record_validations.html#custom-methods
[19:35:15] Criten: sviesusisalus, yeah just use custom validators and i'm pretty sure you can do what you want
[19:37:19] sviesusisalus: smathy, Criten so it can do like validate :express_payer_id, if !card_number.nil?, :on => :update ?
[19:37:56] Criten: Kinda.. yes
[19:38:19] Criten: Not sure of the exact syntax... I normally just use a method for more complex validations
[19:39:34] sviesusisalus: Criten, maby its easier to define one validate method for all those fields ?
[19:39:51] Criten: yeah... i'd say so
[19:40:02] Criten: you can just have one method that does them all if it makes sense to do it that way
[19:40:23] Criten: and you can set custom error messages
[19:40:43] Criten: errors.add(:attribute, "message here")
[19:44:54] sviesusisalus: Criten, so nomather where and how i set errors.add i still have listed them in view ?
[19:45:51] Criten: they are tied to the model
[19:46:04] Criten: so you can do @object.errors.add
[19:46:11] Criten: or in the model you can just do errors.add
[19:46:40] sviesusisalus: Criten, thanks, digging into code
[19:46:46] Criten: good luck :)
[19:47:33] benlieb: How would I convert this (old) named_scope :all to the new `scope` version?
[19:47:50] Criten: Anyone want to help me figure out why heroku completly ignores my ActionMailer::Base.smtp_settings ={} in my production.rb on my staging site...
[19:47:50] benlieb: I'm not sure what named_scope :all does differently from the old Model.all
[19:47:55] sviesusisalus: Criten, one more fast question, what does this param token mean in model ? def express_token=(token)
[19:48:02] Criten: it works fine on my production site...
[19:48:08] Criten: both are run in production mode currently
[19:48:59] Criten: sviesusisalus, that defines a "setter" in rails you can run some code when you set express_token using the = operator
[19:49:13] Criten: so in that case.. if you do @object.express_token = "asdf"
[19:49:23] Criten: in that method the token variable will be "asdf"
[19:49:39] sviesusisalus: Criten, oh, got it :)
[19:50:00] Criten: It's a cool way to massage data before it gets saved
[19:50:51] moizhb: anyway to pass a string to rails application template?
[19:51:16] Criten: moizhb, for like... the page title or something? :P
[19:51:17] blitz: so I had a payments table that used to be a many-many with just one other table, but now I need to make it many-many on many different tables. what's the rails way of doing this? I'd like to keep using the one transaction_id field I have on the payment model and just add a type or something similar
[19:52:04] blitz: I looked into the polymorphic associations but it seems built for another situation
[19:52:08] moizhb: Criten: not views template.. application template rails new my_app -m template.rb
[19:52:28] Criten: Not sure sorry
[19:52:41] Criten: blitz, so basically.. you want tables to be "payable"?
[19:52:51] Criten: so you can associate many tables with payments?
[19:53:38] rhizome: blitz: what are some example tables?
[19:54:01] blitz: for example in the future I want to be able to associate the payment with a shopping_cart or a settlement
[19:54:10] blitz: so you can get all payments from the settlement or from the shopping cart
[19:54:17] blitz: and get all carts/settlements from a payment
[19:56:03] Criten: blitz, you should find one of those online flowchart creators and make a simple db diagram so we know exactly what you want
[19:56:11] Criten: that would help me visualize what you want to do at-least
[19:56:23] rhizome: you have a business that deals with both settlements and shopping carts?
[19:57:06] CorySimmons: Is there a way to render inline css from the model?
[19:57:22] rhizome: CorySimmons: don't do that
[19:57:42] blitz: rhizome is that hard to imagine
[19:58:05] sviesusisalus: maby i miss something, but this railscast has a lot of security issues http://railscasts.com/episodes/146-paypal-express-checkout. someone used this one ?
[19:58:06] rhizome: blitz: i'm not asking questions just to be a jerk
[19:58:15] blitz: yeah I wasn't trying to be snarky
[19:58:44] blitz: I'll probably just do a :through association with an intermediate table handling typing
[19:59:22] rhizome: polymorphic belongs_to is common for that kind of thing
[19:59:35] Criten: blitz, from what i think you want is polymorphic... but i'm not 100%
[19:59:54] Criten: you could also have multiple join tables....
[20:00:31] rhizome: that sounds like fun
[20:01:06] CorySimmons: rhizome: It's just to change the CSS for the body background image. Should I create 2 stylesheets each with 3 lines of code in them (including the closing bracket)?
[20:02:01] CorySimmons: Yes, it'd get added to asset pipeline, but just seems like overkill right?
[20:03:25] blitz: yeah, I'm gonna get polymorphism working
[20:05:21] rhizome: CorySimmons: no idea what you're trying to do
[20:08:23] lurraca: what would be a good place to put a module for my decorators on the app folder structure?
[20:08:31] lurraca: is there any convention for that?
[20:09:34] Criten: So upset with our old dev now haha
[20:11:10] lurraca: concerns folder perhaps?
[20:13:01] CorySimmons: rhizome: http://pastie.org/private/w45zpssx17qzbosyfpoiuq
[20:13:09] CorySimmons: I don't know where to put that
[20:13:16] CorySimmons: That's in my model, sorry
[20:13:33] CorySimmons: I've tried including that method in my templates and such (haml) and it doesn't seem to work
[20:13:34] tubbo: Criten: heh, why?
[20:14:29] CorySimmons: Basically I'm just trying to get it to render a bg image from local, or from s3. I'm pretty sure the conditional part of it works but I'm unsure if stylesheet_link_tag is (it might just be an erb thing)
[20:14:36] CorySimmons: I dunno??? I don't know how to rails at all
[20:15:41] mjc_: stylesheet_link_tag is a view helper
[20:15:45] tubbo: god dammit....bundelr
[20:15:53] tubbo: y u no --with
[20:16:03] tubbo: was there ever a `--with` in Bundler or am I just crazy :P
[20:16:23] Criten: I never use it... haha
[20:16:29] CorySimmons: mjc_: Yeah I figured
[20:17:44] Criten: tubbo, our staging sites normally just use our prouduction config... but on this one he had it set to a "staging" config (IE. RAILS_ENV=staging) and didn't even have a staging.rb in envrionemnts...
[20:17:49] CorySimmons: mjc_: Do you see what I'm trying to do though? I was originally just trying to make it more DRY in the view and then rhizome suggested I not use inline style, so I'm trying to pull the css out to their own stylesheets (so they'll get picked up by the asset pipeline), and in my model, test to see which is which and render only -that- stylesheet
[20:17:52] Criten: so i was wondering why the email wasn't wokring forever
[20:18:04] Criten: it just wasn't loading the settings in production.rb
[20:18:08] Criten: a little oversight on my part
[20:18:30] s2013: for some reason when i choose an option and click on submit the params are just "" https://gist.github.com/ss2k/7a5bca636bad6132ec53
[20:18:35] s2013: trying to figureo ut whats wrong
[20:18:55] tubbo: Criten: heh :D
[20:19:16] Criten: I was getting SO frustrated
[20:19:23] Criten: then ran heroku config and saw the env
[20:19:25] s2013: Criten, our cto was trying to figure out why one of our devices wanst working. ... after a while he realized it wasnt plugged in
[20:19:41] CorySimmons: mjc_: I'm just having a hard time getting anything from the model to the view
[20:19:44] Criten: and just stood up and walked around for a bit
[20:19:46] Criten: like.. REALLY
[20:19:57] tubbo: s2013: don't you need to wrap the names in the object? like 'user[email]' for example.
[20:20:02] Criten: i'm all for having a different configuration if it makes sense... but you should make said config :P
[20:20:13] Criten: CorySimmons, looks like it should be a helper if anything :P
[20:20:19] tubbo: Criten: lol it seems like definitely a mistake.
[20:20:29] s2013: the params is called "commits"
[20:20:32] tubbo: Criten: like he probably thought there *was* a staging.rb
[20:20:44] tubbo: s2013: whatever, transpose it.
[20:20:50] Criten: tubbo, i've never used this staging site for this particular site... so i was lost looking into other reasons
[20:21:05] Criten: it didn't even have sendgrid on the app on heroku so i thought i messed something up enabling that...
[20:21:12] CorySimmons: mjc_: http://i.imgur.com/HKrGNWq.png
[20:21:25] Criten: Even though they make it 99% foolproof haha
[20:21:26] tubbo: s2013: if you can, try to refactor `form_tag(bulk_deployment_units_path` into `form_for @bulk_deployment_unit` or something
[20:21:28] CorySimmons: in the template, the - if any_bg_image? test isn't working
[20:22:01] s2013: im not modifying any object though
[20:22:59] tubbo: s2013: why not?
[20:23:29] s2013: because its not updating any record per say. the controller mainly gets the commit sha + unit ids and sends it off to another url
[20:23:29] toretore: s2013: add html + log output to gist
[20:23:56] tubbo: s2013: ah, but why is the controller doing that? shouldn't that be the job of the object? the controller is just supposed to take in params, maybe massage them a bit, pass them to the object, and then return a response.
[20:24:07] s2013: i am 99% sure the form helper is correct. whats weird is that it worked a month ago.
[20:24:09] tubbo: s2013: from what you're telling me here it seems like a lot of the "meat" of this feature is in the controller. that's bad news bears.
[20:24:25] s2013: tubbo, what do you mean
[20:24:39] tubbo: s2013: but at the same time, it *should* be passing those params since they're <input>s in a form. that's just how browsers work. so maybe something else is up.
[20:24:44] s2013: basically the page allows you to select multiple units
[20:24:55] s2013: i have an action that takes the unit ids + sha
[20:25:01] s2013: and just make a request
[20:25:09] s2013: not sure where else to do that
[20:25:30] tubbo: s2013: ah, that sounds like a job for a service object. food for thought, it's bikeshedding right now.
[20:25:47] s2013: yeah im sure i can refactor it something better but i need to get the most basic version working first
[20:25:52] tubbo: s2013: i think your problem lies somewhere in the params parsing. try to complete this form and gist the output of the logs during the request.
[20:26:04] tubbo: so everywhere from 'Started POST..' until 'Completed in..' in your log
[20:26:42] s2013: toretore,sorry just saw your message. one second let me try something
[20:26:52] s2013: im using pry to check for params tubbo
[20:27:06] s2013: anyways one sec
[20:29:06] s2013: ah here is the weird part.
[20:30:48] s2013: https://gist.github.com/ss2k/7a5bca636bad6132ec53
[20:30:58] s2013: thing is its getting the commits in the get url
[20:33:33] toretore: s2013: you need to give us a lot more information than that
[20:34:33] s2013: i think i figured it out. let me try soemthing
[20:35:58] s2013: got it! i had a second form. for some reason part of it was cut out and that form was sending parameters to the controller if that makes sense
[20:35:59] s2013: thanks guys
[20:40:45] rncrtr: Is there a way to use config.force_ssl but disable secure cookies for a single action?
[20:41:24] AntelopeSalad: what's the best way to use a rails app template to create a brand new gemfile from scratch?
[20:41:46] AntelopeSalad: the current way of just adding: gem 'foo' to the template file injects it into the default gemfile instead
[20:42:13] rhizome: what do you mean, "default"?
[20:42:30] AntelopeSalad: rhizome: it create the usual gemfile and then add your custom gems to it
[20:42:46] AntelopeSalad: i want to use a completely custom gemfile from scratch rather than append to the default one
[20:44:00] rhizome: you can't create the gemfile from scratch?
[20:44:38] AntelopeSalad: i looked at the guides for custom application templates
[20:45:06] AntelopeSalad: there was nothing documented to make a new gemfile from the ground up
[20:48:52] lethjakman: anyone know how binding.pry is different from pry.binding?
[20:52:05] lurraca: I have design question??? I have some code in the application helper to output an html depending on a boleean that i pass into the method. I use it in the view like "= active_td(object.active)". However I'm thinking about moving that logic from the applicationhelper to a module called let's say Activable and include that module in the decorators that are needed? does that seem like a good thing to do? or I'm doing a design overkill?
[20:52:34] bricker: lethjakman: `pry.binding` is the same as calling `self.pry.binding`, which it likely not what you want.
[20:54:58] lethjakman: bricker: hrm interesting. yeah I figured out it wasn't what I wanted. confuesd me a bit thoudh.
[20:55:22] lethjakman: such a great program though
[20:58:34] lethjakman: thanks bricker :)
[21:00:04] s2013: if i need to call an action from another controller in my controller, how would i do that?
[21:00:32] lethjakman: s2013: more details as to what you're doing? sounds like you're not doing it right.
[21:00:38] s2013: probably not. one second
[21:02:00] s2013: https://gist.github.com/ss2k/91e175fcdc46affeb715 lethjakman this is what i have.and it works. basically it takes an array of unit ids and sends it off to an url
[21:02:19] s2013: if it succeeds i want to pass the unit id to another action
[21:02:22] Criten: So my co-worker has a bunch of yields in her layout and when she loads the page view it inserts it into every yield... even though all but one have names.. anyone have any idea why this would be hapening?
[21:02:26] s2013: in another controller
[21:02:34] lethjakman: s2013: so you want to call bulk_deployment from a second controller?
[21:02:48] s2013: no. i want to call a different action from bulk_deployment
[21:03:01] rncrtr: Is there a way to use config.force_ssl but disable secure cookies for a single action?
[21:03:26] rncrtr: I don't want to force all traffic to https, just to make the cookie non-secure
[21:03:51] lethjakman: s2013: I wouldn't structure it like that. I would structure it so you can call different methods depending on what this returns. so abstract the data from the controller you want to call into a method and conditionall call it in the method that's already being called.
[21:03:57] lethjakman: does that make sense?
[21:04:49] s2013: sort of. let me show you. actually i realized its in the same controller so that might make ite asier
[21:06:25] s2013: https://gist.github.com/ss2k/91e175fcdc46affeb715
[21:07:00] s2013: the issue is that the send_job action can be called directly from a page but i want to call it from another action if that makes sense
[21:08:13] lethjakman: s2013: so you're making a post/get request directly to send_job ?
[21:09:00] lethjakman: s2013: ok, I would consider that messy unless there's a really good reason to be doing that. what I would do is I'd make send_job a method of that controller and then call it from within a create method.
[21:09:16] lethjakman: s2013: if you're having troubles with keeping it DRY it means you haven't abstracted it enough.
[21:09:51] s2013: i inherited someone elses code :\
[21:10:46] s2013: codebase is very odd with a lot of little peculiar things
[21:11:56] AntelopeSalad: rhizome: figured a work around to it, i just gsubbed the entire file to an empty string before anything
[21:13:08] s2013: im just going to do a get request directly to the url.. much easier/quicker since we are going to get rid of this feature soon
[21:13:12] s2013: thanks for the help
[21:13:30] lethjakman: s2013: I'd start by moving the redirects and such out of this weird method. moving it to the appropriate restful method, then working from there
[21:13:32] lethjakman: https://gist.github.com/lethjakman/b57c87839ca4a4f4487f
[21:13:37] s2013: open("url") does a get request right
[21:13:40] lethjakman: MORE like that. obviously it's not right. but it's just an example.
[21:13:46] lethjakman: I believe so
[21:13:59] Criten: Have a good evening everyone! Leaving early... so much snow :P
[21:14:22] s2013: Criten, where are you
[21:15:01] Criten: Probably one of the only rails shops in NH hahaha
[21:15:16] s2013: ah nice. enjoy the snow. ours is all slushy by now. my commute home is going to suck
[21:15:47] Criten: Yeah... it's like 13 degress out or something haha
[21:15:55] Criten: so ours is not slushy at all
[21:17:16] s2013: nice. well have fun and be safe
[21:17:35] Criten: You too. Have a good night
[21:17:50] lethjakman: ahh I'd love some snow down here.
[21:17:53] s2013: where are you
[21:19:09] shivamib: heh meanwhile in sao paulo it's scorching hot most days... some xmas...
[21:19:55] s2013: colorado has no snow wtf
[21:19:56] lethjakman: where are you s2013?
[21:20:05] lethjakman: right? colorados weather is crazy
[21:20:05] s2013: shivamib, nice. i was looking at tickets to brazil today
[21:20:08] s2013: so damn expensive already
[21:20:14] lethjakman: it'll be below zero one day then 60 the next
[21:20:21] lethjakman: you have family there?
[21:20:33] shivamib: yeah, and it's only gonna get worse with the world cup
[21:20:40] s2013: in brazil or nyc or colorado
[21:20:46] s2013: shivamib, yea for the wordlcup i meant
[21:21:11] s2013: lethjakman, i have no family in brazil but i do have family in colorado and i grew up in nyc
[21:21:20] s2013: im trying to go there for the world cup
[21:21:21] lethjakman: where in CO?
[21:21:24] s2013: fort collins
[21:21:26] s2013: beautiful place
[21:21:34] lethjakman: no way. I was there a couple weekends ago
[21:21:35] EminenceHC: january 1st 2014 colorado
[21:21:37] lethjakman: odells brewery tour
[21:21:44] s2013: i went there last year. it was awesome
[21:21:49] lethjakman: EminenceHC: what's that?
[21:21:54] lethjakman: s2013: they were crazy busy
[21:22:02] EminenceHC: legal pot :P
[21:22:05] lethjakman: went on my birthday and couldn't get on a single tour. tried all day. drank tons of great beer though
[21:22:16] lethjakman: EminenceHC: oh taht. lol trust me I know.
[21:22:42] s2013: im not cool enough to drink or smoke :(
[21:22:45] EminenceHC: get ready for weed tourism
[21:23:23] s2013: o i just dont. personal reasons i guess. never saw a reason to anyways
[21:23:34] s2013: i was just joking about the notcool enough thing
[21:24:17] lethjakman: I was the same way for a long time
[21:24:53] EminenceHC: until he decided to be cool
[21:25:56] EminenceHC: I wonder if it is possible to have an administrator be able to reset a user's password with devise..
[21:26:18] lethjakman: EminenceHC: you'd have to build in a bit of functionality but should be possible.
[21:26:33] lethjakman: you're really just setting the reset token then giving them a link E believe.
[21:26:41] lethjakman: I switched away from devise though so I'm no expert.
[21:27:01] EminenceHC: lethjakman: ah I see Ill look into it
[21:27:16] EminenceHC: lethjakman: Ya I wish I had built my own authentication system
[21:27:24] lethjakman: EminenceHC: WAY easier since you know how everything works.
[21:28:07] EminenceHC: lethjakman: I am starting to feel that way about a lot of gems..
[21:28:26] EminenceHC: lethjakman: I don't want to reinvent the wheel but I don't wanna have to learn how someone built their wheel either.
[21:30:53] lethjakman: EminenceHC: devise was more trouble than it was worth by far. kept getting stupid errors everywhere. but I agree. a few I"ll reuse...like carrierwave. that one actually saved time.
[21:31:47] rushed: EminenceHC: lethjakman: you're just trading learning upfront for learning as you encounter issues and hoping that your case will be simpler enough then the general case the tool targets that you'll come out ahead. The better the tool and more complex the case the less likely you are to win that bet... and security is pretty complex :)
[21:32:42] lethjakman: rushed: I would disagree. devise solves a pretty simple problem if you understand how authentication works.
[21:32:49] lethjakman: especially with has_secure_password being built in.
[21:33:54] lethjakman: I have to spend a lot of time worrying about security though so maybe I'm just used to it. :) besides if you don't fully understand the framework there's no way you can guarantee the safety of something like devise.
[21:36:26] s2013: do you guys take forever to update rails version i mean like from 3.2.15 to like 3.2.16 or whatever
[21:36:30] s2013: not like rails 3 to rails 4
[21:37:20] shivamib: i try to update as soon as possible, at least for the minor bumps
[21:37:30] rushed: s2013: you should generally upgrade point releases nearly immediately (for some value of immediately where you're sure you're not the first sucker though the gate) as they're generally security or bug fixes :)
[21:37:58] s2013: ok what i mean is that.. at my company.. they want to have a meeting to discuss upgrading from whatever we have now.. to the next release
[21:38:02] s2013: we are just 1 release behind
[21:38:12] s2013: im like i can just update it and thats what i usually have been doing
[21:38:16] bricker: s2013: lol, they want a meeting to upgrading a point release?
[21:38:19] s2013: yes exactly
[21:38:24] bricker: s2013: damn man.
[21:38:35] bricker: s2013: sorry to hear that.
[21:38:51] shivamib: you should upgrade it
[21:38:54] s2013: last few months ive been just updating it but now we have a new CTO and he wants to have a meeting, told me to write all the steps down, etc.
[21:38:58] rushed: s2013: those meetings are probably designed for 3.x => 4.x not point releases (do you meet to decide if you apply this week's Windows Updates?)
[21:39:00] shivamib: and then go to the meeting and say well, it's already done mates
[21:39:00] lethjakman: s2013: those are usually security. so I do those fast.
[21:39:21] s2013: rushed, not 3 - 4 but the next release of 3
[21:39:34] s2013: im running on 3.2.15 i think 3.2.16 is the newest one
[21:39:35] rushed: s2013: I hope you're misunderstanding :)
[21:39:41] s2013: no. trust me
[21:40:37] s2013: he asked which version of rails we are running i said 3.2.15 he said that 3.2.16 came out and should we upgrade? and i said yeah i usually just do it
[21:40:42] s2013: and then he talked about having a meeting, etc.
[21:40:57] lethjakman: s2013: just check if everything works on a staging environment then just upgrade it.
[21:41:10] lethjakman: s2013: that shouldn't be a big deal.
[21:41:15] EminenceHC: s2013: At least your boss knows what an upgrade is..
[21:41:18] s2013: i know.. thats why i was confused
[21:41:39] s2013: our cto is a smart guy.. but since we are a hardware company most people do low level stuff like C
[21:41:41] lethjakman: lol...is he a programmer?
[21:41:53] jarr0dsz: nested resources is not the most fancy thing in rails isent it ;) edit_admin_client_account_path
[21:41:58] s2013: im the only rails guy and i barely know shit
[21:42:11] lethjakman: jarr0dsz: it is nice.
[21:42:17] lethjakman: s2013: you'll get it :)
[21:42:22] lethjakman: I still don't know so much.
[21:42:44] rushed: s2013: are you messing with us? I'm having a hard time believing the intersection of "people who know Rails 3.2.16 is a thing" and "people who would want to have a meeting about upgrading from Rails 3.2.15 to 3.2.16" is not an empty set :P
[21:42:50] s2013: yeah he is a programmer but he is a C/perl guy
[21:42:52] s2013: rushed, i wish
[21:43:23] s2013: i was just curious if anyone else ever faced similar situation
[21:43:32] lethjakman: s2013: I'd basically let him know that it's not a functionality version, but a security update/bug fix usually.
[21:43:53] lethjakman: my ex boss tried to tell me that arrays overflow to 0 when you went out of bounds :/ so I know your feeling.
[21:44:35] JRizzle: i am registered Nickserv
[21:44:37] s2013: heh. no eveyrone here is super smart.. all ivy league grads. but like i said, hardware vs web app.. kind of a disconnect
[21:44:45] JRizzle: dont tell me otherwise! >.<
[21:44:46] s2013: but its a good learning process
[21:45:16] lethjakman: s2013: my boss had is masters in computer engineering...don't have much respect for schooling.
[21:45:46] JRizzle: anyone ever ran into this error when pushing to heroku ? hoe requires RubyGems version >= 1.4.
[21:45:55] JRizzle: using ruby 1.9.2
[21:46:04] lethjakman: JRizzle: gem --version
[21:46:08] s2013: lethjakman, heh
[21:46:27] jarr0dsz: have double nested resources which is the max according to docs ( preferred) but quite some figuring out
[21:46:30] s2013: so what are yall doing for christmas
[21:46:42] lethjakman: JRizzle: is that on heroku?
[21:47:04] JRizzle: that was local, i do heroku gem --version to check that?
[21:47:31] s2013: heroku run
[21:47:43] lethjakman: JRizzle: sounds like your heroku system is out of sync.
[21:48:20] JRizzle: ok heroku is 1.3.7.1
[21:48:28] JRizzle: when i ran heroku run gem --version
[21:48:57] JRizzle: so how do i accomplish updating heroku ? heroku run gem update --system ?
[21:49:12] tubbo: JRizzle: nope, `gem update heroku`
[21:49:17] jamespeerless: how can I see what attributes actually changed in the database after calling save
[21:49:20] rushed: JRizzle: are you sure you don't mean 1.9.3? there is almost no reason you would want to be on 1.9.2
[21:49:26] lethjakman: heroku does it differently
[21:49:33] tubbo: JRizzle: but...you really want to `gem uninstall heroku` actually. you want the Heroku toolbelt instead: toolbelt.heroku.com
[21:49:36] tubbo: JRizzle: http://toolbelt.heroku.com
[21:49:53] JRizzle: i though toolbelt was for mac
[21:49:56] JRizzle: windows lol
[21:50:28] rushed: JRizzle: no, it's the generic name for their local install now for all three platforms
[21:50:29] JRizzle: i use mac at work and windows at home ( not ideal for configuring actions ) but great for styling!
[21:50:34] JRizzle: oh ok nice
[21:51:01] s2013: woo hoo i use windows too. winbros high five JRizzle
[21:51:21] rushed: s2013: the proper emotion is shame
[21:51:26] lethjakman: anyone know how to add extra data to a faye subscription?
[21:51:29] JRizzle: no shame in our game
[21:51:53] JRizzle: i will admit though, RoR is not ideal to develop on windows
[21:52:20] shivamib: buguntu ftw
[21:52:25] s2013: i use ubuntu for ror most of the times
[21:52:30] s2013: but rest of the stuff i use windows for
[21:52:31] rushed: JRizzle: right, like chainsaws are "not ideal" pants
[21:52:53] tubbo: JRizzle: it's for everything. installs ruby, git and the heroku lib automatically
[21:53:13] tubbo: if you use windows for development
[21:53:19] tubbo: congratulations, you are a .net developer
[21:53:21] JRizzle: toolbelt ? yes i use it on my windows
[21:53:23] tubbo: otherwise it's just what
[21:53:49] JRizzle: before we had to use the installers
[21:53:52] tubbo: JRizzle: it installs the proper version of the CLI. i'm just saying otherwise you'll get a "The Heroku gem is deprecated, download the toolbelt instead" warning every time you run it and that's annoying.
[21:54:07] JRizzle: agree thanks tubbo
[21:54:29] JRizzle: and the rest of you o.O
[21:56:46] s2013: anyone going away for holiday?
[21:57:06] lethjakman: shivamib: buguntu?
[21:57:12] JRizzle: s2013: no sir, mi familia locale
[21:57:19] robertjpayne: Is there any reason with rspec + rails that "patch" works differently from get/post/put/delete?
[21:57:29] JRizzle: ok i ran gem update heroku but no change in versions, still at same error
[21:57:31] shivamib: lethjakman, ubuntu, buggy edition :)
[21:57:39] s2013: i am leaving my family for holiday and going to texas heh
[21:57:41] lethjakman: what issues?
[21:58:01] shivamib: it's what the guys call it where i work
[21:58:04] JRizzle: s2013, I am from Texas
[21:58:07] shivamib: the arch fans
[21:58:13] JRizzle: live in texas
[21:59:51] s2013: what part of texas
[22:00:47] JRizzle: Beaumont area
[22:00:55] JRizzle: southeast corner right next to LA
[22:01:58] s2013: i am going to Austin
[22:02:36] rhizome: the oil pan
[22:03:33] s2013: and brisket and beef ribs
[22:04:26] JRizzle: ooohhhh yeaaaaa
[22:04:42] JRizzle: smoked ribs!
[22:05:10] s2013: Salt Lick!
[22:10:06] morenoh159: I want to fetch three posts from every user on my site. Is there a way to do this efficiently with active record queries?
[22:10:45] EminenceHC: Austin would be way cooler if it wasn't in texas.
[22:14:47] lethjakman: morenoh159: I would use includes...there's probably a way you can limit it to 3
[22:14:53] lethjakman: you should let me know when you figure it out
[22:19:02] blai: how do you determine if a particular attribute actually changed on database AFTER model.save call? checking updated_at before/after is a close approximation but not good for multithreaded instances where different attributes could be altered.
[22:19:47] blai: and i believe active model dirty is only tracking before saves (and also doesn't have the expected behavior for multithreaded app?)
[22:19:53] bricker: blai: in an after_save callback, check attribute_changed?
[22:21:10] blai: thanks @bricker: does that work multithreaded?
[22:22:11] lethjakman: morenoh159: now that I think about it...if you make a scope you can probably do it.
[22:22:13] s2013: def create_job_for_unit(unit_list = params[:unit_cb]) <- does this even make sense
[22:22:22] lethjakman: scope and includes.
[22:25:05] morenoh159: lethjakman: I'm staring at this http://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations
[22:25:18] morenoh159: Just cant wrap my mind around my usecase
[22:25:40] lethjakman: so a user has many posts right?
[22:25:52] lethjakman: so it's User.includes(:posts).all
[22:26:15] lethjakman: and what that'd do is it'd preload the messages for each user so you'd only have two queries rather than posts seperately for each user.
[22:27:31] lethjakman: and I THINK you can put a scope on the user that would look something like scope :three_posts, -> { posts.limit(3) } and do it like User.includes(:three_posts).all but don't hold me to that.
[22:27:32] slash_nick: lethjakman: the #all is superfluous, unless you need to change it to an array for some reason
[22:27:35] lethjakman: I haven't tested that.
[22:27:55] lethjakman: slash_nick: is it? all doesn't convert it into an array anymore.
[22:27:58] lethjakman: last I checked you needed it.
[22:28:14] lethjakman: slash_nick: you're right though
[22:28:16] lethjakman: good to know.
[22:28:32] lethjakman: you get the active relation.
[22:28:43] slash_nick: User.includes(:organization).class #=> ActiveRecord::Relation.... User.includes(:organization).all.class #=> Array
[22:29:18] lethjakman: weird...why isn't it a relation like the rest?
[22:29:39] lethjakman: I thought it was supposted to return an active relation now
[22:30:22] morenoh159: in the docs it's doing a puts on the resultset, but I want to return an @variable to the view. Concatenating the ActiveRecord::Relation isn't working
[22:30:23] lethjakman: I guess all doesn't return a relation either.
[22:30:40] lethjakman: wait...it does.
[22:31:14] lethjakman: ActiveRecord::Relation::ActiveRecord_Relation_User this is what includes returns.
[22:34:17] pontiki: i want to validate an update to a record attribute only when the prior value of that attribute is one of a pair of possible values, and two other conditions are true
[22:34:27] pontiki: i'm assuming i need a custom validator for that
[22:34:44] latortuga: pontiki, sounds like yes
[22:35:00] pontiki: but how do i get the prior value (when this happens during an update_parameters) to check tne new value against?
[22:35:09] latortuga: pontiki, field_name_was
[22:35:30] latortuga: pontiki, ActiveModel::Dirty
[22:35:32] lethjakman: morenoh159: you're thinking about this wrong. the data is already cached so you can just access it when you need to. so you could do a user.each do |u| u.post.each do |p| <%= p.text %> end end
[22:36:05] pontiki: thanks, latortuga, i was just about to ask where to look :)
[22:36:32] latortuga: pontiki, it's super handy when you need it but generally not well-covered by guides
[22:36:50] pontiki: is that already included in ActiveRecord::Base?
[22:37:20] bricker: pontiki: yes
[22:38:13] pontiki: internet beer for you!
[22:39:29] morenoh159: lethjakman: ugh, I don't think so. Users have posts. I wan to iterate over each, grab three posts and show this like a feed on the site. I don't have to concatenate the queries?
[22:41:45] lethjakman: morenoh159: no. this will cache everything so you can just iterate over it in the view and have an optimized query.
[22:42:05] AntelopeSalad: is there some hack i can do to take this command: rails new foo -m bar.rb , and inside of bar somehow tell the template to skip running bundle install at the end?
[22:42:25] AntelopeSalad: i know i can run the new command with --skip-bundle , but i wonder if there's an alternative
[22:42:41] LoadedLux: hey guys i'm having issues trying to create a new rails app. I did a fresh new install for ubuntu 13.10 and i have this error when i try to create a new app: cannot load such file --rails/cli
[22:42:42] pontiki: ok, I'm confused again. If i write a custom validator, does it take the place of *all* the validations in the model?
[22:43:03] latortuga: pontiki, no, it's just like another validation line
[22:43:24] latortuga: pontiki, validate :ensure_my_thing_rocks # runs just like other validations
[22:43:25] blowmage: pontiki: write a test and see! :)
[22:44:31] s2013: is there anyway i can use the same checkboxes for multiple forms?
[22:45:42] rhizome: yes, you can use check_box_tag anywhere
[22:46:29] s2013: no what i meant was that. so i have a list if items. i can check them off and click on a form s ubmit.. works fine with the one form submit i had.. but now i need to add another one
[22:47:07] s2013: the checkbox params arent being passed when i click on submit
[22:49:03] s2013: only way i can think of is submit everything to one action with an id or something and based on that forward it to other actions
[22:49:05] s2013: but i dont know
[22:49:52] pontiki: blowmage: working on it!
[22:50:55] morenoh159: lethjakman: I made this https://gist.github.com/morenoh149/8014083
[22:51:17] morenoh159: How do I instead of puts-ing the result, return it as one variable, @feed_items?
[22:51:24] lethjakman: morenoh159: thing is it's still loading ALL of the posts for every user.
[22:51:29] lethjakman: that's gonna suck up your ram.
[22:51:45] lethjakman: you'd need to make a function to iterate over it
[22:52:04] lethjakman: however I wouldn't do that, I'd just iterate over it in the view.
[22:52:41] morenoh159: damn, I was hoping it could be done at the db layer
[22:52:55] lethjakman: morenoh159: ummm...you could execute a custom query.
[22:53:16] lethjakman: I mean you could use a .join with a .where on Post
[22:54:35] lethjakman: can't think of a way to get just 3 of each user from the database though.
[22:55:44] morenoh159: thanks for the help tho
[22:59:06] LoadedLux: hey guys i'm having issues trying to create a new rails app. I did a fresh new install for ubuntu 13.10 and i have this error when i try to create a new app: cannot load such file --rails/cli
[23:03:11] pontiki: yay! it works!!
[23:03:25] zrl: Say I have a has_one association on an object, where a student has_one user. I can access the user's attributes with student.user.attribute. Is there any way I can access the user's attributes with student.attribute?
[23:04:02] tubbo: zrl: 'attribute' or 'attributes'? all AR models have an attributes hash on them
[23:04:26] zrl: where "attribute" is the name of an attribute, ex: "first_name"
[23:04:40] zrl: ex: student.user.first_name
[23:36:58] christo_m: whats the accepted way to use something like tweetstream to filter/track hashtags in the public feed with rails?
[23:37:07] christo_m: im assuming i have to daemonize it?
[23:37:08] bricker`LA: pontiki: now how are you going to track associations??? https://github.com/scpr/secretary-rails
[23:37:57] christo_m: https://github.com/tweetstream/tweetstream it isnt clear to me where that daemonizing code goes.. with the temporary storing of statuses in log files and then inserting with active record
[23:44:00] bricker`LA: christo_m: a rake task would be a good place
[23:47:57] QbY: any rails developers with gchart experience wanna quick job? will paypal or google wallet half down, remainder on completion.
[23:48:23] christo_m: bricker`LA: a rake task?
[23:48:26] zrl: QbY: how large?
[23:48:32] christo_m: bricker`LA: is that where that code block is supposed to go?
[23:48:54] tubbo: christo_m: i like to use rake tasks for one-off commands, like things that will exit. it might be better to just make a script in ./bin/tweet-reader and chmod 755 it
[23:49:10] tubbo: so you can execute with `./bin/tweet-reader` and just run it like a normal process
[23:49:45] christo_m: tubbo: that isnt an option in production.
[23:49:48] christo_m: at least, not right now.
[23:49:49] QbY: zrl. i'd say for a good dev with gcharts experience, probably.... 1 hour or less
[23:49:55] tubbo: christo_m: https://gist.github.com/tubbo/349150b0053a82dc8266
[23:50:03] christo_m: tubbo: trying to keep on heroku free tier for this
[23:50:04] tubbo: christo_m: why not?
[23:50:07] QbY: zrl: i'm just fighting an issue and have ten others, no time to learn ruby
[23:50:08] tubbo: christo_m: ...that doesn't matter.
[23:50:45] christo_m: http://pastie.org/8559532
[23:50:50] christo_m: i was talking about this block
[23:51:35] tubbo: christo_m: yeah, all you have to do to run that as a "binary" (like a normal command on the box) is add a hashbang line at the top that points to Ruby
[23:51:40] tubbo: christo_m: #!/usr/bin/env ruby
[23:52:18] tubbo: christo_m: heroku won't let you run that as a periodic worker without paying, fwiw. you *might* be able to get away with just shelling out and running the daemon outside of Procfile
[23:52:21] tubbo: but i don't really know
[23:52:46] tubbo: christo_m: either way if you're running a separate process you're probably treading in dangerous territory (as far as billing is concerned lol)
[23:52:54] christo_m: tubbo: thats the problem.
[23:52:58] christo_m: but i guess theres no way around it..
[23:53:16] christo_m: i guess ill jsut run it local
[23:53:37] tubbo: christo_m: yeah, you can always just POST the content to Heroku and run this thing on your own computer
[23:53:44] tubbo: might be a better option
[23:54:41] morenoh149: can we pass a variable to indefinite depth with partials? like here http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials
[23:56:02] bricker`LA: morenoh149: first of all, there's no such thing as infinite in computers, second of all, what?
[23:57:10] tubbo: bricker`LA: he said "indefinite"...but may have meant infinite :D
[23:57:29] bricker`LA: tubbo: that makes even less sense