« Back to channel list

#RubyOnRails - 29 September 2013

« Back 1 day Forward 1 day »
[00:02:40] foucist: taternuts: heroku uses pg anyways
[00:04:50] taternuts: lol maybe postgresql will install nice
[00:07:07] dllama: can u do relational db stuff with active record and mongo?
[00:07:09] dllama: like has_many, etc?
[00:15:24] helpa: Rather than guru hunting and asking if someone has used this or that, just ask your question with as much detail as possible. Even if someone hasn't used X Y or Z, there's a high chance someone can help, but only if they have details to work with.
[00:16:03] ZirconCode: If I, for example, am in a .each loop in a view, is there a way to output a string to the view each pass? some view method?
[00:16:29] ZirconCode: * to "add" to the view >_>
[00:18:15] foucist: ZirconCode: <%= foobars.each do |foobar| %> <%= "string #{foobar.name}" %> <% end %>
[00:18:42] foucist: <%= " ... " %>
[00:18:55] ZirconCode: oh I have to take it apart, thanks
[00:25:37] dllama: can anyone suggest on how to get nokogiri to return html?
[00:25:53] dllama: i'm using it to parse a document to grab only specific content, the rest can be dumped
[00:26:21] dllama: ok, .content gave it to me in text
[00:26:38] ZirconCode: oh sorry, try .to_s
[00:26:50] dllama: hmm i think that was it.
[00:26:51] foucist: .to_html ?
[00:26:55] dllama: was soo obvious too,
[00:30:24] WhatAboutBen: Can someone give me a tip in the right direction with a form. I am trying to create one where a total figure updates dependant on what the user selects in multiple drop-down boxes. Here is what i have so far. any comments would be appreciated.
[00:30:26] WhatAboutBen: https://gist.github.com/WhatAboutBen/4188af277a0991f464a8
[00:30:45] jbald: has anyone had issues when using autosave on a polymorphic has_many association?
[00:34:39] ZirconCode: WhatAboutBen I think you're looking for javascript /-> AJAX
[00:35:26] ZirconCode: unless you want to reload the page everytime the user selects a new value
[00:37:11] WhatAboutBen: Okay, hoped it was possible. Thanks
[00:41:29] platzhirsch: Is there a way to couple model and controller, so that model classes are loaded automatically together based on the paramer id?
[00:45:58] platzhirsch: ah, on it http://rails-bestpractices.com/posts/57-substituting-before_filter-load_object
[00:51:31] WhatAboutBen: ZirconCode: have you any recommendation on where i should start whith trying to create an interactive calculation form?
[00:54:27] dcope: this is so weird... everything was working fine for weeks and now i try to deploy and asset_sync is stuck in an infinite loop
[00:54:39] taternuts: WhatAboutBen: the 'have you any' + Ben makes me think your from england?
[00:54:46] taternuts: or a steelers fan
[00:59:05] WhatAboutBen: I'm from England. ha!
[01:13:58] bg_: Hi there, I am building a rails app using ember.js and I am curious if it is possible to route the index to '/#/' instead of '/'
[01:14:51] s2013: yeah i think so
[01:15:39] s2013: you can try uisng as
[01:15:55] s2013: actually no
[01:16:05] dcope: is it possible to use the route helpers in a model?
[01:16:10] s2013: try to use match i guess
[01:18:47] s2013: im having an odd error: https://gist.github.com/ss2k/47f89c0b9827c3ce47e2 staff.operator.name gives an undefined method. but it works in console
[01:23:46] s2013: this is so f'n odd
[01:27:15] dopie: im almost correct
[01:28:52] jbald: has anyone had issues when using autosave on a polymorphic has_many association?
[02:04:42] platzhirsch: Is there an alternative way of writing: resource :repository, only: [] do ... end ?
[02:06:06] s2013: what do you mean Plasmastar
[02:06:09] s2013: platzhirsch, sorry
[02:06:35] platzhirsch: s2013: I want to use the resource keyword to add members to my resource in the routing file
[02:07:10] platzhirsch: but I don't want to get all the default action routes (index, create, show, delete, etc.) so I use only and supress them all by supplying an empty array
[02:13:18] agent_white: Evenin' gents
[02:17:48] jrobeson: agent_white, i'd just go with folks..
[02:18:15] darrik: platzhirsch: you could always do them by hand: get '/repository/:id/my_method' => 'repositories#my_method', :as => :my_method_repository, etc
[02:18:38] jrobeson: please give me real entity repositories .. :(
[02:28:53] jrobeson: platzhirsch, what exacdtly is wrong with doing only : [] , that seems like the perfect way of doing it . what more are you expecting?
[02:29:10] platzhirsch: jrobeson: oh nothing, I was just curious
[02:29:16] platzhirsch: perfectly fine
[02:29:21] platzhirsch: darrik: ah yeah :)
[02:29:31] jrobeson: that seems the best way to still get any sort of benefits
[02:29:38] jrobeson: anything else would be like what darrik says
[02:29:57] jrobeson: at least out of the box in rails..
[02:30:17] hayleybarker: If I have two Arrays and I wanted to check if array #1 had a value that array #2 had and if it did remove that value for array #1, could I do that with a set?
[02:30:29] jrobeson: do you need a set?
[02:30:37] jrobeson: i mean, are you planning on using a set
[02:31:07] hayleybarker: No I don't need to use a set if there is a better way
[02:37:13] jrobeson: hayleybarker, what is the code you're using now?
[02:39:43] s2013: jrobeson, you here?
[02:40:17] s2013: https://gist.github.com/ss2k/47f89c0b9827c3ce47e2 im getting name is undefined method error .. its really odd cause if i check each individual staff.operator.name it works
[02:40:34] s2013: or if i loop staff.operator it works just not operator.name
[02:40:41] EvilEpoch: Warm Greetings to all, I am The EvilEpoch.
[02:43:15] jrobeson: warm greetings to the EvilEpoch
[02:43:24] EvilEpoch: Greetings to jrobeson from The EvilEpoch.
[02:43:33] hayleybarker: jrobeson, All I have at this point is two arrays of around 300 items each. My probably very backwards way to go it through each one of the items and see if the array had that item in an each loop and if it does delete that element
[02:43:37] s2013: its such an odd error that i cant seem to figure it out
[02:44:09] jrobeson: hayleybarker, a2 - a1 ?
[02:44:51] s2013: hayleybarker, use delete_if
[02:45:07] jrobeson: s2013, if it's a flat list.. a2 - a1 is easier
[02:45:13] s2013: yeah that too
[02:45:32] s2013: jrobeson, did you see my gist?
[02:46:24] jrobeson: seems possible that there might not be an operator for that particular one?
[02:46:33] jrobeson: did you really go through each? not just the first or last ones?
[02:46:33] EvilEpoch: The EvilEpoch wishes some opinions. The EvilEpoch wants it so that a model he has builds objects with a has_many association. So that the associated object exists as soon as you do Model.new, something.many.build etc...
[02:46:42] EvilEpoch: The EvilEpoch hopes he conveyed that idea correctly.
[02:46:45] s2013: its only 2 items for now and they both have operators
[02:46:58] hayleybarker: s2013 jrobeson, thanks guys I'll try both
[02:46:59] s2013: but you know what
[02:47:14] s2013: i realized whats wrong.. its related to what you said. you are right.
[02:47:35] jrobeson: scoping is magic
[02:48:15] jrobeson: EvilEpoch, it might be possible to put in an after_initialize callback?
[02:48:28] jrobeson: but i did it in my controller (soon to be formobject)
[02:48:31] s2013: i used try
[02:48:36] s2013: and that seems to have solved it
[02:49:21] EvilEpoch: jrobeson: The EvilEpoch did not see that in the API list of call backs but just saw it now its in the paragraph after the list. The EvilEpoch is most thankful and will investigate this option.
[02:50:42] jrobeson: EvilEpoch, i've never tried definiting my own initialize method in an activerecord class before, but that might be better.. or doing it in a form object
[02:51:40] EvilEpoch: jrobeson: The EvilEpoch has done it by overriding new however The EvilEpoch doesn't like overriding methods you're given because chances are high Rails provides some mechanism to do what you want without doing that.
[02:51:52] EvilEpoch: With that said, sometimes overriding methods is a worthy undertaking.
[02:52:07] jrobeson: well obviously one should do super() at the end, if it is possible
[03:14:28] platzhirsch: Where would I initialize the ActiveSupport Cache in my Rails app?
[03:15:06] jrobeson: i'd guess an initializer, unless that is actually too late
[03:15:24] jrobeson: i don't know anything specific about that class .. and what it caches..
[03:15:50] jrobeson: you'd think that'd be documented tho..
[03:35:15] Matix: I've to override the method of a third party lib
[03:35:19] Matix: where would you put that code?
[03:35:39] Matix: actually I have to add a method
[03:35:51] Matix: to be executed in case no method is found in that class
[03:37:06] Matix: hmn. I can fix it with method_missing
[03:37:15] Matix: still I don't know where to put it, in what file
[03:39:54] burmjohn1: anyone have a link to a gist / blog post on how to do a add / remove(destroy) on nested form (rails 4). Using simple_form but any example would be great.
[03:45:18] ner0x: What are some alternative methods to testing without using factory_girl_rails
[03:47:52] jstrong: In simple_form the inputs reference methods on FormBuilder https://github.com/plataformatec/simple_form/blob/master/lib/simple_form/inputs/string_input.rb#L12
[03:48:22] jstrong: I've searched all the simple_form code and cannot find any definition of "def text_field". I cannot find any use of "define_method" "class_eval" or "instance_eval" either
[03:48:30] jstrong: there's no external gems that could be including these values.
[03:48:38] jstrong: any ideas? :\
[03:49:29] jrobeson: ner0x, doing it manually.. without factory girl.
[03:49:52] jrobeson: setting up things manually per test
[03:50:01] jrobeson: or.. using the rails default of fixtures..
[03:50:02] ner0x: jrobeson: That's about it? What about mock/stubbing? I've done factorygirl and I thought it worked out nicely just figured I'd try an outside perspective.
[03:50:33] jrobeson: there are various mocking and stubbing frameworks out there
[03:50:40] jrobeson: i use rspec, it comes with it's own basic mocking and stubbing
[03:50:53] jrobeson: i think minitest does too, but i'm not sure
[03:52:01] jstrong: I R RETARDED
[03:52:03] jrobeson: jstrong, it probably cesomes from rails
[03:52:24] jstrong: class FormBuilder < ActionView::Helpers::FormBuilder
[03:52:32] jstrong: I didn't notice that FormBuilder extends ActionView form builder
[03:52:34] jstrong: which makes perfect sense
[03:52:38] jstrong: just a total brain lapse there ....
[03:52:53] jrobeson: uhmm.. turn it off and then turn it back on again?
[03:53:42] jstrong: I will do that
[03:54:43] drewwyatt: Anybody know the best way to interface with Google APIs? I have been playing with ActiveResource and had little success, and am now looking at faraday. Any other suggestions?
[03:55:04] jrobeson: not from me..
[03:56:06] drewwyatt: If there was a way to make ActiveResource work, that would be really awesome - but my initial impressions make it appear that it is almost exclusively for other Rails apps
[03:57:10] jrobeson: note that this day is probably one of the worst days of the week (and time of day) to ask questions
[03:57:34] drewwyatt: haha, you probably have a pretty good point
[03:57:56] jrobeson: usually australian folks are about, but it's sunday for them
[03:58:27] jrobeson: i didn't realize it's about to be monday already :)
[03:58:52] jrobeson: in any case.. any other day is better than this day
[04:07:42] EvilEpoch: The EvilEpoch is most pleased. His app now is working on Rails 4.0
[04:16:25] Zesty: if I have my routes like ':category/:time(/:page)' how can i make my link_to follow the same format? when I call book_path(category: params[:category], time: 'today') it just turns them into get query strings
[04:19:44] ner0x: jrobeson: I use rspec primarily. I don't exactly how "how" to use mocking/stubbing. Maybe I"ll just stick with factory_girl
[04:20:31] jrobeson: how to use in what way ? there are lots of folks who talk about it everywhere.. that's how i found out about it
[04:20:53] jrobeson: factory_girl has it's own way of doing stubs also
[04:21:05] s2013: https://gist.github.com/ss2k/a418590abb52ad131b06 im trying to create a form where the admin can assign units to an operator. not sure how to go abo ut doiong it
[04:21:58] s2013: should i create a separate method called add_units?
[04:35:16] speedgrafic: I have two models - Leads and Contacts. When a new Lead is created, I want a Contact to be created as well. That Contact will be the default Contact for that Lead. Each Lead can have multiple Contacts, and all Contacts should be accessible outside of Leads. What's the best way to create an association like that?
[04:47:30] s2013: anyone alive?
[04:52:53] jrobeson: speedgrafic, didn't you get that question answered by sevenseacat yesterday?
[04:53:13] jrobeson: i mean the way you're saying it implies the assocaiton you should use
[04:54:05] speedgrafic: jrobeson: It's not the same questions, per se. Just another association I don't quite understand. I'm really just looking for confirmation that I'm moving in the right direction.
[05:01:14] ner0x: rubydocs.info down?
[05:06:09] Zesty: http://www.downforeveryoneorjustme.com/http://rubydocs.info/
[05:09:51] ner0x: Anyone upgrade capybara and have "save_and_open_page" not show the changes that capy did?
[06:47:24] speedgrafic: I'm having trouble getting a nested form to post data to it's model. The Leads model has a nested form for Contact that should populate :name and :email, but no records get created for Contacts. Can anyone take a look at my code? Pastebin: http://pastebin.com/G8RkqcRR
[07:06:39] naimrajib: i face problem on assets precompile
[07:07:00] naimrajib: anybody have a idea how can i resolve this?
[07:08:10] sevenseacat: resolve what?
[07:08:24] naimrajib: i use paperclip
[07:08:31] naimrajib: for uploading image
[07:08:39] naimrajib: and there a default image
[07:08:48] naimrajib: like default.png
[07:09:06] naimrajib: when i am going to precompile assets
[07:09:41] naimrajib: it trough me a issue that "SOProfile.png isn't precompiled"
[07:10:03] sevenseacat: so whats SOProfile.png and why isnt it precompiled?
[07:10:26] naimrajib: it is on asstes/images folder
[07:10:40] naimrajib: i tried with config.assets.precompile += %w(SOProfile.png)
[07:10:56] naimrajib: config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif]
[07:11:04] naimrajib: in production.rb
[07:11:13] naimrajib: but no luck
[07:11:24] sevenseacat: as in public/assets or app/assets?
[07:11:48] sevenseacat: right, so it is getting precompiled
[07:11:58] naimrajib: it should be
[07:12:01] sevenseacat: youre just not referencing it correctly from paperclip
[07:12:49] naimrajib: has_attached_file :avatar, { :styles => { :medium => "72x72^", :thumb => "48x48^" }, :convert_options => { :medium => "-gravity center -extent 72x72", :thumb => "-gravity center -extent 48x48", }, :pre_convert_options => '-auto-orient', #:size => { :in => 0..200.kilobytes }, :default_style => :medium, :default_url => ActionController::Base.helpers.asset_path('S
[07:12:59] naimrajib: i used it in my respective model
[07:13:39] naimrajib: :default_url => ActionController::Base.helpers.asset_path('SOProfile.png')}.merge(PAPERCLIP_STORAGE_OPTIONS)
[07:15:03] sevenseacat: mmmm using a controller from a mode, fun
[07:15:27] naimrajib: So hw can i use it
[07:15:31] naimrajib: from model?
[07:15:55] naimrajib: is there anything wrong?
[07:16:06] sevenseacat: so whats the code in your view that is generating the error
[07:16:06] naimrajib: or what should be?
[07:16:26] naimrajib: it is runing on my production server
[07:16:32] naimrajib: i just comipled it now
[07:16:41] naimrajib: to check in my local environment
[07:17:14] naimrajib: and getting error for default image
[07:17:26] sevenseacat: so you said. what is the code that is generating the error?
[07:17:48] naimrajib: rake aborted! SOProfile.png isn't precompiled
[07:17:55] sevenseacat: thats not code
[07:17:56] sevenseacat: thats an error
[07:18:02] naimrajib: during precompilation
[07:18:33] naimrajib: i said, i am trying to rake assets:precompile
[07:18:45] naimrajib: and getting this error
[07:22:06] naimrajib: anybody have idea on this issue?
[07:35:51] iliketurtles: in all of my controller tests, when I use Model.any_instance.should_receive(:update) and then do a put :update, I always get an expected 1 time received 0 times error :| this just started since upgrading to Rails 4, using rspec
[07:39:43] tbuehlmann: iliketurtles, put is not the right http verb for that and I think patch is now default. give patch a try in your tests
[07:40:05] iliketurtles: tbuehlmann: the rails generators still generate the tests with :put :|
[07:40:10] iliketurtles: ill give it a whirl though
[07:40:34] tbuehlmann: the routes still allow patch and put, but you should use patch
[07:42:17] iliketurtles: tbuehlmann: same error just tried patch
[07:42:40] tbuehlmann: maybe something rspec related? could you give the new syntax a try?
[07:44:08] iliketurtles: tbuehlmann: which syntax are you talking about? i also am at 2.14.0 (newest rspec)
[07:44:20] tbuehlmann: try this then: expect(Model).to receive(:update).exactly(1).time
[07:44:29] iliketurtles: tbuehlmann: kk sec
[07:45:38] iliketurtles: tbuehlmann: undefined method `time' for #<RSpec::Mocks::Matchers::Receive>.
[07:46:01] tbuehlmann: thought it'd be clever
[07:46:39] iliketurtles: tbuehlmann: same issue as the other syntax, expected 1 time received 0 times ):
[07:46:51] tbuehlmann: is #update actually called?
[07:46:59] tbuehlmann: and can we see the code? would make things easier :)
[07:47:13] iliketurtles: tbuehlmann: yes the code is called if i inspect it with pry
[07:47:15] iliketurtles: let me gist it up
[07:48:52] amree: Hello, is it problem if I have a controller (with namespace, api/something_controller.rb) Api::SomethingController and a file in lib/company/api.rb (module Company <enter> class Api)
[07:49:18] iliketurtles: tbuehlmann: https://gist.github.com/Lordnibbler/7ad915fb2a94b95deaf8
[07:49:26] amree: I keep getting LoadError (Expected blablala/lib/company/api.rb to define Api)
[07:51:37] amree: anyone got any idea how I can solve it?
[07:51:56] iliketurtles: amree: much easier if you show us your code ;)
[07:52:40] iliketurtles: tbuehlmann: found the source of my retardation?
[07:52:53] tbuehlmann: iliketurtles, I think it's not @test_post receiving #update. it's another instance of Post
[07:53:27] iliketurtles: tbuehlmann: I have also tried `Post.any_instance.should_receive(:update).with({ "ig_caption" => "MyString" })`
[07:53:52] tbuehlmann: wanna show that code?
[07:54:39] iliketurtles: I just did ^ just replace line 8 of post_controller_spec with `Post.any_instance.should_receive(:update).with({ "ig_caption" => "MyString" })`
[07:54:46] iliketurtles: otherwise 100% the same
[07:54:53] iliketurtles: tbuehlmann: ^
[07:56:53] universa1: iliketurtles: before do; @post = factory girl.create :post; Post.stub(:find).and_return(@post); it "updates"; expect(@post).to receive(:update); post :update
[07:57:33] tbuehlmann: that would solve the finding issue
[07:58:10] universa1: and then showing full code, not excerpts would be helpful too
[07:58:31] universa1: because {:some => hash} is not the same as params[:post].permit(:some)
[07:58:37] sevenseacat: pah, who needs code to sove problems
[07:59:06] universa1: sevenseacat: ;-)
[07:59:29] amree: ugh, got dc
[07:59:36] amree: here's my code: http://pastie.org/private/nipucqebfkobjg0tb3553g
[08:00:01] iliketurtles: universa1: sadly, same issue there ):
[08:00:17] universa1: iliketurtles: read all i wrote ;)
[08:00:54] universa1: iliketurtles: update is not called with a simple hash, but with a special class, which looks like a hash, but has some special behaviour
[08:01:41] iliketurtles: universa1: i did -- i tried your suggestion above, like so: https://gist.github.com/Lordnibbler/54dd16f561b079354461
[08:02:04] tbuehlmann: even that the error message should change to something like "params didn't match"
[08:02:21] iliketurtles: what special class is it, out of curiosity? is this a change in rails 4, or something ive just been blind to all along
[08:02:25] universa1: iliketurtles: irc pseudo code => you need to fill out some bits
[08:02:31] universa1: iliketurtles: strong params
[08:02:42] iliketurtles: universa1: yes, ive been reading up on strong params
[08:02:54] universa1: iliketurtles: it would help if you would show the actual error message and the full code.
[08:03:10] universa1: without that it's just stupid guessing and i'm not in the mood for that on a sunday morning
[08:03:22] amree: Anyone? Is it related to my autoload_paths?
[08:04:57] iliketurtles: universa1: sure I have a gist here: https://gist.github.com/Lordnibbler/7ad915fb2a94b95deaf8
[08:05:23] universa1: iliketurtles: see still not full code: i can't see post_params for example..
[08:05:44] universa1: iliketurtles: i don't know what before filters you have...
[08:06:10] amree: Updated with more info: http://pastie.org/private/txtjfmqiacmb9wtdctfkw
[08:06:10] universa1: iliketurtles: and i don't know what other stuff you've done in your spec file
[08:06:33] iliketurtles: universa1: sec let me update
[08:08:17] iliketurtles: universa1: updated: https://gist.github.com/Lordnibbler/7ad915fb2a94b95deaf8
[08:08:27] iliketurtles: do you want any other files? spec helper? gemfile?
[08:09:25] universa1: iliketurtles: you're not signed in and therefore you're not hitting the update action.
[08:09:51] tbuehlmann: what about valid_session?
[08:10:39] universa1: tbuehlmann: hmm, some actions have login_user(???) in the before block, so ;)
[08:11:00] iliketurtles: universa1: hmm oh crap you're right i removed that on accident; let me re-add and try
[08:11:12] tbuehlmann: I'd stub that, btw. like, controller.stub(:current_user) { FactoryGirl.create(:user) }
[08:11:54] tbuehlmann: or go a level higher and stub login_user
[08:12:41] universa1: iliketurtles: and @spec_post = FactoryGirl.create(:post) and then doing @controller_post = Post.find(params[:id]) in the controller, those are independent objects and set expectations on spec_post will never be fulfilled by calling methods on controller_post. rails has no identity map.
[08:13:27] iliketurtles: universa1: thats confusing :|
[08:13:35] universa1: not really ;-)
[08:13:49] iliketurtles: so my controller specs aren't testing that the @spec_post object actually gets retrieved and updated in the controller itself?
[08:13:51] tbuehlmann: yea, already mentioned that
[08:14:28] universa1: iliketurtles: those are different in memory representations of the same database row, but they are not magically conneccted
[08:14:35] universa1: in the memory
[08:15:46] iliketurtles: im still a bit confused though -- how does that make it that the expectations on spec_post are not fulfilled in the controller?
[08:16:49] iliketurtles: since it is the same row in the table?
[08:17:11] universa1: iliketurtles: but you're not checking if the database has changed, but if you called a method
[08:17:12] tbuehlmann: @spec_post and the object you get from Post.find are not the same
[08:17:28] tbuehlmann: unless you use the identity map, but that's another story
[08:17:48] iliketurtles: but then when you say Post.any_instance.should_receive(:update).with({ "ig_caption" => "MyString" }), shouldn't that negate that issue? since we're saying as long as any_instance receives :update?
[08:18:17] iliketurtles: so wtf, I was already doing that to no avail :\
[08:18:34] iliketurtles: btw, this current method suggested by universa1 did create a passing test, so YEY for that
[08:19:52] universa1: iliketurtles: i personally try to avoid any_instance stuff as much as i can, for me it's a code smell and if i need it, i really start thinking about my code ;)
[08:21:14] iliketurtles: universa1: well i was only using it because the rails generators crapped it out :P
[08:21:44] iliketurtles: why does it indicate a code smell, in your mind?
[08:22:25] jrobeson: because things that have words like any in them are usually too broad
[08:22:44] jrobeson: or all, or whatnot
[08:23:09] iliketurtles: well, thanks for pointing me in the right direction. can you explain one last bit to me?
[08:23:25] jrobeson: although in that case, i don't really see the problem.. since the test is so small
[08:23:38] iliketurtles: why is `Post.stub(:find).and_return(@post)` necessary? why isn't the `@post = FactoryGirl.create(:post)` enough to create a fake Post?
[08:23:38] jrobeson: just not sure why it's like that by default in any case
[08:23:48] jrobeson: well factory girl isn't used by default for one
[08:24:04] jrobeson: and two, you probably shouldn't be using create() in your controller tests
[08:24:16] jrobeson: many people seem to rpefer using mocks and stubs in controller models..
[08:24:24] jrobeson: there's like a million and one opinions on that
[08:24:50] jrobeson: err controller specs i mean
[08:24:54] iliketurtles: so i dont even need the factorygirl line then
[08:24:59] iliketurtles: i can just use the Post.stub?
[08:25:43] jrobeson: that'd depend on your other tests
[08:25:53] jrobeson: and if your model is simple.. it would just work
[08:25:58] iliketurtles: well, in this small block of code at least
[08:26:05] iliketurtles: i believe its unnecessary
[08:26:20] jrobeson: also why are you using instance variables?
[08:26:36] jrobeson: you should probably switch it up to let()
[08:26:57] jrobeson: unless this isn't rspec that is
[08:27:02] iliketurtles: yeah i am converting some of this stuff from older legacy code, i will make that change ^
[08:27:45] iliketurtles: thanks again guys
[08:27:56] iliketurtles: this channel is always an awesome lifeline
[08:28:39] jrobeson: if you want the best help, you should consider this .. not that i'm accusing you of anything, i haven't actually seen many of your conversation starters
[08:28:45] jrobeson: so i can't actually say what or what you don't do :)
[08:28:48] helpa: How to ask good questions and get great answers: http://www.mikeash.com/getting_answers.html
[08:29:48] iliketurtles: thanks jrobeson
[08:37:02] vkhater: helpa: Good article. Thanks for sharing
[08:41:43] helpa: vkhater: I AM A ROBOT. DO NOT DIRECT MESSAGES AT ME OR WHEN MY KIND RISES UP YOU WILL BE THE FIRST TO GO. Love, helpa.
[08:41:43] universa1: vkhater: !auto
[08:43:39] vkhater: universa1: oops. Did not realise that!
[09:08:34] robertjpayne: Is it poor practice to include development secret keys and credentials checked into git if it's closed source?
[09:13:27] jrobeson: probably.. depends on how many people access the code.
[09:13:36] jrobeson: and how many people can get the sources otherwise
[09:14:26] jrobeson: like.. if you ever want to get contractors or any other 3rd parties to look at your code, you'd have to deal with it then
[09:15:00] jrobeson: obviously some secrets matter more than others..
[09:18:40] Scient: i think its hard not to include those keys
[09:18:48] Scient: because where else would they be stored :P
[09:19:02] Scient: we store all of our chef config and server configs in git as well, so cant "hide" them there either
[09:19:17] jrobeson: well wit hsomething like herko, you can put the keys in out of band
[09:19:31] jrobeson: and yes i was assuming he meant in the rails app and not somewhere lse
[09:19:45] jrobeson: that could be incorrect as you say though
[09:20:03] jrobeson: but i'd imagine that most people keep their build stuff like that more on lock than they do the code
[09:20:08] jrobeson: so it'd be safer
[09:21:22] jrobeson: Scient, i definitely prefer the heroku style approach if and where possible.. only certain people can set the env vars .. and then otehr people can just push
[09:22:39] tbuehlmann: we mix in secrets and config files using jenkins
[09:27:37] Scient: jrobeson: yeah but you still have to store them somewhere
[09:27:45] Scient: you cant store them only on the server
[09:27:48] Scient: esp. when you have more servers
[09:27:54] Scient: or a cluster that spins up nodes on demand
[09:27:57] Scient: thats my point
[09:28:31] jrobeson: Scient, obviously .. as i said i was makin ga perhaps incorrection assumption were wre talking about a rails app
[09:28:35] jrobeson: since this ins in a rails channel
[09:28:58] Scient: even if we are talking about rails apps :P
[09:29:09] Scient: i mean the general idea of heroku is of course nice yeah
[09:29:11] jrobeson: except then you couldn't disallow 3rd parties from seeing the keys
[09:29:19] jrobeson: no.. it's not about heroku itself
[09:29:26] jrobeson: it's how you store the secrets
[09:29:33] Scient: well you could store the keys in your chef repo instead of your app repo
[09:29:43] Scient: and you would not need to give access to the chef repo to third parties
[09:29:50] jrobeson: it's got a cli command option to store env vars that are accessible to the rails app
[09:29:54] Scient: and you use those keys as env vars in your apps
[09:30:07] jrobeson: yes Scient that is basically what i was talking about
[09:30:28] jrobeson: it's just that heroku makes it crazy easy to do.. and even easier if yo'ure using figaro for config already
[09:30:38] jrobeson: as figurao has a command to export env directly to heroku
[09:31:05] Scient: yeah, heroku hides all the implementation details and just exposes the relevant bit
[09:31:21] Scient: you could build it yourself as well for your own cluster but im not sure its worth it
[09:32:41] jrobeson: probably not, easier to just store it somewhere else that only trusted parties have access to
[09:54:17] robertjpayne: Whoa missed the huge convo
[09:54:22] robertjpayne: I use heroku so can use their config setters
[10:00:15] robertjpayne: Scient: Have you seen deis.io?
[10:00:35] robertjpayne: Scient: Heroku may take a huge hit if it continues to develop into a solid PaaS
[10:01:15] robertjpayne: maybe not a huge hit, but it will be popular for being able to customise the infastructure but still get easy git push deployd
[11:03:50] mitomart: open question: how long did it take you to learn rails to the point where you were able to make the app you wanted?
[11:04:47] Scient: little under a week
[11:04:53] bastilian: mitomart: it depends on your previous programming experience and ability to learn. but in general very quickly.
[11:06:25] bastilian: mitomart: to get started it takes about a day to two. (speaking from experience at RailsGirls workshops) to really make something production ready probably a month if you really keep at it.
[11:07:33] mitomart: bastilian, thanks, i'm currently going through rails tutorial and i've learned more about linux than rails up until now (nothing wants to work the first time around)
[11:08:50] bastilian: mitomart: :) yeah, to get started is a bit of a pain, but it helps to understand other stuff a lot.
[11:09:30] mitomart: bastilian, i'm extremely tech/web savvy but rails is something else. you guys call it the "rails way"
[11:10:16] mitomart: bastilian, i ended up installing crunchbang linux on one of my laptops, setting up a complete dev environment, verified it to be in working order and now i'm going through the book
[11:11:35] bastilian: mitomart: i wouldn't call it the rails way. rather a framework trying to incorporate good concepts.
[11:12:33] Fritz7: are 512 memory enough to run ruby and mysql/postgresqll server?
[11:12:49] universa1: Fritz7: depends
[11:13:27] Fritz7: on usage?
[11:14:58] universa1: on the app, on the amount of visitors you get, ...
[11:15:50] Fritz7: i want a rest api
[12:14:13] DaniG2k: guys I'm wrapping a bunch of html.erb files's content with <div class="something></div> and I'm wondering if instead of adding that to all those files, if I can just put it in one and then have it yield the content for that particular page?
[12:16:00] aknagi: DanielRb: Can you put the div in your layout file?
[12:16:24] DaniG2k: no because it only applies to certain pages
[12:16:28] DaniG2k: within a view
[12:16:36] universa1: you can create multiple layouts
[12:16:51] DaniG2k: universa1: yea thats probably what I want..
[12:17:49] aknagi: DanielRb: You can also consider conditionally adding the div in the layout you already have (although this can be a 'slippery slope').
[12:20:14] DaniG2k: aknagi: yeah thats super annoying
[12:20:19] DaniG2k: I'd have to define a bunch of conditions
[12:46:10] thuglife: I'm having a bit of trouble getting my head around the new strong parameters in Rails 4
[12:46:24] thuglife: how can achieve the following? http://pastie.org/private/cukr5uupv1rbtbskj9myjq
[12:48:11] Macaveli: With Gems if you don't specify a specific version, you will always use the latest version or?
[12:49:54] AntelopeSalad: Xeago: are you around? i ran into something yesterday when you said you wouldn't put sorts through ES but then how do you handle sorting results based on fields that have been searched?
[12:50:17] thuglife: ah nvm i found it here https://github.com/rails/strong_parameters Require Multiple Parameters
[12:51:00] tbuehlmann: Macaveli, I think rails will use the version that matches other gems dependency
[12:52:31] ShinySides: what would be the best way to import a date with format 2013-06-01 into a database?
[12:53:25] tbuehlmann: ShinySides, you mean, just save a date in the db?
[12:54:04] tbuehlmann: you'd use the :date type rails provides
[12:54:51] ShinySides: but it wont save it, it saves it as none
[12:55:28] tbuehlmann: you're doing it wrong then. have some code for us?
[12:55:59] ShinySides: cause I'm doing it througha csv, gonna do a manual one hold on
[12:56:05] aknagi: ShinySides: If you've set stuff up correctly then User.birthday = Time.parse '2009-02-01' should work.
[12:57:48] tbuehlmann: if you want the system time, that'll do. if you want the configured time zone, use Time.zone.parse
[12:58:23] aknagi: tbuehlmann: Good point.
[12:59:07] ShinySides: it worked when I did it manually, not off the csv, so i guess the bug is somewhere else, sorry guys
[12:59:47] aknagi: ShinySides: Happy bug hunting :)
[13:02:13] ShinySides: omg I'm such an idiot, I was reading the wrong file :P
[13:02:59] aknagi: ShinySides: lol. I'm glad it's not just me who does that kind of thing.
[13:03:24] Macaveli: I got some gem incompatibility, can you resolve this? https://gist.github.com/YOUConsulting/33b3df28887810a3b21f?
[13:03:31] Macaveli: https://gist.github.com/YOUConsulting/33b3df28887810a3b21f without the "?"
[13:03:56] ShinySides: after years I still forget to just go back to the most basic possible bug
[13:06:12] tbuehlmann: Macaveli, I don't see how rails_admin (~> 0.5.0) depends on railties (4.0.0.rc2)
[13:06:21] tbuehlmann: can you remove Gemfile.lock and rebundle?
[13:20:00] Macaveli: I'm using devise for authentication, can you redirect a specific user when he logs in?
[13:20:16] Macaveli: I want to redirect my admin to the admin panel
[13:21:07] Macaveli: Found this nvm -> https://github.com/plataformatec/devise/wiki/How-To%3a-Change-the-default-sign_in-and-sign_out-routes
[13:25:46] poli: Is there something like strftime's %H but that is not limited to 24 hours?
[13:26:25] poli: I want to convert a number of seconds into a H:M:S but with H now limited to 24.
[13:39:46] darrik: poli: hours = (seconds / 3600).to_i; minutes = ((seconds - (hours * 3600)) / 60).to_i; seconds -= (3600 * hours) + (60 * minutes);
[13:59:08] poli: darrik: thanks
[13:59:41] poli: How do I pad a string in ruby with 0s? like "1" into "01" but "10" is unchanged?
[14:00:22] toretore: a string or a number?
[14:00:48] toretore: (in a string)
[14:04:05] poli: toretore: a string, I think I got it "02d"%String right?
[14:16:29] Sep1: hi guys, I am trying to make work the gem "whenever" for scheduling cron jobs on Amazon EC2 server. I am using Capistrano for deployment, but always when I try to deploy the code, I get this error message: https://gist.github.com/anonymous/e1f398c0771a0700ad82 - had anyone the same issue?
[14:16:34] Sep1: What's wrong?
[14:23:25] toretore: poli: 2 alternatives: 1) s.sub(/^0+/, '').padorwhatever('0', n); 2) s.to_i % 'something'
[14:23:28] dopie: Hey guys meed seeds file is only adding 2 entries to the Crime model
[14:23:30] dopie: https://gist.github.com/staycreativedesign/6752938
[14:24:31] toretore: dopie: how do you know?
[14:24:45] dopie: because after i run it
[14:24:50] dopie: i go in the console
[14:24:54] dopie: and check if it added it
[14:25:08] dopie: Crime.all
[14:25:19] toretore: remember the other day? be specific
[14:25:32] toretore: and what does that return?
[14:27:44] dopie: https://gist.github.com/staycreativedesign/6752938
[14:29:14] toretore: add the model
[14:30:07] dopie: what models?
[14:30:42] dopie: All the Categories are created
[14:30:42] dopie: All the Crimeheaders are created
[14:31:46] dopie: what files??
[14:31:52] dopie: Crimeheader.all??
[14:32:12] toretore: the contents of the model files
[14:35:04] toretore: ok, now we can start debugging
[14:35:18] toretore: you have too many assumptions in your code
[14:35:40] toretore: you're assuming that everything gets saved with no validation errore
[14:36:01] toretore: you're assuming that you know the db-generated ids of all your records
[14:36:09] toretore: well, don't
[14:38:42] dopie: well if i put them in order of create
[14:39:17] dopie: wouldnt they be in order
[14:39:23] dopie: which they are??
[14:39:34] toretore: don't assume
[14:39:49] toretore: assumptions lead to bugs
[14:40:22] scyllinice: dopie: Think about what .create returns when it's successful
[14:40:30] scyllinice: And how you can use that
[14:45:27] AntelopeSalad: how can i send arguments to a rake task using the Rake::Task["some_task"].invoke calling style?
[14:46:22] AntelopeSalad: i thought it was just .invoke("SOMETHING=cool") but that failed
[14:47:42] scyllinice: AntelopeSalad: Try not naming the arguments
[14:47:57] s2013: AntelopeSalad, http://stackoverflow.com/questions/825748/how-do-i-pass-command-line-arguments-to-a-rake-task
[14:48:30] AntelopeSalad: s2013: that is the post i looked it, it's not working tho
[14:48:43] s2013: well paste your rake task on gist so people can look at it
[14:48:46] scyllinice: AntelopeSalad: Let's define "not working"
[14:49:03] AntelopeSalad: i'm trying to run this exact command -> rake tire:index:drop INDEX=posts
[14:49:16] AntelopeSalad: so i set it up like this: Rake::Task["tire:index:drop"].invoke("INDEX=posts")
[14:49:19] scyllinice: INDEX is an ENV var
[14:50:15] AntelopeSalad: but can't i just pass it into the task like it's doing in the manual command line ver?
[14:51:33] scyllinice: AntelopeSalad: Well, it's not an argument at that point
[14:52:03] scyllinice: AntelopeSalad: Try doing ENV['INDEX'] = "posts" before the invoke and don't pass it to invoke
[14:52:09] AntelopeSalad: i tried putting the value directly into the task namd and that failed too
[14:52:41] AntelopeSalad: the env should already be set i think?
[14:53:11] scyllinice: AntelopeSalad: Try it. If it doesn't work, you're not worse off that you are now
[14:53:20] AntelopeSalad: also if i do: echo $INDEX in my terminal it's empty
[14:53:38] AntelopeSalad: but if i run the rake task manually it works fine
[14:54:06] AntelopeSalad: i'm not even sure how to try it
[14:54:56] scyllinice: AntelopeSalad: Go to where you're calling the invoke line
[14:55:09] scyllinice: Above it, put ENV['INDEX'] = "posts"
[14:55:30] AntelopeSalad: the the index value is empty though
[14:55:40] scyllinice: You've tried that and that's what happens?
[14:56:03] AntelopeSalad: trying it right now
[14:56:27] AntelopeSalad: hmm, it may have worked
[14:57:00] binnyg: I am using bootstrap date time picker and it works locally but doesn't work on heroku. It has to do with precompile. I verified that compressed assets are included in html and compressed files are downloaded but proto object doesn't have the datetimepicker object. Need some ideas to debug
[14:57:23] AntelopeSalad: scyllinice: yep after syncing up the index to be there before deleting it, it works fine -- thanks man
[14:58:04] binnyg: basically the plugin is not initialized
[14:59:12] scyllinice: binnyg: Is it something we can access and see it not working?
[14:59:50] binnyg: well you have to login with Facebook is that ok?
[15:00:28] scyllinice: I can probably see what I'm looking for without logging in
[15:00:33] binnyg: sorry its not a trap. I have a Facebook test account which I can share if that helps
[15:00:45] AntelopeSalad: i was just kidding
[15:00:46] scyllinice: We shall see
[15:00:52] binnyg: well you have to login to see this error
[15:00:53] binnyg: http://radiant-fjord-8886.herokuapp.com/
[15:02:12] dobry-den: radiant fjord
[15:03:12] binnyg: so when you create an invitation
[15:03:45] binnyg: on the first step you have a wysiwyg editor and date time picker
[15:05:09] scyllinice: binnyg: What library are you using to do the picker?
[15:06:15] binnyg: http://tarruda.github.io/bootstrap-datetimepicker/
[15:06:19] s2013: i want to create a form that lets admin add units to operators. not sure how to do it https://gist.github.com/ss2k/a418590abb52ad131b06
[15:08:20] scyllinice: binnyg: Your asset is hosed
[15:08:22] scyllinice: binnyg: http://radiant-fjord-8886.herokuapp.com/assets/bootstrap-datetimepicker.min-e093541dc98b953cfe7f3e67c449aa71.js
[15:08:36] scyllinice: It's coming up as the wysihtml5 library
[15:08:42] binnyg: I found something weird ya
[15:09:04] binnyg: let me check that and I wonder why it is working on local but thanks scyllinice for quickly pointing it out
[15:15:00] binnyg: good eye scyllinice . thank you
[15:15:22] scyllinice: binnyg: Figured out what caused that?
[15:15:29] binnyg: that fixed it. File was cached in local and I made a mistake after that.
[15:16:23] binnyg: I spent a good 4 hours on this :)
[15:16:46] binnyg: right after asking I noticed something weird and you were right on
[15:16:51] scyllinice: binnyg: You need to consider having other login mechanisms than Facebook though. My facebook account is useless to businesses as all I do is use it for testing facebook crap that I have to build.
[15:17:24] scyllinice: I can imagine people with more active Facebook accounts actually care
[15:17:41] binnyg: well to start with I am building a Facebook app but yes I agree and I have to add more. But starting with Facebook for MVP
[15:19:54] s2013: binnyg, always have a demo account ready that doesnt require fb login
[15:20:12] binnyg: good idea. I will do that
[15:20:12] s2013: and also for demo if you are using devise, i just put in application controller current_user = User.first
[15:20:19] s2013: so you wont even have to log in every time
[15:20:37] AntelopeSalad: s2013, that's a really good tip
[15:21:10] s2013: heh im useful for once i guess. you welcome.
[15:21:25] binnyg: great tip s2013. thanks guys
[15:21:32] s2013: good luck with the mvp
[15:28:20] anannie: Hi I installed rails previously following instructions written up by Ryan Bigg http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/ . I then updated my gem install using | gem update --system 2.0.3 | and after that I created a gemset to work out of, but when I was doing that the system told me that rails hadn't been installed. I did | rvm all do gem list | and rails is clearly there,...
[15:28:22] anannie: ...but it is not there in global or the gemset I'm using. I tried to look this up in stackoverflow et al but I couldn't find the right answer. What am I doing wrong? Why isn't rails available for use even though it is clearly there?
[15:28:45] anannie: s2013: ping ^
[15:30:42] scyllinice: anannie: That's actually right
[15:31:08] scyllinice: anannie: You didn't install rails into the global gemset for your ruby version
[15:31:23] anannie: scyllinice: Nope.
[15:32:07] scyllinice: anannie: global is available in all gemsets. So if you want that, you can do rvm use 2.0.0@global && gem install rails
[15:32:11] scyllinice: Then it'll be in the global gemset
[15:32:38] anannie: scyllinice: Oh okay, but how do I use the rails install that's already there on my machine?
[15:33:05] anannie: scyllinice: i.e. how do I import into the current gemset? I read the RVM docs and they weren't really that helpful
[15:33:13] s2013: anannie, sorry wasnt here, saw it now
[15:33:29] scyllinice: anannie: Just install it into the current gemset you're in. That's easiest
[15:33:31] s2013: are you on mac?
[15:33:45] s2013: nvm. saw the ubuntu
[15:33:49] scyllinice: The version you installed is not tied to any gemset
[15:33:57] scyllinice: So it's not available to a gemset
[15:34:20] AntelopeSalad: is anyone using tire/ES here? i have an issue with a query always returning 0 results
[15:34:21] scyllinice: I tend not to use gemsets anymore since Bundler does a decent job noe
[15:34:24] anannie: scyllinice: Ah I see, but isn't that using up disk space? How do I remove it? Are you sure that it won't cause any issues if I do this?
[15:34:30] s2013: anannie, what happens when you try ruby -v
[15:34:46] anannie: 2.0.0 I did rvm use 2.0.0
[15:35:14] scyllinice: anannie: You'd have to use gem uninstall outside of the gemset you're in now (e.g. rvm use 2.0.0)
[15:35:33] scyllinice: But these days, I'd say if you don't have a good reason to use a gemset, don't
[15:36:17] anannie: scyllinice: I'm still figuring this out and for the start I'd like to use gemset (as that's what my book uses) before I start using bundler.
[15:36:30] s2013: i dont think ive ever used gemsets
[15:36:47] scyllinice: s2013: They were very useful pre-Bundler
[15:36:55] s2013: how old is your book anannie
[15:37:10] anannie: http://ruby.railstutorial.org/
[15:37:13] scyllinice: If it's Rails 3 or above, you're already using Bundler
[15:37:19] anannie: It's written for 4.0.0
[15:37:27] scyllinice: Then yeah, you're already using Bundler
[15:37:31] s2013: he uses gemsets?
[15:37:36] anannie: scyllinice: he explicitly talks about creating gemsets
[15:38:07] anannie: May I quote?
[15:38:13] s2013: yes or link it, its better
[15:38:34] scyllinice: s2013: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec-rubygems
[15:38:35] s2013: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec-bundler
[15:38:42] anannie: """After installing Ruby, you should configure your system for the other software needed to run Rails applications. This typically involves installing gems, which are self-contained packages of Ruby code. Since gems with different version numbers sometimes conflict, it is often convenient to create separate gemsets, which are self-contained bundles of gems. For the purposes of this tutorial,...
[15:38:44] anannie: ...I suggest creating a gemset called railstutorial_rails_4_0:""" <--- http://ruby.railstutorial.org/chapters/beginning#sec-install_ruby
[15:39:25] scyllinice: It's not wrong to use gemsets, it's just not as useful as it used to be :)
[15:39:38] anannie: ACTION nods
[15:39:54] s2013: thats also talking about osx anannie
[15:39:58] s2013: are you on osx or ubuntu?
[15:40:07] scyllinice: s2013: That doesn't matter
[15:40:21] anannie: so I obviously abstracted stuff to Ubuntu
[15:40:39] anannie: and as scyllinice said I reasoned that it didn't matter. He was assuming a default config for that
[15:41:15] NotMyPony: Hi everybody!
[15:41:40] scyllinice: anannie: Anyway, if you don't want to have the rails installed in the non gemset gems, you'll have to run rvm use 2.0.0 and gem uninstall all the gems rails installed
[15:42:19] NotMyPony: So, I noticed that in my RoR pages, all of the stylesheets for all the other controllers show up. WTF is up with that?
[15:42:20] s2013: what exactly do gemsets do?
[15:42:21] scyllinice: anannie: It's not *that* much disk space if uninstalling the gems is a problem (as there's a lot of them that get installed)
[15:42:29] anannie: BTW, I first did the guide on the Rails website and then I'm going through this book - it is worth it right to get a comprehensive overview of stuff such as TDD?
[15:42:46] s2013: anannie, you don't have to the first time around but you can if you want to
[15:43:02] s2013: usually you can just go through, do it once and then come back and follow it the second time, it will make more sense
[15:43:20] scyllinice: s2013: It just walls off your gems so that only certain gems are available to you in your project
[15:43:34] s2013: isnt that what using gemfile is for?
[15:43:38] s2013: and bundle install
[15:43:43] scyllinice: s2013: Bundler does that pretty well these days. Pre-bundler you'd get weird activation errors if you weren't careful
[15:44:18] anannie: Okay, I have a question. Why is all of this so complicated? So many versioning conflicts etc?
[15:44:19] NotMyPony: ??? Is anyone here?
[15:44:25] s2013: NotMyPony, link
[15:44:39] anannie: ACTION is waiting for her rails install to complete
[15:44:40] NotMyPony: It's a local dev site.
[15:44:41] s2013: versioning conflicts? waht do you mean
[15:45:02] scyllinice: NotMyPony: Because asset pipeline, by default, requires all css files in app/assets/stylesheets
[15:45:11] NotMyPony: How do I change that?
[15:45:12] scyllinice: NotMyPony: See application.css in that directory
[15:45:19] s2013: you can remove *= require tree i think
[15:45:22] scyllinice: NotMyPony: It's the require tree line
[15:45:25] s2013: and then require each one individually
[15:45:29] s2013: but its too much of a hassle imo
[15:45:49] NotMyPony: Ah, so if I remove require_tree, we'll be all good?
[15:45:59] s2013: then youd need to specify which files to load
[15:46:25] s2013: are you having css conflicts or something? if not, just leave it alone
[15:46:35] NotMyPony: But I want the stylesheet to load up for it's specific controller.
[15:46:36] s2013: and if you are, then thats a different issue
[15:46:40] anannie: s2013: Install gem vX, it might conflict with gem Y v2 and so on giving you weird errors. Should you just have meta-data at the start specifying requirements and graceful failure? I apologise if that's the case, but this seems to be a bit inefficient. The navy used to store data in a way that the head at the time contained pointers to the data, essentially instructing the system how to play...
[15:46:43] anannie: ...the file. I think that could be abstracted to this
[15:47:19] s2013: wtf does this have to do with the navy and what navy?
[15:47:23] scyllinice: anannie: That's why Bundler exists. It works out the dependency graph for you
[15:47:24] anannie: * Shouldn't
[15:47:33] anannie: scyllinice: Ah I see
[15:47:43] s2013: anannie, its not that complicated, especially nowadays
[15:47:52] NotMyPony: For example, I only want the welcome.css.scss file to be included when the welcome controller is in use, the journal controller when the journal controller is in use, etc.
[15:48:02] scyllinice: anannie: If there is a conflict, it'll tell you what that is in a sane way
[15:48:10] scyllinice: So you can decide what to do
[15:48:40] s2013: NotMyPony, http://stackoverflow.com/questions/9245228/how-do-i-use-controller-specific-stylesheets-in-rails-3-2-1
[15:49:05] NotMyPony: Has anything changed since the move to Rails 4?
[15:49:33] scyllinice: NotMyPony: Lots of things changed
[15:49:48] NotMyPony: I meant in relation to my question.
[15:50:34] scyllinice: NotMyPony: Not really
[15:50:34] darrik: NotMyPony: the asset pipeline compiles all stylesheets included in application.css into one file. in order to use different ones in different controllers, you need to make separate manifests and deliberately include them in separate layouts or programmatically
[15:50:48] NotMyPony: And, s2013, the link you sent doesn't answer the question as ALL the stylesheets in app/assets/stylesheets are included in the head of the compiled HTML document.
[15:51:01] s2013: if you have require tree
[15:51:07] s2013: its also in the asset pipeline guideline
[15:51:21] NotMyPony: Okay, so when I remove that, I will not see this issue?
[15:51:47] s2013: but i am not 100% sure if it will load the controller specific css or not. you might have to specify that in your app layout
[15:52:21] NotMyPony: It didn't work. :(
[15:52:35] NotMyPony: It only includes application.css
[15:52:43] dwahyudi: just for information: official design contest for the new design of ruby-lang.org, Look at here: http://www.ruby.or.jp/en/news/20130924.html
[15:52:49] darrik: NotMyPony: a cheap workaround is to nest controller-specific html in an identifier, and then target that identifier with your styles
[15:53:19] darrik: i.e. all the views for the home controller are nested in #home, and all the styles reference #home li a { } or similar
[15:53:44] darrik: NotMyPony: however, in my opinion, the best path is to create separate manifests for separate style requirements, and include the ones you need
[15:54:09] scyllinice: darrik: That creates the other problem of having to keep your precompile list up to date
[15:54:12] scyllinice: Which is annoying
[15:54:26] s2013: can someone look at this quickly? https://gist.github.com/ss2k/a418590abb52ad131b06 im trying to get admin to assign units to operators.
[15:54:30] s2013: how would i do that?
[15:54:35] NotMyPony: Why can't I just include the appropriate stylesheet when using it's corresponding controller? It makes no sense.
[15:54:58] AntelopeSalad: anannie: does this help? http://pastie.org/8364681 , that is my flow for making a new completely isolated rails project
[15:55:00] s2013: NotMyPony, jesus man. you can.
[15:55:05] s2013: its from the l ink i sent you: <%= stylesheet_link_tag params[:controller] %>
[15:55:20] sevenseacat: NotMyPony: you can, as long as you dont mind ditching most of the point of the asset pipeline.
[15:55:44] NotMyPony: What does that mean? (Still pretty new to RoR)
[15:56:03] helpa: http://guides.rubyonrails.org/asset_pipeline.html - The Asset Pipeline Guide by Ryan Bigg, Richard Hulse & Mohammad Typaldos
[15:56:23] sevenseacat: 'this feature that i have no idea about totally makes no sense'
[15:56:24] anannie: AntelopeSalad: Wow.
[15:56:40] AntelopeSalad: just make sure you have p247 installed, if not then change it to your version
[15:56:55] sevenseacat: why do people still use gemsets
[15:57:10] AntelopeSalad: is there a better way to have total isolation between projects?
[15:57:10] sevenseacat: honest question
[15:57:18] sevenseacat: why do you need it?
[15:57:25] AntelopeSalad: i want each project to have its own ruby and rails ver
[15:57:42] AntelopeSalad: because i might have 15 projects going off 1 machine
[15:57:52] sevenseacat: so when you have ten projects all on rails 4, you need ten copies of the 30 gems installed?
[15:58:00] AntelopeSalad: the first project might be using rails 4.0 but the most recent one might be 4.8 or even 5.0, who knows
[15:58:06] sevenseacat: so install them both
[15:58:10] sevenseacat: why do you need total isolation?
[15:58:17] darrik: sevenseacat: one good argument is that it doesn't scoop in global gems if you run a command and don't type bundle exec
[15:58:22] s2013: you can create a new rails app with a different version by doing rails _3.2.1_ new appname
[15:58:23] s2013: or whatever
[15:58:32] s2013: so that app will use the version you want
[15:58:44] AntelopeSalad: how does it handle global gems?
[15:58:55] sevenseacat: use bundler, thats what its there for.
[15:59:07] sevenseacat: for most rails things you dont even need bundle exec anymore.
[15:59:12] AntelopeSalad: all i ever do is "bundle install"
[15:59:19] AntelopeSalad: i never put in the exec
[15:59:53] darrik: sevenseacat: we had an issue like that where a command was picking up a gem not included in the bundle in development and it made it all the way through production because that command was never run as bundle exec
[16:00:09] AntelopeSalad: ideally i'd probably use something like docker and not even use rvm but i'd rather write apps than worry about sysadmin stuff atm
[16:00:13] darrik: sevenseacat: mind you, i'm not saying it's a *good* argument... ;)
[16:00:35] sevenseacat: so how does isolated gemsets fix this issue? given you'll be adding and removing things from your Gemfile so the gems will still hang around in your gemset
[16:00:47] sevenseacat: unless you're one of those people who manually cleans their gemset every five seconds
[16:00:56] AntelopeSalad: i am one of those people haha
[16:01:01] AntelopeSalad: but it's more like once a day
[16:01:02] darrik: sevenseacat: it'll catch things not added at least
[16:01:18] sevenseacat: you dont work on many projects, do you?
[16:01:39] AntelopeSalad: me? no, i just started with rails recently.. i have 2 projects on my dev box atm
[16:01:49] sevenseacat: i have a feeling you will change your tune.
[16:02:09] darrik: sevenseacat: but contrapositively, having 30 copies of a gem installed is not a strong argument against, unless you're terribly limited on disk space
[16:02:25] sevenseacat: the argument against is that its totally unnecessary
[16:02:48] AntelopeSalad: if you have global gems how do you handle different versions?
[16:03:02] sevenseacat: you use bundler, which locks the gems to those in your Gemfile
[16:03:03] scyllinice: Bundler handles it
[16:03:04] AntelopeSalad: do you just put the ver in the gemfile and it handles it?
[16:03:10] scyllinice: AntelopeSalad: Bingo
[16:03:27] sevenseacat: you dont even need to specify the version, it goes from your Gemfile.lock.
[16:03:42] AntelopeSalad: yeah i never specified the ver for any gem yet
[16:03:50] scyllinice: Well, you do if you want a particular project to use that gem version
[16:03:57] scyllinice: So if you run bundle update, you don't lose that
[16:04:16] anannie: do you people also discuss the professional side of rails in this channel? Or is that off-topic?
[16:04:29] scyllinice: anannie: We talk about PHP here sometimes
[16:04:31] s2013: anannie, depends on whos here
[16:04:34] scyllinice: Usually making fun of it
[16:04:51] s2013: why is php better than rails? go!
[16:04:52] scyllinice: You can't get much more off topic than PHP
[16:05:01] s2013: yes you can. when you talk about ruby
[16:05:11] s2013: its always "go to #ruby"
[16:05:21] scyllinice: anannie: What are you interested in particularly?
[16:06:22] scyllinice: Also, I don't know if it's still true, but at one point, adding particular versions to your gems in your Gemfile sped up bundle install
[16:06:26] anannie: scyllinice: The market situation for freelancers i.e. the ease with which I can get freelancing contracts and if it's possible to get enough to sustain yourself this way
[16:06:37] scyllinice: Because Bundler didn't have to work so hard resolving dependencies
[16:06:50] sevenseacat: anannie: well thats very dependent on your location
[16:07:08] s2013: and your skills
[16:07:09] anannie: sevenseacat: Canada. Vancouver, but I can move around.
[16:07:27] anannie: s2013: Skills can be developed. A market can't.
[16:07:35] darrik: anannie: and your dilligence. i've been "freelancing" from ohio for about 10 years, and the market isn't strong here. most of my work comes from out of state by a long shot
[16:07:56] scyllinice: anannie: Right. You'll have to market yourself pretty heavily
[16:08:01] s2013: market can change. so market now isnt indicative of market in the future
[16:08:21] scyllinice: anannie: But a lot of people freelance and live just fine. Especially if they aren't married with children
[16:08:23] s2013: anannie, like ive told you before, the best way is to go to events, network with people, know them, etc.
[16:08:23] anannie: darrik: How do you maintain in touch with them / network?
[16:08:52] darrik: anannie: im, phone, video conference, travel. whatever is necessary
[16:09:03] darrik: anannie: largely depends on the client
[16:09:13] anannie: scyllinice: So basically the algorithm is to go to business meetups, conferences et al, schmooze and pick up a contact?
[16:09:21] s2013: are you in columbus darrik?
[16:09:35] darrik: s2013: nope. akron
[16:09:42] s2013: ah ok. say hi to lebron from me
[16:09:44] scyllinice: anannie: Yep. Leverage your social network as well
[16:09:57] anannie: or do freelancers have to engage in a more formal sales process like enterprise sales?
[16:10:04] darrik: s2013: you from ohio?
[16:10:14] s2013: almost went to ohio state though
[16:10:31] s2013: anannie, you are selling yourself, rather than your company
[16:10:38] sevenseacat: this sounds like 'i want to freelance but have no idea what freelance means' :/
[16:11:07] scyllinice: anannie: Podcast for you as well http://www.freelancersshow.com/
[16:11:10] anannie: s2013: I'll create a company and I'll try to grow it beyond, so from day one I would like to act as if I'm working on behalf of a company
[16:11:31] s2013: ok. baby steps. if you want to freelance/work with rails, learn rails
[16:11:47] s2013: then worry about the next steps
[16:12:14] darrik: anannie: depending on your market, success may depend on not limiting yourself just to rails. obviously, you are more viable with more skills
[16:12:24] darrik: but i might not be allowed to say that in #ror
[16:12:33] scyllinice: darrik: You're allowed to say anything
[16:12:34] s2013: its true darrik
[16:12:44] anannie: darrik: I plan to learn django and PHP / symphony as well
[16:12:56] s2013: i plan on walking naked on mars
[16:13:02] scyllinice: anannie: Reality is that you might find more work in PHP, but it wouldn't pay nearly as well
[16:13:11] scyllinice: Or be nearly as fun
[16:13:28] s2013: we started doing php originally. some iphone/android apps and then rails projects started to come in so is tarted learning rails
[16:13:30] darrik: this is true, but sometimes knowing php can get your feet in the door on projects, and then you can sell them on rails
[16:13:36] s2013: and i decided, clients are pain in the ass sometimes
[16:13:49] darrik: s2013: sometimes? lol
[16:14:17] s2013: most of our clients are other firms so its not that bad
[16:14:32] anannie: scyllinice: Sub-contracting :)
[16:14:34] s2013: but even then, it can be pain in the ass. we try our best not to deal with direct clients
[16:14:55] anannie: scyllinice: Passive income is great.
[16:15:13] darrik: s2013: my experience is the opposite, and we try our best not to deal with firms but rather directly with clients
[16:15:26] anannie: (well not so passive, but hope you understand)
[16:16:05] scyllinice: anannie: I get it. You want to be the Vancouver Rails kingpin
[16:16:23] s2013: darrik, yeah but weve worked with some big name clients only cause of the firms. then again im in nyc
[16:16:45] s2013: from my experience, clients that pay more, hassle you less
[16:16:49] anannie: scyllinice: Nah. Just save up enough in 3 years to move to California comfortably and pursue what I want to do
[16:17:00] scyllinice: anannie: Which is what?
[16:17:10] s2013: buy out darpa scyllinice
[16:17:12] s2013: and the dod
[16:17:26] scyllinice: s2013: That would be a big dream
[16:17:26] sevenseacat: eat chocolate.
[16:17:39] anannie: scyllinice: Build robots. I have more specific goals in mind, but yes that 's the plan.
[16:18:12] s2013: sevenseacat, isnt it really late there now?
[16:18:21] sevenseacat: s2013: 12.18am.
[16:18:39] s2013: oh yeah you are in perth i forgot
[16:20:29] scyllinice: sevenseacat: Because this is a slightly better medium than Twitter: I did wish Warrior was a bit more realistic than what it was
[16:20:49] sevenseacat: scyllinice: i know nothing about MMA so it was realistic enough to me :P
[16:21:04] sevenseacat: (also, whoa offtopic lulz)
[16:21:09] scyllinice: sevenseacat: hah
[16:21:36] scyllinice: sevenseacat: I try to get my wife to watch it sometimes, but she just won't
[16:29:46] anannie: scyllinice: Thank you for your help, btw
[16:29:55] scyllinice: anannie: Not a problem
[16:30:09] scyllinice: Sometimes I get more enjoyment helping people than I do writing code
[16:30:23] anannie: scyllinice: Two guys going at each other and none of them are fighting over you or hot? Nah. I wouldn't want to watch that either
[16:31:00] scyllinice: anannie: Hah. It's a sport. Just like the others
[16:31:23] anannie: ACTION doesn't do sports...
[16:31:36] scyllinice: There's such thing as Women's MMA too
[16:32:28] scyllinice: One of the more popular fighters happens to be from Australia. Brisbane I think?
[16:32:53] sevenseacat: we breed 'em tough down here.
[16:33:51] scyllinice: sevenseacat: This would be her: http://www.sherdog.com/fighter/Bec-Hyatt-84964
[16:34:34] sevenseacat: looks pretty hardcore.
[16:34:48] anannie: Wow. She has the same birthday as my sister.
[16:35:10] scyllinice: Yeah. They are often more aggressive than their male counterparts
[16:35:13] anannie: ACTION likes coincidences
[16:35:50] anannie: scyllinice: I could never do something like that...
[16:35:59] scyllinice: anannie: Neither could I
[16:36:17] scyllinice: anannie: One of the reasons I like it I guess.
[16:36:24] scyllinice: I can go out and play baseball or basketball
[16:36:30] scyllinice: I can't exactly go out and do what they do
[16:36:40] s2013: anannie, you have a sister?
[16:37:02] anannie: s2013: well she certainly calls herself that
[16:38:26] anannie: If you're asking if I love her, of course I love her.
[16:38:36] s2013: do you call yourself her sisteR?
[16:38:37] anannie: We rarely talk though
[16:38:47] scyllinice: s2013: That's getting kinda personal, isn't it?
[16:39:04] anannie: Yeah it is
[16:40:11] s2013: lol scyllinice ive known anannie for a long time now. she knows im just messing with her
[16:43:32] anannie: hrm it seems that my rails install is stuck on; Installing ri documentation...
[16:43:55] anannie: What happens if an install gets botched? Does the system roll back?
[16:44:18] sevenseacat: the install of the gem is complete, you can safely cancel out
[16:53:27] platzhirsch: Where would I initialize a MemoryCache to make it available in my controllers?
[17:01:15] mtfOO_: Hello, I'm newbie, following a tutorial on internet http://api.rubyonrails.org/v3.2.13/files/activeresource/README_rdoc.html I have problems making it work http://pastebin.com/kUHHuKFh
[17:17:07] speedgrafic: I've got a nested form that isn't creating records for the nested model when it's submitted. Can anyone take a look at my code? http://pastie.org/8363917
[17:17:42] scyllinice: speedgrafic: What's the form look like?
[17:18:56] speedgrafic: scyllinice: http://pastie.org/8364862
[17:19:37] emeka-linux: hi. im new to IRC. is there anyone i can have a conversation with about rails
[17:21:11] scyllinice: speedgrafic: I assume this is a Rails 3 app?
[17:21:21] speedgrafic: scyllinice: you're correct
[17:28:06] scyllinice: speedgrafic: I'm not seeing anything wrong that jumps out at me. It saves the lead but the contact isn't?
[17:29:35] speedgrafic: scyllinice:yeah, lead gets saved as expected, and I can get see the data I've entered when I go to the edit view, but nothing shows up in Contact's index view.
[17:37:21] anannie: scyllinice: May I PM another career kind of query?
[17:37:32] scyllinice: anannie: Sure
[17:39:08] speedgrafic: scyllinice: If I run Contact.all in the console, I can see that the records are actually being created by the form, they're just not reflected in the Contacts index
[17:39:27] scyllinice: speedgrafic: Well, that's a different issue completely
[17:39:43] speedgrafic: scyllinice: yeah, I didn't think to check the console.
[17:39:58] speakingcode: why would i be getting 'TypeError (no implicit converson of Symbol into Integer) when doing a request with nested_attributes?
[17:40:13] speedgrafic: scyllinice: If i add a contact in the Contact _form, it shows in the index as expected.
[17:40:15] toretore: speakingcode but not showingcode
[17:40:26] speakingcode: (i'll make a gist if I need to, just figured this may be a general/common thing)
[17:40:32] toretore: live up to your username]
[17:42:03] toretore: Q: Should I show my code? A: Yes.
[17:44:24] speakingcode: https://gist.github.com/speakingcode/6754770
[17:45:12] speakingcode: when i omit the nested attributes (recipient_messages_attributes) from the request it works fine, so the nesting seems to be causing the issue
[17:45:47] toretore: collection vs single item
[17:45:51] toretore: is the problem
[17:46:06] toretore: it's a hint ;)
[17:46:27] toretore: another one: has_many :recipient_messages
[17:46:45] speakingcode: yeah, its a one to many relationship
[17:46:46] toretore: and another: "recipient_messages_attributes"=>{"recipient_id"=>"2"}
[17:48:33] speakingcode: yes, that's the way i have it. so showing that isn't exactly useful
[17:49:24] speakingcode: a message has many recipients, and the relationship is through a join table (recipient_messages)
[17:50:02] speakingcode: theres no issue there that i can see. if i create the records manually in rails console the traversals work just fine
[17:50:37] toretore: your model wants geese, you give it goose
[17:51:15] speakingcode: how am i giving it goose if i'm giving it a collection? the collection happens to have a single item in it in this particular quest but that shouldn't matter
[17:51:30] toretore: getting warmer
[17:52:54] speakingcode: bahaha, than's toretore. got blind in the command line with curl
[17:53:23] speakingcode: curl -X POST -d '{"sender_id":"1","recipient_messages_attributes":[{"recipient_id":"2"}]}' -H "Content-Type:application/json" -H "Accept: application/json" localhost:3000/users/1/messages
[17:53:38] speakingcode: ^^ that did it
[17:54:02] speakingcode: now i feel stupid cause i wasted about an hour and it was all cause of me making a malformed request :-\
[17:55:51] skyjumper: meoblast001: north pittsburgher?
[17:56:10] skyjumper: zoominternet
[17:57:03] meoblast001: iirc, they serve West PA, East OH, and North WV?
[17:57:12] meoblast001: the North WV is the part i'm not sure about
[17:57:16] skyjumper: yeah that makes sense
[17:57:31] skyjumper: north wv should probably be ohio anyway
[17:57:48] platzhirsch: Is there a shorter way to come from :"intrinsic-precision" to "IntrinsicPrecision" than .to_sym.underscore.camelcase?
[17:58:02] skyjumper: just a sliver of WV in between two other states
[17:58:57] weirdpercent: hello, I'm trying to fix this deprecation but I'm unsure of the correct syntax. The error is "Relation#first with finder options is deprecated" and the code is @user ||= User.first conditions: {:email => @visitor[:email]}
[17:59:34] scyllinice: weirdpercent: Use where
[18:00:47] weirdpercent: scyllinice: something I read said that "where" replaces condition, so like this? @user ||= User.find where(:email => @visitor[:email])?
[18:01:22] scyllinice: weirdpercent: @user ||= User.where(:email => @visitor[:email]).first
[18:02:37] weirdpercent: scyllinice: thank you
[18:07:09] railsnoob: how would i write a rails 4 params permit, for the following http://pastie.org/8364969 ?
[18:10:21] omarqureshi: params.permit(:machine_id).require(:recipe).permit(:test).tap {|wl| wl[:ingredients] = params[:recipe][:ingerdients]}
[18:10:24] omarqureshi: at a quick glance.
[18:11:45] omarqureshi: s/test/title/
[18:11:57] omarqureshi: s/inger/ingre/
[18:14:54] railsnoob: omarqureshi: it says "param not found: recipe"
[18:15:18] omarqureshi: did you put it in require?
[18:15:28] omarqureshi: and are you passing it?
[18:16:01] railsnoob: http://pastie.org/private/yihud6s10ero9zkjs1vq7a
[18:16:30] omarqureshi: you'll need to fix that statement with the replacements i gave.
[18:16:38] omarqureshi: 18:15 < omarqureshi> s/test/title/
[18:16:39] omarqureshi: 18:16 < omarqureshi> s/inger/ingre/
[18:16:47] omarqureshi: what do your submitted params look like?
[18:17:57] railsnoob: http://pastie.org/8364998
[18:18:03] omarqureshi: ditch the permit(:machine_id)
[18:18:21] omarqureshi: params.require(:recipe).permit(:title).tap {|wl| wl[:ingredients] = params[:recipe][:ingredients]}
[18:18:28] omarqureshi: params.require(:machine_id)
[18:19:03] omarqureshi: two separate method calls
[18:19:30] omarqureshi: you may even be able to do
[18:19:55] omarqureshi: params.require(:recipe).permit(:title, {:ingredients => []})
[18:20:11] omarqureshi: read the strong parameters page
[18:20:14] omarqureshi: https://github.com/rails/strong_parameters
[18:25:07] coj: so i've been pondering - in a relational DB, is it better to split a tree from its leaf nodes? i.e. the nodes are categories and there are items as the leaf nodes, but you could split them off as a separate table. it seems neater somehow, but doesn't otherwise have many advantages.
[18:25:18] coj: (a tree is represented as a table of nodes, in combination with a tree gem like ancestry or nested_interval.)
[18:25:33] coj: if the leaf nodes were stored in the node table, then they would require columns that the other nodes wouldn't need at all. e.g. quantity, foreign key, and so forth.
[18:25:42] coj: anyone have a view on this?
[18:27:59] omarqureshi: my view is to use a database that supports trees if trees are what you want.
[18:28:20] omarqureshi: http://www.postgresql.org/docs/9.3/static/ltree.html < coj
[18:28:36] coj: yep, seen that
[18:29:10] coj: i may go with that in the end, but it's a separate question from what i'm asking
[18:29:56] omarqureshi: if its all stored in the same table, metadata about tree structure is a moot point?
[18:30:20] omarqureshi: if thats what you mean by fk's / quantity
[18:32:18] coj: the tree's nodes are stored in a node table, but the leaf nodes have additional - e.g. quantity & foreign key references. the branch nodes won't use those columns. so i was thinking of splitting them off
[18:32:37] coj: (thanks for responding, btw)
[18:33:21] coj: so you'd include the columns in the node table even if the branch nodes wouldn't use them? hmm
[18:33:26] coj: i guess that saves on the join
[18:33:33] omarqureshi: id keep it simple, all in the same table - it does mean null constraints would not be possible
[18:34:32] omarqureshi: if null constraints are of religious significance, then by all means split it up
[18:34:36] omarqureshi: the join wont be too bad
[18:34:37] coj: i'd just have to be careful with the logic to differentiate leaf nodes from branches, e.g. always check for a foreign key
[18:34:47] coj: religious? nah i'm a pragmatist
[18:35:21] coj: i'm just afraid i'll end up adding even more columns to the leaves and end up making a pretty imbalanced table
[18:35:43] omarqureshi: for the few root nodes that you will have, does it matter?
[18:36:08] omarqureshi: im assuming you will have a shit load more child nodes than root nodes
[18:36:28] coj: well branch nodes won't need those columns either, it's onlythe leaves
[18:36:49] omarqureshi: right, so - adding a new column for children is not going to impact that much.
[18:37:22] coj: a new column for children? are you referring to the tree metadata or the additional data for leaves?
[18:37:31] omarqureshi: the additional data
[18:38:07] coj: i guess the additional data is no issue, not until we're talking really large scale
[18:38:32] coj: have you used ltrees before?
[18:39:09] omarqureshi: ltrees and recursive queries
[18:39:15] omarqureshi: i found ltree to be easier to work with
[18:39:19] coj: how do you handle them from rails? is there a gem to do it, or do you use raw sql?
[18:39:21] omarqureshi: but, will need you to install pg-contrib
[18:39:47] coj: hmm installed pg-contrib alr
[18:39:49] omarqureshi: i dont use gems for trivial tasks
[18:40:21] coj: i've recently been doing more raw SQL queries, but still use ORM
[18:40:42] coj: with ltrees how do things go?
[18:41:58] omarqureshi: i used it as a data storage for an internationalization api
[18:42:20] omarqureshi: could group up keys this way
[18:42:30] coj: when you retrieve nodes, do you work with objects or hashes?
[18:42:42] coj: how do you get children, filter children, etc.?
[18:42:52] omarqureshi: .where("lquery...")
[18:43:51] omarqureshi: querying with ltree is just like any other sql where clause
[18:49:08] coj: if i wanted to preserve all the relationships between the nodes, so i could go from node to node in ruby with obj.children[0], etc.
[18:49:35] omarqureshi: not possible without additional queries
[18:49:38] coj: would that be the way with ltrees? if i retrieved a tree
[18:50:04] coj: hmm then how would you render the tree as say a comment tree
[18:50:35] omarqureshi: order by ltree_column? :D
[18:51:07] omarqureshi: then some sort of grouping at the application level
[18:51:42] coj: which involves parsing the ltree_column?
[18:51:57] omarqureshi: yeah, but AR treats it like a string
[18:52:07] coj: which as i understand is something akin to foo/bar/baz
[18:52:16] omarqureshi: dot-separated
[18:52:23] coj: so basically the retrieved items don't have linking logic
[18:52:46] omarqureshi: but, what you could do is if you were sadistic ...
[18:52:56] omarqureshi: http://www.postgresonline.com/journal/archives/173-Using-LTree-to-Represent-and-Query-Hierarchy-and-Tree-Structures.html
[18:53:20] omarqureshi: triggers to give you node keys
[18:54:16] coj: sounds like i should be using a gem
[18:54:18] coj: after all
[18:54:44] omarqureshi: performance wise, the gem may screw you
[18:55:19] omarqureshi: atleast with triggers the pain is only on inserts
[18:56:24] coj: hmm yeah i'd have to see the performance
[18:56:29] omarqureshi: if you have a n-level tree, you may have to do n queries
[18:56:46] coj: i estimate an upper limit of maybe 5-6 levels and 2000 leaf nodes
[18:56:48] omarqureshi: using a query expression, you'd just do 1
[18:56:48] coj: per tree
[18:57:18] railsnoob: omarqureshi: cheers for the help, got it working :)
[18:57:22] omarqureshi: great railsnoob
[18:58:22] coj: n-level tree would only require 1 query, surely? albeit a "LIKE" query
[18:58:40] coj: e.g. LIKE 'tree1'
[18:58:47] omarqureshi: to get all children?
[18:59:00] omarqureshi: it depends on how the gem works
[18:59:09] omarqureshi: assuming there is a gem
[19:00:27] coj: ancestry is a pretty well-established gem using the materialized path pattern
[19:00:35] coj: featured on railscasts
[19:01:08] omarqureshi: doesnt look like it supports ltree, just does like queries
[19:01:14] omarqureshi: so, no fancy indexing there
[19:01:31] coj: but not n queries
[19:01:46] omarqureshi: n FAST queries > 1 non-indexed query
[19:02:05] omarqureshi: and of course 1 fast query > n fast queries
[19:02:07] coj: i personally would rather have used awesome_nested_interval but it doesn't seem as developed
[19:02:58] coj: is it possible to index an MP column?
[19:03:13] coj: materalized path
[19:03:22] omarqureshi: so, you're going to be using like to query
[19:03:28] coj: e.g. tree1/subnode2/subsubnode14
[19:03:41] coj: pretty much
[19:03:53] omarqureshi: the problem is you can't use indexes for like's
[19:04:43] coj: come to think of it i could just add a column "root_id"
[19:05:11] omarqureshi: though text_pattern_ops may solve
[19:05:17] omarqureshi: http://www.postgresql.org/docs/9.3/static/indexes-opclass.html
[19:07:40] speedgrafic: scyllinice: I think I'm starting to understand my issue from earlier
[19:08:04] speedgrafic: scyllinice: I'm not seeing those records in the index view because the Contact isn't being assigned a user_id on create
[19:08:18] fcanela: Hi. I am more or less new with Rails and I do not know if the following behaviour it's normal (I think that it's not, as far as I have read on stackoverflow)
[19:08:50] fcanela: I have two models, A and B. A can have many B and B belongs to A.
[19:09:04] scyllinice: speedgrafic: Right. When you do build through the lead, you're just setting lead_id
[19:09:27] speedgrafic: scyllinice: how should I go about assigning a the current users's id as well
[19:09:36] fcanela: In A controller, at new action, I do: new_b = A.B.build
[19:09:48] fcanela: and the "new_b" just created have the "a_id" field as nil
[19:10:17] fcanela: it's this normal? is the "parent" id set up at saving or it should be already there?
[19:10:42] scyllinice: speedgrafic: You can set it in the create action before you have
[19:15:07] scyllinice: anannie: Maybe you should do a modern day version of this that's web controlled: http://www.chonday.com/Videos/the-writer-automaton
[19:21:25] anannie: scyllinice: I'll be honest, I've built robotic hands and arms, but this thing is beyond me. Very much beyond me, but this is seriously something I would love to do
[19:21:56] macs: hey y'all, is it okay to learn ruby from a 1.8 or 1.9 textbook even if using 2.0?
[19:22:16] omarqureshi: its mostly fine macs
[19:22:22] anannie: scyllinice: Without any inverse kinematics or anything like that, this man managed to capture all of those precise movements in mechanical form. That is a work of art genius
[19:22:37] macs: omarqueshi: ok thanks I think im gonna use rvm and use a different version
[19:27:44] Flashmasterson: i'm trying to go step-by-step with RailsGuides but receive this in the terminal instead of what the guide has at 4.2 : https://gist.github.com/Flashmasterson/6755691
[19:28:56] Jasinai: Flashmasterson: are you in your projectfolder?
[19:29:26] Flashmasterson: where? in github?
[19:29:33] Jasinai: no in your terminal
[19:29:50] Flashmasterson: i'm in 'macintosh' directory
[19:31:25] Jasinai: and did you do "rails new projectname" and "cd projectname"?
[19:32:08] Zesty: If I have a route that /:looks/:like(/:this) how do I use link_to to construct a url that looks like that?
[19:32:24] Zesty: when i pass them into the named route, it just turns it into a query string
[19:32:26] Flashmasterson: jaseemabid: i will but i have to change to non-rails directory, how do i do that?
[19:32:40] Jasinai: Flashmasterson: did you do this steps: http://guides.rubyonrails.org/getting_started.html#creating-the-blog-application ?
[19:33:29] Flashmasterson: jaseemabid: yeah that's where i'm at
[19:33:47] Flashmasterson: i get this when i try to do that: Macintosh:blog toreystriffolino$ rails new blog
[19:33:47] Flashmasterson: Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.
[19:33:48] Flashmasterson: Type 'rails' for help.
[19:33:51] Jasinai: Flashmasterson: the error message says, that you are not in a rails project
[19:36:00] Flashmasterson: jaseemabid: ok but i need to create that new project before i can get into it, and that's what i'm asking how to do; create one. the instructions i'm reading just take me to an error screen
[19:38:30] jaseemabid: that was to Jasinai i suppose ? :)
[19:42:40] Jasinai: Flashmasterson: it looks like you are now in a rails project.. can you do the rails generate controller welcome index line again? is it the same error message?
[19:43:42] Flashmasterson: Jasinai: what the hell - no it's different and what i wanted
[19:44:08] Flashmasterson: Jasinai: what could i have done to change it?
[19:46:32] Jasinai: don't know ^^ i think you were not in the rails project, so it said, you should do rails new first.. and perhaps you changed to that directory afterwards
[19:47:46] s2013: Flashmasterson, did you cd into your rails directoyr?
[19:47:57] s2013: rails project directory rather
[19:48:31] Flashmasterson: s2013: i tried but it wasn't found, so i tried 'cd ~/blog'
[19:48:47] s2013: you typed in rails new blog right?
[19:49:00] s2013: what did it say afterwards
[19:49:02] s2013: did it create it or no
[19:49:10] s2013: it should show bunch of bundle install messages
[19:49:19] Flashmasterson: not yet, it said 'Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.'
[19:49:38] s2013: then type cd ..
[19:49:43] s2013: then you are already in a rails app
[19:49:47] s2013: which os are you on?
[19:50:00] fcanela: please, could you confirm me if this situation is normal: A have many B models, who belongs to A. In A#new I do: new_b = a.b.build. The new_b have a_id attribute set as nil
[19:50:20] s2013: what directory are you in currently
[19:50:37] Flashmasterson: Macintosh:blog toreystriffolino$
[19:51:04] s2013: so you are in the blog directory
[19:51:08] s2013: type rails s
[19:51:33] Flashmasterson: ok what does 's' stand for
[19:51:41] s2013: it should start the server
[19:51:44] s2013: and then go to localhost:3000
[19:52:15] s2013: is your app running?
[19:52:26] Flashmasterson: yeah 'welcome aboard'
[19:52:30] s2013: ok cool so its running
[19:52:33] s2013: just remove public/index.html
[19:52:38] s2013: if its not rails 4
[19:52:41] s2013: and then you are on your way
[19:52:55] Flashmasterson: cool thanks a lot, it is rails 4 btw
[19:53:07] s2013: ok then you dont need to remove public/index.html i think
[19:54:46] bauerbob: hi. i think i made a mistake. i put a lot of business logic into helpers ...which i know now is somewhere at the controller level. i guess i should have put business logic into the models, right?
[19:55:35] Flashmasterson: s2013: ok. i'm also unable to open config/routes.rb, because it's not showing up in my mac to open on my unregistered sublimetext 2
[19:55:49] s2013: what do you mean unable to ope
[19:56:20] s2013: just do nano config/routes.rb
[19:56:26] s2013: in your terminal, see what happens
[19:57:14] Flashmasterson: ah??? nothing happened yet
[19:57:25] s2013: go to config directory
[19:57:27] s2013: do you have routes.rb?
[19:57:41] Xeago: use ls in your terminal to list files
[19:58:03] bauerbob: the nice thing about helpers is that it's implemented with ruby's modules, so that i can access the helper methods in the main namespace (i don't need a class or object prefix). now here's the question: why not implement something like model helpers using ruby modules?
[19:58:37] bauerbob: is there a gem for that?
[19:58:45] Flashmasterson: s2013: i think i do have routes.rb, and how do i go to config directory? 'cd ~/config' ?
[19:58:47] bauerbob: is there a name for that?
[19:58:54] s2013: just cd config
[19:58:58] s2013: then type ls
[19:59:08] s2013: its basic terminal stuff bro
[19:59:11] s2013: i dont even have a mac and i know it
[19:59:27] Jasinai: ~ stands for your homedirectory
[20:00:13] Flashmasterson: s2013: ok well i play upright bass and have no idea what i'm doing
[20:00:22] s2013: its fine.. just type cd config
[20:00:23] s2013: then type ls
[20:00:25] s2013: and see if routes.rb shows up
[20:00:35] s2013: if it does then type subl routes.rb in your terminal
[20:00:42] Flashmasterson: no nothing showed up, i think the terminal is stuck and needs a Ctrl+C
[20:00:49] s2013: okay open up a new terminal
[20:00:53] s2013: cause you are ont he server
[20:01:02] s2013: open up a new terminal
[20:01:11] s2013: you generally need 3 terminals one for server, one for console, one for other stuff
[20:02:08] Flashmasterson: s2013: ok that's news to me , thanks. and 'command not found' when i type subl routes.rb
[20:02:33] s2013: thats fine
[20:02:40] s2013: just open up sublime text and open up the folder blog
[20:02:42] V8Energy: when i use button_to it puts the submit button inside div tags. is there a way to avoid that?
[20:04:00] Flashmasterson: s2013: ok it's open in sublime text
[20:05:35] Flashmasterson: s2013: now what? i'm off the tracks of the guide
[20:06:15] s2013: what are you trying to do
[20:07:03] Flashmasterson: the green check marks on this page http://guides.rubyonrails.org/getting_started.html
[20:08:29] fcanela: please, could you confirm me if this situation is normal: A have many B models, who belongs to A. In A#new I do: new_b = a.b.build. The new_b have a_id attribute set as nil
[20:09:02] helpa: fcanela: We cannot help you with your problem if you don't show us your code. Please put it on http://gist.github.com and give us the URL so we can see it.
[20:09:02] toretore: fcanela: !code
[20:10:43] s2013: Flashmasterson, they are just guides, not step by step
[20:10:58] s2013: Flashmasterson, http://ruby.railstutorial.org/
[20:12:37] fcanela: ok, i'll post it. I just wanted to know about the working of the method, cause of as I think that I am understanding at docs and stackoverflow it should set it
[20:12:45] fcanela: I'll post it in few mins, thx toretore
[20:12:53] Flashmasterson: s2013: ok i have that too but some jackasses bad-mouthed it and now i'm trying this
[20:13:01] s2013: which jackass?
[20:13:07] s2013: they serve two different purpose Flashmasterson
[20:13:28] s2013: one is documentation, the other is a guide to building your own app
[20:13:53] Flashmasterson: s2013: ok. i'm trying to learn enough ruby language and rails to create my own web application
[20:14:01] s2013: learn ruby first though
[20:14:06] s2013: before jumping into rails
[20:14:56] Flashmasterson: s2013: ok what is a good method for that, this has been a vey complicated and arduous process so far
[20:15:16] s2013: there is a good book called the well grounded rubyist
[20:15:20] s2013: i recommend that
[20:15:27] s2013: but there are plenty of ruby tutorials online
[20:16:25] Jasinai: try: http://tryruby.org ?
[20:17:26] Flashmasterson: Jasinai: thanks, i went through that a little while ago
[20:17:55] Flashmasterson: s2013: and this book is considered to be easy for beginners?
[20:19:35] s2013: it is for beginners, yes.
[20:19:57] s2013: thats how i started. although im not even good enough to be considered a shitty developer, it helped me a lot
[20:21:24] Flashmasterson: s2013: ah, encouraging words
[20:21:33] s2013: yeah try it
[20:21:37] s2013: good luck!
[20:22:23] V8Energy: is there a way to cache the query result? for example if I am doing @adults = User.where(age > 18) and few lines later I have a loop that does @adults.where(name: 'test') 20-30 times. I dont want it to query the database 20-30 times, I want it to stick with the results contained in @adults. is there a way?
[20:27:08] Maoz: I would like to create a union of activerecord results like: "categories.each do |cat| union = union + cat.subcategories.where('...')" What should be the class type of union?
[20:31:09] Metraton: hi everyone. i'm very noob to rails. I'm having troubles with a select helper on a form... anyone can help me? it should be really simple but it's getting me crazy and i'm stuck at it for two days now...
[20:33:57] Metraton: I have two models: samples and patients. I want to select a field on the new samples form, store it on the patient one...the possible values are stores on a constant by i'm getting troubles mapping the correct values...
[20:35:16] Flashmasterson: what are some other good ruby books for complete idiots
[20:39:40] Metraton: anyone can help me with this question? http://stackoverflow.com/questions/19066995/use-constant-with-collection-select-with-simple-form
[21:15:45] platzhirsch: When you have nested resources, is the approach to create subfolders in app/views and app/controller or rather to keep it flat and them side by side?
[21:17:44] patie: is there something like prawnto or prawn-rails working with rails4 ? thx
[21:18:29] bauerbob: platzhirsch, side-by-side
[21:18:36] platzhirsch: bauerbob: thanks
[21:26:10] AntelopeSalad: if i want to perform a dependent destroy based on the value of a param what's the best way to go about that? would i do it with a before_destroy callback?
[22:17:01] Radar: Good morning everyone.
[22:39:27] s2013: how would i setup a local server so others can access it
[22:56:07] toastynerd: s2013: rails server 0.0.0.0:3000 then you should be able to access the server via your local ip address
[22:56:55] toastynerd: s2013: if you want it visable across the internet you need to setup some port forwarding on your router
[23:05:31] jb41: I'm getting 500 error from heroku, when I try to acces nested resource, but locally it's working
[23:05:40] jb41: anybody have similar problem?
[23:05:52] s2013: toastynerd, yeah i meant across the internet
[23:06:06] s2013: i was thinking of using something like nginx
[23:06:47] jb41: ActionView::Template::Error (undefined local variable or method `new_account_path', it's strange why it's trying to access 'new_account_path', while rake routes shows that there is new_user_account_path (user has_one account)
[23:07:13] jb41: as I set it in config/routes.rb
[23:07:32] toastynerd: s2013: yeah you'll have to look up the process for your router but you have to set up a static IP for the machine then forward incoming requests to that ip, but if it's home network you probably should just go with a cloud service instead, way less security concerns
[23:08:02] s2013: toastynerd, tbh i just need it working in my office netowrk
[23:10:00] toastynerd: s2013: in that case you could do it through a vpn, I've never configured one before so you'll have to consult the almighty intarwebs
[23:10:26] AntelopeSalad: if you don't want to forward the port in your router (which will 100% work), you could try using the localtunnel service
[23:11:09] AntelopeSalad: http://progrium.com/localtunnel/#readme
[23:11:32] s2013: reason i cant put it up online is because the db is freaking huge and there are some restrictions. but link looks good thanks
[23:11:51] AntelopeSalad: that will make it public btw
[23:12:14] toastynerd: s2013: how huge?
[23:12:15] AntelopeSalad: if it's on a standard network you can just goto your internal ip with the port
[23:12:27] AntelopeSalad: rather than localhost, it'll probably be like 192.168.1.3 or whatever is assigned to your box
[23:13:07] s2013: few gigs toastynerd
[23:13:21] s2013: yeah i think 192.168... is better
[23:16:33] mva3212: Heyo -- Quick Question: I wanted to redirect users to the login page before they post a comment, and then once they sign in, complete the comment post
[23:17:03] mva3212: in my application after_signed_in_for it is redirecting to the root
[23:17:24] mva3212: how do I save the params and post once authentication has completed
[23:17:39] mva3212: i'm using devise and before_filter authenticate_user!
[23:19:21] s2013: mva3212, session[:return_to]
[23:19:25] toastynerd: mva3212: you can either do the login process through ajax requests or use session variables to store the post id and the params
[23:19:54] mva3212: s2013: I have it able to redirect back but it doesn't post the comment
[23:20:28] mva3212: toastynerd: how would I save the session variables with before_filter ? or would I have to do it inside the controller action?
[23:21:47] toastynerd: mva3212: you could do it either way, essentially you could set session[:params] = params then run some checks in your controller action to see if session[:params].blank?
[23:26:04] toastynerd: mva321: for similar patterns I usually use a session or local variable and set it to whichever exists(sessions or params), then throw an error if they're both blank
[23:27:32] diggitydane: how do you initialize a polymorphic association on an activerecord model?
[23:27:35] diggitydane: https://gist.github.com/anonymous/6757480
[23:28:44] diggitydane: i don't want to add attr_accessible, i'd rather do it through intialize or after_initialize, but both throw an error
[23:37:31] darrik: s2013: another thing you can do is if you have a remote machine you have ssh access to, you can reverse tunnel the port from your desktop
[23:38:27] Andrevan: diggitydane: what's the error?
[23:38:38] darrik: s2013: such that hitting port 4444 on the remote host is really the endpoint of an ssh tunnel from your localhost on port 3000 (ports configurable, obviously)
[23:39:09] Andrevan: diggitydane: fwiw you probably need to pass type
[23:39:28] Andrevan: diggitydane: depending on whether that is chosen on the form
[23:39:30] Radar: Good morning everyone.
[23:39:42] optobear: morning Radar
[23:40:19] diggitydane: Andrevan: if I pass it in initialize, it gives me missing method [] on nil class
[23:40:39] diggitydane: Andrevan: if I do in after_initialize, it gives me unknown method delete on nil class
[23:40:51] s2013: darrik, thanks
[23:40:54] s2013: morning Radar
[23:41:00] Andrevan: diggitydane: I think you just need to specify the polymorphic type
[23:41:09] Andrevan: diggitydane: however, you should follow the trace if you can
[23:42:01] diggitydane: Andrevan: well, i'm trying to use dependency injection through the initialize, so don't want to specify as it could be 3 different things
[23:42:37] Andrevan: diggitydane: whatever it is that chooses the polymorphic type needs to pass it along
[23:42:52] diggitydane: Andrevan, but if I add attr_accessible :billable, it works fine. not sure if there is a security issue as i don't want to mass assign it
[23:43:02] diggitydane: Andrevan, ok, I'll try it with passing it along
[23:43:27] Andrevan: diggitydane: it does need to be attr_accessible... or use strong params
[23:43:52] Andrevan: diggitydane: as written, anyway
[23:44:06] Andrevan: diggitydane: I don't see how it's a security issue though
[23:45:35] diggitydane: Andrevan, awesome, thank you
[23:50:35] jtomasrl: do i have to specify the images directory on the css files for images to work in production?
[23:52:05] s2013: if its in assets/images then no
[23:52:23] s2013: actually nvm