« Back to channel list

#RubyOnRails - 30 June 2013

« Back 1 day Forward 1 day »
[00:04:44] richardr: Is it appropriate (and secure) to register a user (user / pass) through a RoR API from a front-end like Backbone?
[00:27:04] shime: richardr: yes, use cors with oauth
[01:07:48] aharris6: hello all, anyone know how to make form fields required when using form_tag?
[01:12:39] butblack: is there a way to add the results of a active record filter together?
[01:14:48] slash_nick: butblack: active record filter?
[01:15:12] butblack: slash_nick: i think i got it, thanks
[01:24:25] butblack: slash_nick: hi, you can do something like this, Model.find(1,2,3) to find instances of the Model where id = 1,2, and 3.. can you do the same in the where clause/
[01:31:21] railsnthings: butblack: I think you can do that with hash conditions as per http://stackoverflow.com/questions/16305392/rails-syntax-for-where-clause
[01:31:48] butblack: railsnthings: just saw that, perfect, thank you
[01:32:06] railsnthings: butblack: No problem!
[01:38:06] railsnthings: aharris6: Adding validations to the model didn't work for that?
[01:39:01] aharris6: railsnthings: after reading the documentation (duh), I realized that the field accepts three parameters
[01:39:26] aharris6: i was adding :required to the second, which is for pre-populating content
[01:40:08] aharris6: so i just added a blank content parameter, and put my :required => true as the third
[01:40:28] aharris6: <%= text_field_tag(:term, content = nil, options = {:required => 'true'}) %>
[01:43:11] fulcan: I am trying to start a new aplication and rails is stuck on an old aplication I already deleted. Routing Error No route matches [GET] "/courses/new" http://bpaste.net/show/pOWmaXYVXOxzwYYt5ckk/
[01:46:41] narya: hi thurr. I am as rookie as you can be to rails and ruby
[01:47:28] narya: i am trying to create a dropdown menu, accessable from all pages, which is too contain an entry for each project that exists
[01:47:56] narya: so I created a layout under layouts/project.html.erb, which my application.html.erb is rendering
[01:48:29] narya: and in that layout I have a loop: <% @projects.to_a.each do |project|%>, etc.
[01:48:41] narya: however when I browse /projects/<id>
[01:48:46] narya: this menu is not showing anything
[01:50:54] narya: is there some collision with the variables, or what? ;o
[01:51:29] sam113101: narya: only when you're on /projects/<id>?
[01:52:07] sam113101: on other pages it work correctly?
[01:52:23] fulcan: my routes.rb http://bpaste.net/show/110844/
[01:53:04] narya: http://pastebin.com/7kw5bLWd
[01:53:31] narya: sam113101: only on /projects/id
[01:53:42] narya: other pages work. or.. probably not edit. sec
[01:54:10] narya: yeah, never when a page is using @project
[01:54:24] sam113101: where is that @projects coming from? why are you even using a @ variable?
[01:54:57] narya: i have no idea. i just wanted to render a dropdown based on the projects added, which would be accessible in the main menu
[01:54:59] sam113101: why are you doing .to_a on it?
[01:55:21] narya: .to_a is because before, when it was empty, I got bla bla NilObject doesnt have .each
[01:56:00] sam113101: well you should check if there are projects first
[01:56:11] sam113101: doing .to_a is kind of ugly
[01:56:13] narya: i tried @projects.nil
[01:56:17] narya: didn't work
[01:56:22] narya: got the Nil error :D
[01:56:44] slash_nick: butblack: yeah... @model.where(id: [1,2,3]) oughta work
[01:56:52] Mosselman: I am submitting to a form using Net::Post
[01:56:55] sam113101: anyway, narya, I think you're looking for Projects.each
[01:57:10] sam113101: unless you really defined @projects somewhere
[01:57:11] Mosselman: and I get a csrf error.. even though I am setting the authenticity_token in the post params
[01:57:24] Mosselman: Am I missing some sort of header or something?
[01:57:39] narya: sam113101: is Projects accessible everywhere? from f.x layouts/application.html.erb?
[01:58:26] narya: i tried googling "what is accessible where", seemed hard to find docs for that
[02:00:20] narya: sam113101: using Projects.each instead yields: "uninitialized constant ActionView::CompiledTemplates::Projects"
[02:01:14] sam113101: narya: because it's supposed to be Project, sorry
[02:01:30] narya: i should have tried that : )
[02:04:31] maodun: I have an XMLHttpRequest that's being made to my rails server, then abruptly aborted before rails hits the respond_to code block. Then my server seems to block on this. Why would this be and what should I do to avoid it?
[02:05:44] maodun: Basically I make a request to the server, the server sees the requests and sleeps for 10 seconds, and in that 10 seconds, I abort the request client-side. Then the server seems to hang when it wakes from the sleep and gets to the respond_to block
[02:06:28] narya: sam113101: isn't ActiveRecord::Base.all loopable?
[02:06:35] narya: <% Project.all do |project| %> yields nothing
[02:07:44] sam113101: narya: have you ever used all on any Enumerable object?
[02:08:31] fulcan: I am trying to start a new aplication and rails is stuck on an old aplication I already deleted. Routing Error No route matches [GET] "/courses/new" http://bpaste.net/show/pOWmaXYVXOxzwYYt5ckk/
[02:08:34] fulcan: my routes.rb http://bpaste.net/show/110844/
[02:08:54] narya: i have never used ruby nor rails prior to today. I've read Why's, watched tons of railscasts etc etc
[02:09:02] narya: but today is the first time I actually try doing something
[02:09:17] brownies: Project.all.each do |project|
[02:09:23] brownies: you should probably learn Ruby first.
[02:09:49] narya: My approach is always: jump into something rather advanced, learn from that
[02:09:54] brownies: there's a Programming Ruby book on the site... go read a few chapters from there
[02:10:07] narya: i learned python by maintaining a test suite at my company
[02:10:20] sam113101: you're going to get lost if you try to learn both ruby and rails at the same time
[02:10:43] brownies: you're going to get lost if you think you can learn ruby *by* learning rails
[02:10:50] brownies: but learning both simultaneously is not unreasonable.
[02:11:17] ner0x: Anyone use carrierwave_direct with the railscast example and notice sending the key in which the uploader is bound to is just ignored? Or stripped from carrierwave since it's not an actual file?
[02:11:46] ner0x: https://gist.github.com/fswitalski/5893510
[02:11:47] sam113101: narya: can I suggest a ruby book? it's not too huge and it's great at explaining how everything works
[02:12:05] narya: yes please. i've bought like 6 as the web suggests so many
[02:12:42] sam113101: narya: The Well-Grounded Rubyist
[02:13:08] narya: That one was never mentioned.
[02:13:20] narya: most people encouraged one to read the Pickaxe
[02:13:26] fulcan: ActionController::RoutingError (No route matches [GET] "/courses/new"): I deleted that project, why is rails still pointed to it? I have certainly restarted the server??
[02:13:30] narya: thanks for the tip sam113101
[02:17:38] fgo: fulcan: How/where is it pointing to that? You can try searching your code base or views for 'new_course_*'
[02:19:52] fulcan: fgo where would it be hidden? http://bpaste.net/show/1cbWsHFeG9G1JmV8gdFg/
[02:22:04] fgo: fulcan: are you getting the error because you're directly accessing it from the browser? eg. local.domain/courses/new
[02:23:21] fulcan: fgo yes. i'm an idiot
[02:24:17] iliketurtles: I'm using rspec and capybara, and whenever i `get root_path` or `get page_path("anything")` i get ActionController::RoutingError:No route matches [GET] "/"
[02:24:21] iliketurtles: any idea why that might be?
[02:49:32] zeromodulus: Is it better to have css loaded conditionally or just stuff everything in the asset pipeline so it can get minified?
[02:49:47] zeromodulus: or is there a way to have conditional loading and minification?
[02:50:22] zeromodulus: I was thinking about having a content_for block for css.
[02:50:26] zeromodulus: And then conditionally loading the CSS.
[02:50:40] zeromodulus: I'm not sure if it would get minified though.
[02:51:00] zeromodulus: or is everything in app/assets/stylesheets minified and precompiled?
[02:51:06] zeromodulus: regardless of how it's included?
[02:51:25] fcanela: good question, zeromodulus
[02:51:27] fcanela: I have the same one
[02:54:34] GeekOnCoffee: ugh, it's too late at night for this… what's the magic keyword to create without mass assignment protection? doing it in a migration, so I'm not concerned about the security concerns
[03:21:22] zeromodulus: I need to figure out how to organize my app better.
[03:21:34] zeromodulus: It's starting to get somewhat large and it's becoming harder to keep organized.
[03:30:03] zeromodulus: tree seems like a pretty nice command line utility to help with that.
[03:30:30] zeromodulus: I have some things namespaced a couple levels deep, which seems to make things a little unwieldy.
[04:13:03] micah`: zeromodulus: depending on the size of your css, it might make more sense to just deliver the whole thing and cahce it once
[04:14:21] zeromodulus: Yeah, possibly.
[04:14:28] Paradox: will we wake up
[04:14:29] Paradox: in the body of a buffalo
[04:14:29] Paradox: runnin through the fields with our old friends
[04:14:50] zeromodulus: I could always learn how to do profiling and the like.
[04:14:56] zeromodulus: And find out which way works best.
[04:15:51] micah`: zeromodulus: if you're unsure, i'd err on the side of simpler
[04:16:13] micah`: gzip and proper caching goes a long way
[04:16:24] zeromodulus: Well, I'll figure something out eventually.
[04:17:09] Paradox: i shaved nearly 50% of my load time on an app down by just doing gzip and caches
[04:17:16] Paradox: also moving off heroku
[04:17:19] Paradox: to openshift
[04:17:33] micah`: cwere you serving assets from heroku Paradox ?
[04:17:38] micah`: s/cwere/were
[04:17:43] Paradox: micah`, no, at that point we'd moved to akami
[04:17:50] micah`: ACTION nods
[04:18:04] Paradox: i really like the way openshift works
[04:18:09] Paradox: its a fusion of EC2 and Heroku
[04:19:30] micah`: did they give a talk at railsconf two years ago? I think I may have seen a demo...
[04:19:41] ksinkar: i have added the devise gem and still i get method_missing error for authenticate_user! and I am not able to figure out what is the bug. I have worked with devise before and it worked out of the box. Unable to debug the problem. Any hints as to how to proceed?
[04:19:59] Paradox: they may have
[04:20:11] Paradox: basically you make or use "cartridges" that are basically equivalent to ruby bundles
[04:20:14] Paradox: but can contain more
[04:20:32] Paradox: ie a standard rails app would use a linux+nginx+ruby cartridge
[04:20:33] micah`: ksinkar: getting that in a browser?
[04:20:40] Paradox: and then a postgres cartridge
[04:20:40] ksinkar: micah`: yes
[04:21:46] Paradox: the coolest thing about OS though is
[04:21:48] micah`: ksinkar: did you restart the server after bundling?
[04:21:50] Paradox: it has something like amazon's auto-scale
[04:21:59] Paradox: you define paramiters and limits
[04:22:11] Paradox: and then it scales to the cheapest setting that can serve all your shit
[04:22:18] Paradox: dynamically
[04:22:39] Paradox: say a single large cartridge could take the job of 4 smaller ones
[04:22:44] Paradox: it will boot up the large one and swap it in
[04:22:47] Paradox: saving you money
[04:23:10] Paradox: its still beta though
[04:23:13] Paradox: so i wouldnt use it for production
[04:23:18] Paradox: but if you're a large app
[04:23:28] Paradox: behind a big proxy or something (like HAProxy)
[04:23:41] Paradox: might as well throw a few app servers on there and route a few users to it to see what happens
[04:23:52] ksinkar: micah`: yes
[04:23:59] Paradox: worst comes to worst they hit refresh and get a different app server
[04:24:03] ksinkar: micah`: many times
[04:25:32] ksinkar: micah`: have you faced this problem before?
[04:26:14] ksinkar: Paradox: so if we are doing something fancy like ffmpeg, then we can do that with openshift? Because we cannot do that with Heroku.
[04:26:20] Paradox: ksinkar, i believe so
[04:26:30] Paradox: i'd take a look
[04:26:34] ksinkar: Paradox: did you host your own openshift server?
[04:26:41] Paradox: but you very easily can
[04:27:03] ksinkar: I have not tried that yet. But sure would like to
[04:27:27] Paradox: openshift isnt beta anymore
[04:27:30] Paradox: its launched
[04:27:35] Paradox: i'd seriously consider it
[04:27:44] Paradox: esp considering heroku's new CEO is a corporate shill
[04:28:31] fulcan: how do you get rid of this error? You have already activated rake 10.1.0, but your Gemfile requires rake 10.0.3. Using bundle exec may solve this.
[04:28:32] Paradox: i've not been entirely trustworthy of heroku ever since the rapgenius stuff revealed they care more about new node programmers than bread and butter rails programmers
[04:28:39] Paradox: fulcan, bundle exec rake
[04:29:14] Paradox: ksinkar, https://www.openshift.com/developers/ruby
[04:29:32] Paradox: rhc app create ThisIsntHeroku ruby-2.0
[04:29:50] Paradox: rhc cartridge add PostgreSQL-9.2 -a ThisIsntHeroku
[04:29:51] zeromodulus: Why doesn't rails give me a name for my show route?
[04:30:07] Paradox: what do you mean zeromodulus
[04:30:39] zeromodulus: <name for this route would be here if it had one> GET /console(.:format) consoles#show
[04:31:01] Paradox: give me a sec to look at a routes in one of my apps
[04:31:36] zeromodulus: It also strikes me as odd that it's displaying consoles#show, since I've declared it to be a singular resource in my config/routes.rb file.
[04:33:42] micah`: ksinkar: looks like helpers are defined when you declare a devise_for in your routes
[04:33:48] micah`: ksinkar: assuming you've done that?
[04:34:06] ksinkar: micah`: devise_for :target_model
[04:34:13] ksinkar: micah`: I have donet hat
[04:34:13] Paradox: zeromodulus, have you ran/run rake routes
[04:34:24] zeromodulus: Yep, that's where I got that line.
[04:34:44] Paradox: check your routes, look for resources :whatever
[04:34:55] Paradox: if thats there delete it
[04:34:59] Paradox: if you used a generator it would add it
[04:35:22] zeromodulus: I do have a resources :console line, but I added that manually.
[04:35:32] Paradox: do you have entries in your controller?
[04:36:05] zeromodulus: It's kind of supposed to be a namespace.
[04:36:26] zeromodulus: But I chose to make it a controller instead.
[04:36:31] zeromodulus: Because I want to have at least one page for it.
[04:36:34] micah`: ksinkar: :target_model would yield #authenticate_target_model!, right?
[04:36:40] Paradox: im not sure then
[04:36:47] Paradox: i'd have to see code to do any more debugging
[04:37:32] zeromodulus: Okay, I have a gist coming up.
[04:38:08] ksinkar: micah`: you are so right. You nailed it.
[04:38:33] micah`: ksinkar: phew. was not totally familiar with Devise's Mapping class
[04:39:21] ksinkar: micah`: i guess this was case of having another pair of eyes
[04:41:44] zeromodulus: https://gist.github.com/zeromodulus/5893879
[04:42:28] zeromodulus: any other code that might be needed in this case?
[04:43:27] Paradox: zeromodulus, have you thought of using a namespace and then faking it
[04:43:33] Paradox: i had to do something similar in an app recently
[04:44:25] zeromodulus: No, I'm not sure how I would do that. It seems to work fine when I use resources as opposed to just resource.
[04:45:11] Paradox: i had to fake somethin like this a few months ago
[04:45:16] Paradox: let me see if i can remember what i did
[04:45:16] zeromodulus: I have another group of resources that look like this: https://gist.github.com/zeromodulus/5893887
[04:46:09] zeromodulus: Those generate the routes I need for that group.
[04:46:23] zeromodulus: But the other group, using a singular top level resource, doesn't seem to work as I expected.
[04:46:46] micah`: zeromodulus: both #resource and #resources map to a plural controller. you should just specify the controller to use in the route
[04:47:38] zeromodulus: if that's the case, and resource does accept a :controller parameter, it's undocumented in the v3.2.13 docs.
[04:47:42] Paradox: if i can recall right
[04:47:51] Paradox: there was some way of setting your own path in a route
[04:47:55] Paradox: but i cant remember what it was
[04:48:15] zeromodulus: micah`: it worked though, thanks.
[04:48:40] Paradox: resource does
[04:49:28] Paradox: what i was trying to remember was the "path:" thing
[04:49:46] Paradox: which lets you set your own path
[04:49:50] zeromodulus: I don't think that's what I needed.
[04:50:04] zeromodulus: the path prefix was coming out as I wanted
[04:50:10] Paradox: ie say i have a thing called "authentications"
[04:50:22] Paradox: which handles each oauth account for a user
[04:50:32] Paradox: so a user could have facebook and github or whatever
[04:50:49] Paradox: but i want the user to be able to manage them from /user/authentications
[04:50:53] Paradox: because everything else is /user
[04:50:57] Paradox: ie /user/edit
[04:51:00] Paradox: or whatever
[04:51:10] Paradox: paths to the rescue
[04:51:13] zeromodulus: I find it kind of weird how Rails doesn't generate names for all routes.
[04:51:22] Paradox: its better than the alternative
[05:08:18] zeromodulus: Ah, okay. I just realized something.
[05:12:28] zeromodulus: This is how I solved my routing and link building problem: https://gist.github.com/zeromodulus/5893942
[05:37:23] Paradox: zeromodulus, you can name your own routes afaik
[05:37:43] zeromodulus: Yeah, but I'd like to avoid it if possible.
[06:40:04] BrianJ: In my edit page how do I show what assets have currently been uploaded using paperclip? http://pastie.org/8096213 this gives me just empy file upload fields
[06:43:34] rushed: BrianJ: you might find a working example helpful http://railscasts.com/episodes/134-paperclip http://railscasts.com/episodes/182-cropping-images http://railscasts.com/episodes/253-carrierwave-file-uploads
[06:50:24] kara_sweets: hey guys is there a way to detect the base url in from within rails
[06:52:00] rushed: kara_sweets: normally you shouldn't have to (if you're not at the root then the relative path should be set by the web server and handled by rails)
[07:09:40] kara_sweets_: how would you define a survey model that allows users to add questions or rating levels?
[07:12:11] rushed: kara_sweets_: you might find a working example helpful http://railscasts.com/episodes/196-nested-model-form-revised
[07:19:32] kara_sweets_: using a qrcode gem to generate qr codes, the way it works is you query a url and it generates the code and displays it: http://backtalk.herokuapp.com/companies/1.png
[07:19:44] kara_sweets_: i wanna use the image in other areas of the site however
[07:20:22] kara_sweets_: nm think i answered my own question, you could set the source of an image tag as http://backtalk.herokuapp.com/companies/1.png
[07:22:15] rushed: "Let me just scan this QR code" said no one ever
[07:37:22] kgeo: hiall, I have a weird problem. I have a STI class hierarchy: Producer, Partner, Freelancer < Statusowner < Contact. However calling Producer.all gives me all Contacts instead of Producers only. The SQL by rails looks like: SELECT "contacts".* FROM "contacts" WHERE "contacts"."type" IN ('Partner', 'Producer', 'Partner', 'Freelancer') ORDER BY contacts.name
[07:38:28] kgeo: sorry that wa for Partner.all. Notice thath string "Partner" is twice in the IN statement!
[07:38:49] kgeo: any ideas what's going wrong?
[08:37:59] zeromodulus: kgeo: Seems like the problem is in the part where it checks for the type.
[08:38:23] zeromodulus: kgeo: It's basically just checking that the type is one of those 4.
[08:40:22] kgeo: zeromodulus: exactly, it should only check for one type. This should be the expected behaviour in STI, right? I could do the SQL by hand but that would defeat the purpose of the framework...
[08:41:14] zeromodulus: kgeo: Post some code.
[08:41:46] zeromodulus: Hard to tell what the problem is exactly with no code.
[08:42:11] kgeo: zeromodulus: hm. thats gonna be a lot of code. let me see, how to best handle.
[08:42:54] kgeo: zeromodulus: I forgot where we usuall post code...
[08:43:02] zeromodulus: gist.github.com is good.
[08:43:09] krainboltgreene: Where do you people look for contract work?
[08:43:13] zeromodulus: you don't have to post all of it
[08:43:23] zeromodulus: just something that demonstrates the problem
[08:56:08] kgeo: zeromodulus: have a look here: https://gist.github.com/kgeo/be94899b5d2b9086a356 in the controller the index is an example wher it's used. tell me if you need to see more
[09:00:31] zeromodulus: kgeo: okay, looking.
[09:01:07] zeromodulus: kgeo: shouldn't there be tables for the descendants?
[09:01:19] lxsameer: is there any standard or a conventional place to add rake task for a rails app ?
[09:01:42] kgeo: zeromodulus: no, its single table inheritance
[09:01:52] sevenseacat: lxsameer: /lib/tasks is pretty standard.
[09:02:10] lxsameer: sevenseacat: thanks
[09:02:26] rushed: lxsameer you might find a walkthrough helpful http://railscasts.com/episodes/66-custom-rake-tasks
[09:02:42] lxsameer: rushed: thanks man
[09:04:10] zeromodulus: kgeo: How does the query even know how to check the type?
[09:06:56] kgeo: zeromodulus: That is how STI is supposed to work. you introduce a hidden type column wher rails keeps track of the type of the current row/record. In queries this field is used to siimulate wparate tables, in this case of a (virtual) partners table.
[09:07:26] kgeo: well supposed to work. As I said I dont know what I am doing wrong.
[09:08:43] zeromodulus: In your data, are the type fields populated correctly?
[09:09:47] zeromodulus: If it's hidden to rails console, perhaps you could copy and paste the query into rails dbconsole.
[09:12:40] zeromodulus: kgeo: are you using a plugin?
[09:12:44] kgeo: the output is visible in console => [#<Partner id: 124, name: "24", type: "Partner" and so on
[09:13:46] kgeo: zeromodulus: the first Partner seems to be the class and further down (I cut down the output) the type is visible and correct.
[09:14:11] kgeo: zeromodulus: what plugin do you mean? for what?
[09:14:36] zeromodulus: kgeo: there are a couple plugins for implementing single table inheritance.
[09:14:47] zeromodulus: I was wondering if you might be using one.
[09:15:39] kgeo: zeromodulus: No I dont remember so. Should be straight rails 3.2. Let me add the gemfile to the gist just a sec
[09:15:45] strnadj: hello, its possible to define my own callback for activerecord from plugin?
[09:15:58] rushed: kgeo: did you gist your models and the console session of the results you found unexpected at some point?
[09:16:36] strnadj: Iam looking for some inspiration in https://github.com/pat/after_commit but it does not work for me .. singletonclass': undefined method `define_callbacks' for #<Class:ActiveRecord::Base>
[09:16:58] rushed: strnadj: are plugins a thing anymore? :)
[09:18:12] rushed: strnadj: did you notice this on the page you linked? "Please note: Rails 3 (and thus, ActiveRecord 3) provides commit callbacks natively, so this library will remain just for versions 1.2.x to 2.x of ActiveRecord."
[09:18:40] rushed: strnadj: you're flipping over some very old rocks there :)
[09:19:44] kgeo: rushed: yes, check https://gist.github.com/kgeo/be94899b5d2b9086a356
[09:20:19] strnadj: rushed: Yes, I read it, but in doc of Rails 3.2.13 I was not able to find, how to define my own callbacks … so I am looking for plugin, which does it
[09:21:26] rushed: strnadj: callbacks generally (as their name suggest) need to be provided by the framework (which will then call you back), what events are you trying to tie into?
[09:22:04] kgeo: zeromodulus: just added the gemfile to the gist. refresh.
[09:23:02] zeromodulus: well, if you don't know, I would assume you didn't add any.
[09:23:12] strnadj: Iam trying to extend https://github.com/swanandp/acts_as_list, cause I need to react to refresh positions… I think, there is 2 options how to do this.. observer to "position" field or extends plugin for some callback, which will be called after update positions finish
[09:23:46] rushed: kgeo: you might try flattening your inheritance hierarchy and making sure the basic case works, and then re-adding the complexity and checking things are still working along the way (some red-light green light tests might help here), you might also find a working example of the basic case helpful http://railscasts.com/episodes/394-sti-and-polymorphic-associations
[09:24:20] rushed: strnadj: and before/after save would not be sufficient for that task?
[09:26:17] strnadj: rushed: I try that, but it seems to, they are not called …
[09:26:18] kgeo: rushed: I watched the cast. refactoring the class hierarchy now is too late. I am too deep in the mud now... The only way out now I see is to write my own SQL.
[09:26:29] rushed: strnadj: that sounds unlikely :)
[09:26:53] strnadj: https://github.com/swanandp/acts_as_list/blob/master/lib/acts_as_list/active_record/acts/list.rb#L97
[09:27:21] strnadj: I think, it is the reason why ...
[09:27:23] rushed: kgeo: I didn't suggest you throw away your hierarchy, I suggested you temporarily flattening as a way to debug your issue :)
[09:28:41] rushed: strnadj: if you're thinking that's the case based on the assumption you can only have one after_update callback you're mistaken :)
[09:29:15] kgeo: rushed: How would I go about that? leaving aout classes in the hierarchy would break my application totally.
[09:29:49] strnadj: rushed: I know, that you can have more callbacks, but Are you able to set in what order which will be called?
[09:32:30] rushed: strnadj: check out the prepend option :)
[09:33:07] rushed: strnadj: also, could I suggest fewer assumptions about what won't work
[09:34:17] rushed: kgeo: does the whole application need to work to test a single Model.all in the console? http://www.youtube.com/watch?v=yB-JzPBJalA
[09:39:25] zeromodulus: kgeo: do you have a deadline for this app?
[09:40:15] kgeo: zeromodulus: yeah, kind of, its allready past...
[09:40:43] zeromodulus: Well, I don't think that's a good way to think about it, i.e. being stuck in the mud.
[09:40:55] zeromodulus: You can always recreate the problem differently as someone suggested.
[09:42:35] kgeo: zeromodulus: I guess I start over with the classes in a separate app and try to build a hierarchy with a similar depth to see what happens
[09:42:41] kgeo: thx to all
[09:42:59] kgeo: for your time
[09:43:07] zeromodulus: yep, good luck
[09:53:06] ksinkar: micah`: have you got persistent redirect loops while integrating devise?
[10:32:35] mnms_: Guys i cannot properly point to background.png in production mode in sass file
[10:33:04] mnms_: what helper should I use in sass ?
[10:38:22] strnadj: mnms_: http://stackoverflow.com/questions/9304607/sass-rails-helpers-image-url-asset-url-are-not-working-in-rails-3-2-1 maybe it can help to you :)
[10:40:29] mnms_: strnadj: Ok nevermind, Ive just added asset-url and it works. BTW Rails 4 :)
[10:40:37] mnms_: Thanks for help
[11:00:05] ganjaman: is this RUbyOnRAilS ?
[11:07:15] mdedetrich: how do you run a validate_each inside a custom validate_each (I essentially wan't to run another validation inside my custom validator)
[11:24:48] mdedetrich: or is there a way to manually run a specific validation on record
[11:28:03] khalidraja79: is there anyone sho can help a newbie question
[11:35:46] zeromodulus: hmm... thinking about using some JavaScript to hack some CSS.
[11:35:59] jalcine: What's the minimum memory requirement for Rails?
[11:37:03] zeromodulus: I need this div to take up the maximum amount of space it can within it's container.
[11:51:13] mnms_: what do you use for automatic deployment ?
[13:08:54] krainboltgreene: There are 67 gems, with +1,000,000 downloads, that are < 0.X.Y and match SEMVER semantics.
[13:34:54] Tokenizer: hi , if I want to "squish" all parameters to remove multiple spaces from strings (upon form submission), is there a way to achieve this?
[13:35:50] Tokenizer: actually to add to that question, to "trim/strip" first then squish
[13:36:29] Tokenizer: I want to do that automatically for all my forms and params
[13:36:32] krainboltgreene: It's best to create a normalizer class that takes the params, normalizes the values, and returns a hash for your #create
[13:37:18] Tokenizer: krainboltgreene, i don't know how to do that
[13:38:01] krainboltgreene: https://gist.github.com/krainboltgreene/5895170
[13:38:06] krainboltgreene: Something like that.
[13:38:32] krainboltgreene: Use objects to create cleaner controllers.
[13:39:03] krainboltgreene: That way you can be like: Article.create(ArticleNormalizer.new(params[:article]).to_hash)
[13:39:24] krainboltgreene: This also lets you avoid shit like strong_parameters.
[13:56:53] cwin: Any ideas why user_id would pass through correctly as a param, but be null when creating a new object (for me, it's a thread): https://gist.github.com/colewinans/5895213
[13:58:06] krainboltgreene: cwin: STDlib already provides a class called Thread.
[13:58:28] krainboltgreene: Don't call your model Thread.
[13:58:39] cwin: ok, I'll change it
[13:58:50] cwin: krainboltgreene: thanks!
[14:01:16] cwin: krainboltgreene: same issue persists after changing the name
[14:01:38] krainboltgreene: cwin: You changed the table name too?
[14:02:01] krainboltgreene: Update the gist.
[14:02:05] cwin: krainboltgreene: yes, and migrated – it creates the post and everything, just with a null id
[14:02:23] cwin: krainboltgreene: updated: https://gist.github.com/colewinans/5895213
[14:02:34] cwin: null user_id, sorry
[14:02:54] krainboltgreene: Well your controller #create method doesn't actually save anything.
[14:02:58] universa1: rubygems.org having problems for anyone else, too? can't download better_errors, times out :-(
[14:03:19] krainboltgreene: cwin: Which is exactly why the id is nil.
[14:03:43] cwin: krainboltgreene: ah, would I fix that with something like .create instead of .new?
[14:04:06] cwin: krainboltgreene: ok, trying it out, fingers crossed thanks!
[14:05:47] cwin: krainboltgreene: no dice, it's weird, I can see the user select happening on the web server, and it's grabbing the right user_id, but, it's not making its way into the insert for the post
[14:06:51] krainboltgreene: Switch user_id: to user:
[14:07:27] krainboltgreene: Also, you should probably save the publication.
[14:08:18] cwin: krainboltgreene: ok
[14:10:29] cwin: krainboltgreene: switching user_id to user: gives me Couldn't find User without an ID. I went ahead and updated the gist to include the server log, so you can see what I'm saying. It looks like, initially it grabs the user_id correctly… but then it gets lost along the way
[14:12:26] krainboltgreene: That is pretty strange.
[14:12:32] krainboltgreene: Grab pry and drop in.
[14:14:01] cwin: oh, a debugging tool
[14:14:12] cwin: ill check that out and try to figure it out, thanks
[14:15:38] himsin: hi, I am planning to use rails LTS, it has a 'harden' option, does it include the functionalities present in rails_xss plugin too?
[14:16:38] rushed: himsin: hey, you know what does? Rails 4 :)
[14:47:42] cwin: krainboltgreene: figured it out. the issue is, the post model accepts_nested_attributes for :user, and has a user through :publications, but… the join happens -after- the object is created… so it can't get the user_id through the join, because it doesn't exist yet
[15:20:39] dexec: Gentlemen, I have a project on 4.0.0.rc1. Are there any big changes I should watch out for between this and 4.0.0 final? Is there any individual CHANGELOG I can take a look at?
[15:32:02] universa1: dexec: you could look at the changes in the change log and/or the commits between those two
[15:32:47] universa1: dexec: you probably need to change the session store initializer, but aside from set everything worked in my little pet project, which just moved from rc1 to final
[15:34:29] dexec: universa1: Thanks will check that out.
[15:35:09] universa1: dexec: you need to have: YourApp::Application.config.session_store :cookie_store, key: '_your_app…' in the initialier
[15:35:15] universa1: instead of encryped_session_store
[15:49:27] cubecul: i'm trying to generate radio buttons (with one default checked based on an attribute value). why does 'until' in a helper not generate anything? https://gist.github.com/cubecul/5895665
[15:52:13] brownies: cubecul: you probably want until count == value
[15:53:14] cubecul: oh right. fixed that, but it still doesn't work
[16:07:21] helpa: cubecul: Two spaces is *the* standard indentation for Ruby. Please always use two-space indentation. Tabs are evil. See http://www.caliban.org/ruby/rubyguide.shtml#indentation
[16:07:21] slash_nick: cubecul: !indent
[16:10:51] cubecul: sorry about that: https://gist.github.com/cubecul/5895771
[16:11:14] slash_nick: cubecul: I can't express how much more enjoyable that is to read
[16:12:10] slash_nick: cubecul: !doesntwork (this bot always knows what to say)
[16:12:34] helpa: cubecul: What "didn't work"? Did your server not start? Did your computer explode? Did your webpage turn bright pink? Did your client not pay your bill on time? You may have to be more specific. A Gist (http://gist.github.com) of the code that doesn't work (and the error you are getting) will be helpful.
[16:12:34] slash_nick: cubecul: !didntwork
[16:13:09] slash_nick: you already have the gist of the code cubecul, but I don't know what's not working... is there a stack trace?
[16:13:31] s2013: whats the issue?
[16:13:50] cubecul: in full now… i'm trying to generate radio buttons (with one default checked based on an attribute value). why does the 'until' in the helper not generate anything? https://gist.github.com/cubecul/5895771
[16:14:25] cubecul: the radio_button outside the until will produce a radio button; the until itself will not produce any
[16:14:50] slash_nick: cubecul: ok... that's easy to explain... it'd help you to set something like return_string = ""
[16:15:08] slash_nick: and cubecul, instead of just calling radio_button_tag, call return_string << radio_button_tag
[16:15:24] slash_nick: cubecul: at the end of your method, "return return_string"
[16:15:37] slash_nick: cubecul: you'll find you need to call "return return_string.html_safe"
[16:18:32] cubecul: slash_nick: what was fundamentally wrong with what i did?
[16:19:09] slash_nick: cubecul: you called radio_button_tag in a helper without returning the html it produces to the view.
[16:19:57] cubecul: slash_nick: is there anything i could call that would spit ERB back to the view?
[16:20:08] cubecul: slash_nick: or does that not matter?
[16:20:35] slash_nick: cubecul: you don't need or want that
[16:20:52] slash_nick: cubecul: unless you don't know yet about "rendering partials"
[16:21:27] slash_nick: cubecul: what I mean is that the only time you should be "spitting ERB" into a view is by rendering a partial in that view (partial contains html/erb)
[16:22:18] slash_nick: cubecul: did you get it going or should I fork that gist?
[16:22:23] cubecul: slash_nick: ok. i think i understand now. i still have a lot more reading to do
[16:22:29] cubecul: slash_nick: i got it to work! thank you
[16:24:57] slash_nick: great cubecul... good job
[16:25:18] Fire-Dragon-DoL: can someone suggest me a good method to replace all &amp; &nbsp; and similar in their character representation? I'm converting an html e-mail to a text mail. However, raw doesn't work on most characters, CGI::unescapeHTML does not replace &nbsp;
[16:29:36] leftblank: hi… i'm getting an error when bundle installing rails 4.0.0 -
[16:29:38] leftblank: Gem::RemoteFetcher::FetchError: Errno::ETIMEDOUT: Operation timed out - connect(2) (https://rubygems.org/gems/rake-10.1.0.gem)
[16:29:48] leftblank: any ideas why?
[16:32:14] crankharder: something is wack in the land of rubygems right now
[17:13:42] pontiki_: http://www.downforeveryoneorjustme.com/rubygems.org
[17:32:24] Fire-Dragon-DoL: Why on earth htmlentities decode into non-human-readable string?!
[17:48:15] flaggy: hello. I recall seeing a rails cast which taught how to create a check box button for deleting a given field. Anyone knows what it was (or have other references as to how to do it?) I recall you could name the check box something and then it would work when you save the object
[17:55:25] RubyPanther: flaggy: http://lmgtfy.com/?q=railscast+checkbox+delete
[18:20:30] nobitanobi: Hi guys, anybody knows how to created a Nested Object in Rails 4, like this:http://stackoverflow.com/questions/845366/nested-object-creation-with-json-in-rails
[18:20:43] nobitanobi: It's working in Rails 3, but not in 4
[18:25:26] scyllinice: nobitanobi: Post code, any errors you're getting, etc. Otherwise, we can just guess. Guessing isn't any fun
[18:26:44] nobitanobi: scyllinice, let me do that.
[18:27:30] RubyPanther: My guess, having not clicked on stackwhatever, is that you used rails 3 advice from a forum, instead of a rails 4 guide or blog
[18:28:44] nobitanobi: scyllinice, here you go: https://gist.github.com/novito/5896300
[18:29:12] nobitanobi: yes, it's a Rails 3 advice. But I can't find that in the docs. How o send a nested object when creating a parent Object.
[18:30:05] scyllinice: Ok, that's code
[18:30:11] scyllinice: Now what isn't working?
[18:31:41] nobitanobi: scyllinice, post "/api/v1/users/#{user.id}/campaigns/#{campaign.id}/trips", {"trip" => {"events_attributes" => [{"distance" => 200}], "distance" => 200}}, {'HTTP_AUTHORIZATION' => "Token token=\"#{auth_token.access_token}\""}
[18:31:52] nobitanobi: this is not creating an Event object
[18:34:41] nobitanobi: With Rails 3 it was working fine. As suggested here: http://stackoverflow.com/questions/845366/nested-object-creation-with-json-in-rails
[18:44:12] nobitanobi: scyllinice, basically I would like to know how can I created Nested Objects when passing them in a JSON in rails
[18:52:43] scyllinice: nobitanobi: Check for ROLLBACK or otherwise messages in your log
[18:52:51] nobitanobi: scyllinice, there is no rollback
[18:53:00] nobitanobi: it just seems is not getting the events_attributes param
[18:53:31] nobitanobi: I get a 200 with events: []
[18:55:13] scyllinice: nobitanobi: Where are you passing trip_params? I don't see it being used
[18:55:54] nobitanobi: uh? In the test is here: post "/api/v1/users/#{user.id}/campaigns/#{campaign.id}/trips", {"trip" => {"events_attributes" => [{"distance" => 200}], "distance" => 200}}, {'HTTP_AUTHORIZATION' => "Token token=\"#{auth_token.access_token}\""}
[18:56:13] nobitanobi: oh my godness.
[18:56:22] nobitanobi: scyllinice, you are right, I'm not passing it in the create.
[18:58:04] nobitanobi: scyllinice, same thing though hum.
[18:59:44] scyllinice: nobitanobi: Alright. How about your logs?
[19:00:09] nobitanobi: yup, I will paste that, but is just showing the INSERT into the trip table.
[19:00:20] scyllinice: nobitanobi: Go ahead and add the definition of the Trip class
[19:02:01] nobitanobi: https://gist.github.com/novito/5896408
[19:04:10] nobitanobi: it's completely ignoring the "events_attributes" attribute :O
[19:08:21] nobitanobi: scyllinice, need to reboot brb
[19:12:10] mnms_: Guys I cant find out why I must refresh page to get the jquery validation engine work, because if I go from another page to sign_up page validation is not working
[19:13:15] mnms_: I added validationengine method on document ready function
[19:25:28] blackmesa: Hi all. I have an index page which lists companies from my db. The company titles are links to /edit/:id. I'd like to achieve that it doesnt visit the edit page, but instead toggle the form below the company title. anyone has a hint where to start? thank you
[19:29:02] blackmesa: I think I have to work with render "form", locals: :id" or something like that
[19:36:29] nobitanobi: scyllinice, I have created a SO question...Just in case you care: http://stackoverflow.com/questions/17394098/create-nested-object-with-rails-4-json-call
[19:48:22] vadelius: Can I easily route all /img/ requests to /images ?
[19:49:22] fryguy: vadelius: something you should consider doing at the webserver level, not the application level
[20:19:10] machty: anyone know a good place for me to put code that adds custom macros to ActiveRecord? e.g. my own acts_as_whatever that adds a bunch of a class and instance methods? i have some stuff in initializers, but if i change it i obviously have to restart the server. Is this something I could put into /lib and autoload/reload somehow?
[20:35:02] Aque0s: good evening everyone. How can I create a custom route helper? I have an STI setup with a base model named Content... I've then got a bunch of content types and I'd like to create a route helper like content_path(@content) which returns the URL for that piece of content dependant on its type...
[20:36:10] davidcelis: it's Ruby, just write one and make it a helper method?
[20:36:36] Aque0s: okay, so in application_helper.rb?
[20:36:49] davidcelis: Unless you also want to use it in controllers
[20:37:00] Aque0s: I would yes
[20:37:02] davidcelis: In which case you should add it to ApplicationController (with a helper_method call)
[20:37:13] davidcelis: or some module included by ApplicationController if you want to separate it out
[20:37:52] Aque0s: I see, okay... Is there an accepted approach for STI routing?
[20:39:55] davidcelis: undefinedza: Not really. I'd probably just check @content.type and return a path accordingly
[20:40:06] davidcelis: undefinedza: You could maybe leverage `url_for`
[20:50:11] DANtheBEASTman: hi all.. pretty new to rails dev, I have a shell on a server that doesn't have root, but has apache running.. any chance of me getting rails set up on here?
[20:58:49] nobitanobi: scyllinice, I found it.
[21:02:50] davidcelis: DANtheBEASTman: don't you need root to do anything with apache
[21:02:56] lethjakman: what do you guys think of things like heroku or amazon ec2 for hosting a rails site?
[21:02:59] lethjakman: is it worth the money?
[21:03:28] davidcelis: heroku is way more expensive than ec2
[21:03:45] scyllinice: ec2 is an expensive VPS. Heroku is a fancy layer on top of EC2. If you know system administration, just do your own VPS and worry about scaling when you need to
[21:04:55] nobitanobi: scyllinice, I was doing the call like this: {"trip":{"distance": 300, "events_attributes" : [{"distance":300}]}} --- And it didn't work.
[21:05:04] nobitanobi: but doing the call like this: {"trip":{"distance":400}, "events_attributes":[{"distance":300}]}
[21:05:09] lethjakman: scyllinice: cool, that's what I've been doing. seemed a LOT more cost effecient.
[21:05:17] DANtheBEASTman: davidcelis: yeah, pretty much. I have a good relationship with the admins so i can probably get them to add a few lines in apache.conf as long as it won't mess up the rest of the site
[21:05:25] lethjakman: just wanted to make sure I wasn't missing something crucial.
[21:06:21] scyllinice: lethjakman: People were hosting rails apps before Heroku and ec2 came along. :P
[21:52:58] flip_digits: are there any good books on Rails Four worth buying now?
[21:57:09] butblack: why doesn't this return all the instances of User?
[21:57:10] butblack: https://gist.github.com/ebbflowgo/5897130
[21:57:28] butblack: and how could i make it do so?
[21:58:34] tbuehlmann: ugh? well, User.all will work, or if you want to just get ones from given ids, try User.find(ids)
[21:58:53] butblack: tbuehlmann: yeah.. I'm still curious as to why this doesn't work
[21:59:11] tbuehlmann: well, at first, where's @users defined?
[21:59:27] butblack: tbuehlmann: isn't it defined there?
[21:59:50] tbuehlmann: ah, didn't see the rescue. that's really dirty..
[22:00:10] BrianJ: How do i limit an .each to like 5 records returned? for instance @instance.each do |instance| and limit that to 5?
[22:00:29] butblack: tbuehlmann: i'll improve it if there's a better way, regardless it seems to me that this should world
[22:00:39] tbuehlmann: so, for id=2, it will raise and @users will be just a single instance of User. for id=1 you are trying to call User+, which will raise again
[22:00:47] tbuehlmann: in the end, you should just get the user with id=5
[22:01:10] butblack: However, I would like to get all of the intances
[22:01:20] butblack: i'll improve it
[22:01:50] tbuehlmann: BrianJ, try `@instance.take(5).each do |instance|`
[22:02:15] butblack: tbuehlmann: i updated it: https://gist.github.com/ebbflowgo/5897130
[22:02:35] butblack: I meant to put in a where clause, for example instead of specifying ID you could do a different attributes
[22:02:37] BrianJ: tbuehlmann: undefined method `take'
[22:02:46] tbuehlmann: BrianJ, what class is @instance of?
[22:03:08] tbuehlmann: butblack, what the heck are you trying? could you give a real example? that just makes no sense
[22:03:37] BrianJ: Instance class, active record base
[22:03:49] BrianJ: Instance model
[22:03:56] tbuehlmann: and it has an #each method?
[22:04:01] tbuehlmann: for what exactly?
[22:05:24] Mang0z0r: Hi everyone!
[22:06:18] BrianJ: Instance.all
[22:06:24] BrianJ: Instance.fnd(:all)
[22:07:18] boytoy: How come I can still visit my site with the Tor Browser after implementing this? https://gist.github.com/kakekake89/5888836 (alternative 2: Rails)
[22:08:58] BrianJ: nevermind, i removed the find(:all) and tried using take(5). Once i added the find back, it worked
[22:09:07] BrianJ: thanks tbuehlmann
[22:09:39] tbuehlmann: and if you just need 5 records, you should use .limit(5) when retrieving the records
[22:10:06] BrianJ: Instance.find.imit(5)?
[22:10:14] BrianJ: Instance.find.limit(5)?*
[22:10:19] tbuehlmann: without find
[22:13:08] butblack: tbuehlmann: that's what' I'm trying to do, still not sure why it doesn't' work
[22:14:41] IRC-Cop: is this ruby?
[22:14:52] Apane: IRC-Cop, no
[22:15:02] Apane: IRC-Cop, this is rubyonrails
[22:15:05] IRC-Cop: why does it say ruby on rails
[22:15:15] Apane: IRC-Cop, captain obvious
[22:15:24] IRC-Cop: so this is ruby
[22:15:35] Mang0z0r: ruby and ruby on rails are two different things.
[22:15:49] Mang0z0r: well, not so much but you apply it differently.
[22:16:19] IRC-Cop: it is ruby on rails
[22:16:32] Mang0z0r: isn't it ruby ?
[22:16:32] Apane: IRC-Cop, evidently, he is a troll
[22:17:17] IRC-Cop: so what is ruby ON rails good for?
[22:18:26] Apane: IRC-Cop, no, that is not the reason sorry.
[22:18:36] krainboltgreene: Apane: Mute it.
[22:19:18] IRC-Cop: !worthless apane
[22:20:31] IRC-Cop: FUCKING BITCH
[22:21:02] Apane: IRC-Cop, But yeah, Rails is the framework that runs on the Ruby language
[22:21:32] Apane: IRC-Cop, give it a shot man, ya might like it - it's great for quick prototyping
[22:22:16] krainboltgreene: Apane: It's a troll, don't respond.
[22:24:41] Mang0z0r: Apane: You are way too nice :)
[22:24:51] tbuehlmann: butblack, https://gist.github.com/tbuehlmann/5897229#file-gistfile1-rb
[22:25:04] Apane: Mang0z0r, nah lol i was just trying to see how he'd respond to that
[22:27:25] Mang0z0r: good evening for me :)
[22:29:55] lamaster: hey guys, could someone tell me that is the right way to execute ruby method for example every second, something like setInterval in js
[22:30:19] lamaster: should i use while() and sleep or something?
[22:31:15] lamaster: that's needed to stream data via live controllers
[22:36:01] machty: I would like to reopen a Gem and include a custom module i write in lib/my_app/gem_override.rb. I have this working, but how do I get it to reload between requests? this seems to be a slightly different problem from the common one's on SO, but i can't seem to figure it out
[22:36:39] machty: in my fiddlings with IRB, if i define a class which "includes" a module, and then I reopen the module later and add stuff to it, the original class gets the new code
[22:36:55] machty: without haven't to do anything special/more than reopening the included module
[22:37:06] machty: but this doesn't seem to work with rails
[22:41:13] s2013: https://gist.github.com/ss2k/807bb5b92c709f171bb1 im getting an wrong number of arguments (0 for 1)
[22:41:54] s2013: kind of confused as to why
[22:45:37] lethjakman: lamaster: I know this isn't an answer, but it may help you. I saw your question and it has me curious as to how you'd handle something like that. http://blog.phusion.nl/2012/08/03/why-rails-4-live-streaming-is-a-big-deal/
[22:46:11] lethjakman: s2013: add the error to that.
[22:46:35] s2013: what you mean
[22:50:33] lethjakman: s2013: you got an error message telling you that you're getting the wrong number of arguments. post the whole thing in there under a new "file"
[22:50:36] Apane: looking to integrate chat (similar to chatroulette minus video) into my app. what is a good gem for this?
[22:51:47] s2013: Apane: http://railscasts.com/episodes/260-messaging-with-faye?view=asciicast did you look into that?
[22:52:11] s2013: lethjakman: https://gist.github.com/ss2k/807bb5b92c709f171bb1 updated
[22:53:02] lethjakman: s2013: what does the model for current_user look like. specifically the admin method.
[22:53:12] davidcelis: app/models/user.rb:36:in `admin?'
[22:53:32] lamaster: lethjakman: thank you, i've tried while with sleep(), and that's work fine for me, i have needed this to test server-sent events. i'll be using postgres notifications for events then
[22:53:33] davidcelis: the trace tells you exactly where to look
[22:54:00] davidcelis: line 36 of user
[22:54:14] s2013: yeah i see now. it was by a different programmer. k thanks im fixing it now
[22:55:54] lethjakman: lamaster: how well does that perform concurrently?
[22:55:57] lethjakman: I'm just curious
[22:56:10] Apane: nice! thx, s2013
[22:56:57] lamaster: lethjakman: can't really say yet
[22:59:06] zeromodulus: I'm using a gem called yaml_db which dumps the database to yaml, this works very nicely when I want to create some sample data, dump it to a file, and then load all of the data back in after I've tested features such as delete/update/etc, however... I'm also using Paperclip for image uploads. The actual images themselves do not get dumped, so I cannot restore the images later. What are some ways I can make it s
[22:59:07] zeromodulus: o the images get dumped?
[22:59:52] lethjakman: zeromodulus: write a script that wraps the yaml dump and copies over the images as well?
[23:00:05] zeromodulus: Ah, excellent idea.
[23:00:18] lethjakman: I think that's the easiest, since the images are literally just a folder.
[23:01:59] AntelopeSalad: what path do i need to add to my system path to run binaries that are installed via gem install?
[23:02:09] zeromodulus: lethjakman: where should I put the script?
[23:02:27] AntelopeSalad: i'm new to ruby and rails and i wanted to try a gem out, i can install it fine but the binary it installs is not on my path
[23:02:46] cwin: I have a join called Subscriptions. It stores a user_id and a post_id. I'd like to display all of the posts a user has subscribed to – how would I select and display each post using the subscriptions table?
[23:02:53] zeromodulus: lethjakman: I suppose I could put it in lib, but maybe I could put it on the model I want to dump?
[23:07:51] jaymiejones86: cwin you would need a relationship between user post and subscription
[23:07:57] jaymiejones86: cwin that should get you going
[23:08:04] w32stuxnet: would anyone here be able to tell me how to show a different form input type based on the value of the input in simple_form?
[23:08:32] jaymiejones86: w32stuxnet why are you changing the type?
[23:08:51] w32stuxnet: because I have a bunch of selects with an "other" option
[23:09:03] w32stuxnet: and it's all done dynamically, so based on the page it may or may not have an other option
[23:09:35] cwin: jaymiejones86: I have one – it's user_id. I'm trying to display the post for each subscription belonging to the current_user. I'm just not sure how to construct that in my controller.
[23:09:39] jaymiejones86: w32stuxnet well do you store the selects "other" state? because you could check to see if other has been set, then display the additional field
[23:09:42] w32stuxnet: and as the other option is stored within the array that is turned into a bunch of radio boxes, I need to be able to replace the radio box with a text field
[23:10:16] jaymiejones86: so you have a has_many posts through subscription in the user model?
[23:10:51] cwin: @jaymiejones86 yep. right now, I have it listing all of the subscriptions, but, I'd like to take it one step closer, and instead of listing the subscriptions, display the posts for each subscription. the has_many :through and everything is all setup and working perfectly.
[23:11:24] jaymiejones86: so the subscription model has many posts? so you would do like user.subscriptions.posts should give you the array of posts
[23:11:34] jaymiejones86: given you defined user = User.find(x)
[23:11:45] cwin: jaymiejones86: ah ok, I'm going to give that a shot, that sounds right, thanks!
[23:13:36] cwin: @jaymiejones86 If I do user.subscriptions.posts, I need to define the method "posts" as being the objects associated with each post_id in the subscriptions table. any idea how i can do that?
[23:14:52] cwin: jaymiejones86: *
[23:15:59] jaymiejones86: Subscription model has_many :posts
[23:17:07] s2013: i have an admin section on a site and i wanta sidebar to be in every admin page. what would be the best way to do that? i created the sidebar and put it in admin/layouts/_sidebar.html.erb
[23:17:19] s2013: should i do that in application/layout and add some sort of condition? im a bit confusd
[23:17:38] cwin: jaymiejones86: got it, that's the case currently. i just need to define a method in my controller that says… find each post for every subscription, using the post_id from the subscription. I'm just not sure how to write that.
[23:18:46] Travka: Hey, anyone free to help ? i have a question about ror. I have a problem with basic blog tutorial, undefined method `title'
[23:18:46] Travka: Extracted source (around line #3):
[23:18:46] Travka: <strong>Title:</strong>
[23:18:47] Travka: <%= @post.title %>
[23:18:56] jaymiejones86: cwin you could define an instance variable in the controller, or in the model you could write a method that gets all of those posts so like display_subscribed_posts method on the model and generate the array there
[23:19:05] cwin: jaymiejones86: something like @posts = subscriptions.where( "id => subscriptions.post_id")
[23:19:08] jaymiejones86: cwin in the model is probably the best appraoch
[23:19:37] cwin: jaymiejones86: ok, awesome, thank you! do you know where i could find an example of what that would look like? i'm just not sure how to write it
[23:19:42] fryguy: s2013: a better choice would be to create a baseclass admin controller that defines using a new layout and have all of your admin controllers inherit from that instead of applicationcontroller
[23:20:27] s2013: i have a separate namespace for admin
[23:21:40] jaymiejones86: cwin ;) will leave that up to you for self discovering
[23:21:53] s2013: the header that i have in application layout is fine
[23:21:57] cwin: jaymiejones86: thanks for getting me this far, cheers!
[23:22:00] s2013: i just need a separate sidebar
[23:22:48] jaymiejones86: it may or may be something like self.subscriptions.posts within the display_subscribed_posts method
[23:24:28] Travka: hey, anyone can help ?
[23:24:48] jaymiejones86: Travka need more info, how are you setting @post? what does your model look like?
[23:24:59] jaymiejones86: send through a gist of your model and controller
[23:25:18] Travka: simply guide http://edgeguides.rubyonrails.org/getting_started.html
[23:27:24] Travka: I have a problem after adding /app/view/posts/show.html.erb and where i trying to save post from /posts/new , and where i back to /posts/#postnumber i get error undefined method `title'
[23:27:41] jaymiejones86: Travka send through a gist of your model and controller
[23:27:52] jaymiejones86: i dont care what the site says, i want to see what YOU have done
[23:27:59] Travka: kk, thanks.
[23:32:53] Travka: jaymiejones86 https://gist.github.com/anonymous/5897460
[23:34:27] jaymiejones86: Travka under your create method in your controller @post = Post.new(params[:post].permit(:title, :text)) should be @post = Post.new(post_params)
[23:34:39] jaymiejones86: Travka also i cannot see your model in the gist
[23:35:32] Travka: model is empty class Post < ActiveRecord::Base
[23:40:55] jaymiejones86: and your db has an entry of title?
[23:42:20] Travka: yes sure, t.string :title t.text :text
[23:44:14] jaymiejones86: ok in your view, seeing as you dont have any tests instead of @post.title do @post.inspect and see what variables you have in there
[23:47:20] Travka: Title: nil Text: nil
[23:50:23] cwin: jaymiejones86: I'm not finding any resources that are helpful for display an object using the object_id in a has_many :through association. do you know of any good resources for this? read the raw API but didn't get too much insight there
[23:50:49] Travka: ok, anyway thanks for your time.
[23:51:39] jaymiejones86: Travka, thats the problem, theres no data getting @post, so its not finding the post or the title has no data, therefore, error
[23:52:42] jaymiejones86: cwin as i said earlier self.subscriptions.posts within the display_subscribed_posts method… hint hint self in this instance would mean the user option so if you had that method in your model and then you did say user = User.find(x) and then user.display_subscribed_posts it might just list the posts… or get you close...
[23:53:24] cwin: jaymiejones86: ahhhhh ok, thanks a ton!
[23:53:42] jaymiejones86: cwin im quite tired, but i believe that should be right
[23:53:59] cwin: jaymiejones86: no worries, i'll play with it a bit – i think i'm close
[23:55:42] jaymiejones86: cwin https://gist.github.com/jaymiejones86/3f7cdbb9bb2c7be2b486
[23:56:01] s2013: anyone familiar with inherited-resources gem?
[23:56:31] cwin: jaymiejones86: oh snap, that makes perfect sense, i'll give that a shot now – thanks!