« Back to channel list

#RubyOnRails - 15 September 2014

« Back 1 day Forward 1 day »
[00:01:43] aamax: yeah, it's my bad. i was calling it wrong to do the single test and that test isn't running when i run the whole suite (not sure why on that)
[00:01:47] aamax: thx neway
[00:42:38] helpa: I'm Dynamite
[01:16:19] dman777_alter: hi I am doing the tutorail on http://guides.rubyonrails.org/getting_started.html for the blog
[01:17:01] dman777_alter: when trying to save to the database the params.require(:article).permit(:title, :text) is not working and I get a ActiveModel::ForbiddenAttributesError in ArticlesController#create
[01:19:40] sevenseacat: and what is the full error?
[01:39:49] greenride: When using apipie, is there a way to utilize concern substitutions (apipie_concern_subst) inside of the example or description strings?
[01:49:42] Radar: dman777_alter: Can you please gist the fuill error message? Can you also put that app up on GitHub so we can inspect it?
[02:04:03] Radar: good morning sevenseacat
[02:10:20] sevenseacat: how are we all on this sunny monday morning
[02:50:05] capin: ehhh it's still sunday night for me :/
[02:50:47] capin: but no complaints really :)
[02:54:00] capin: sevenseacat: how's monday morning going for yuh?
[02:54:25] capin: cool, anything new and exciting happening?
[02:54:33] sevenseacat: spent like half an hour wrestling with select2 as part of this spree app im working on before deciding to just not use select2 for that field
[02:55:23] capin: isn't spree the gem that radar works on?
[02:55:50] capin: ohhh he's not working on that anymore?
[02:56:52] capin: well i'll be
[02:57:39] capin: sevenseacat: you ever work on syncing a rails api with an iOS app?
[02:57:43] lightswitch05: select2 isn't always the easiest jquery plugin
[02:57:44] Radar: http://ryanbigg.com/2014/07/ryan-bigg-is-now-a-git/
[02:57:51] sevenseacat: never worked on an iOS app, so no.
[02:58:06] sevenseacat: have done syncing stuff from the rails side though
[02:58:07] Radar: lightswitch05: non-sequitur much?
[02:58:22] sevenseacat: the problem wasnt with select2, it was with spree
[02:58:24] lightswitch05: Radar: not enough
[02:58:49] sevenseacat: trying to use select2 on a field in spree's nested fields
[03:00:28] sevenseacat: anyway :) all good
[03:02:41] capin: yeah im thinking about using restkit to sync with a rails app to consume the api on the iOS side, just not sure how all they syncing is going to work :/
[03:03:41] capin: Radar: congrats on the new gig, does this mean your coming back to the states? richmond VA?
[03:03:56] Radar: capin: Thanks :) I'll be staying in Melbourne for the time being.
[03:04:18] sevenseacat: no idea what that is. the syncing stuff ive done in the past was very manual - device hits a sync endpoint with the time of last sync, rails app responds with everything important and new since that time
[03:04:29] capin: Radar: don't get eaten by a shark ;)
[03:04:36] Radar: capin: No plans yet to even visit America
[03:06:08] capin: sevenseacat: i want something a la a mail app, be able to update your profile via the web using the rails app or using the iOS app itself
[03:06:46] sevenseacat: i'm not sure what the problem is here
[03:08:04] capin: LOL, no problem just explaining what kind of functionality i need ;)
[03:08:31] capin: or am trying to achieve, haven't gotten there yet :l
[03:32:43] coreycondardo: how can i output a form helper tag from a helper method into a view template?
[03:33:23] Radar: coreycondardo: what have you tried?
[03:33:42] coreycondardo: https://gist.github.com/coreycondardo/64bbfac4f1a5c12a818c
[03:33:50] coreycondardo: and i call that method from within my view
[03:33:55] Radar: and what happens?
[03:34:16] Radar: Why not just call concat instead of interpolating and .html_safe'ing
[03:35:32] lightswitch05: coreycondardo: don't the form helpers already return an html safe string?
[03:35:46] coreycondardo: i???m not doing it for any particularly good reason :)
[03:35:51] coreycondardo: i???ll blame it on ignorance!
[03:38:05] coreycondardo: i???m testing that out :)
[03:41:16] coreycondardo: is there a good way to prevent the explicit return in that helper method? for example it???s giving me an array of hours, even though all i want is the form i built
[03:42:27] sevenseacat: because the return value of that method is Task::HOURS
[03:42:45] sevenseacat: if you want to return something different, you need to do that
[03:43:04] coreycondardo: hi sevenseacat :)
[03:43:10] sevenseacat: remember, ruby always takes the last return value in the method as the return value of the method, unless you specify otherwise
[03:43:22] coreycondardo: which makes perfect sense. in this case my method is a helper method which returns a form
[03:43:35] coreycondardo: so its doing everything it should + returning me the value, as it should
[03:43:47] coreycondardo: i want it to do its thing EXCEPT tell it to forget about the thing it usuallyr eturns :)
[03:44:04] coreycondardo: i can return nil at the end
[03:44:05] sevenseacat: it doesnt return a form
[03:44:06] coreycondardo: but is that bad manners?
[03:44:15] coreycondardo: no it doesn???t return, it does render it for me tho if i call this from a view
[03:44:43] sevenseacat: you're not outputting anything from this method
[03:44:55] sevenseacat: calling html_safe on strings doesn't output them
[03:45:10] sevenseacat: nor should you be randomly printing things out from the middle of helpers
[03:45:22] sevenseacat: you should be returning one string, for your view to decide what to do with
[03:46:19] coreycondardo: well i had this all in a view, but that was too much logic so i thought i was supposed to pull it out of there and do logic elsewhere
[03:47:18] sevenseacat: you have two pieces of logic there - the loop and the conditional - and the conditional is entirely unnecessary
[03:47:46] sevenseacat: it can simply be written as `check_box_tag("checkin_times[]", hour, checkin_times.include?(hour.to_s), {:multiple => true})
[03:48:25] sevenseacat: that being said i dont know what this method is even for
[03:48:37] sevenseacat: i dont know why its not using rails' inbuilt helpers for building checkboxes
[03:49:09] sevenseacat: nvm, i was thinking of its helpers for radio buttons
[03:50:00] coreycondardo: the conditional checks the an array for a value. if the value exists it checks the box off in the form view
[03:50:12] sevenseacat: you don't need it there.
[03:50:38] coreycondardo: should it be in the view instead?
[03:50:45] sevenseacat: see the line of code i wrote ^
[03:50:51] coreycondardo: sorry i missed it let me look
[03:50:56] lightswitch05: coreycondardo: I think you have view templates mixed up with ruby code. Just having random strings in ruby doesn't do anything
[03:52:04] coreycondardo: i do get that. i was trying to follow the rules of not having too much logic in a view. i dont get when ur supposed to use a helper vs keep stuff in a view.
[03:52:12] coreycondardo: i get that strings in ruby dont do anything
[03:52:21] coreycondardo: im trying to learn the best practice thats all
[03:52:22] sevenseacat: if its reusable logic you want to share, put it in a helper.
[03:52:38] sevenseacat: putting a loop into a view is fine.
[03:53:28] lightswitch05: maybe this is what you are trying to do? https://gist.github.com/lightswitch05/9fc6090bc223595bafd0
[03:54:06] sevenseacat: lightswitch05: i really dont think thats what he means either, given that will return Task::HOURS.join
[03:54:33] lightswitch05: sevenseacat: yeah just removed that
[03:54:48] sevenseacat: so much poor code
[03:55:35] lightswitch05: I'm not saying this is the way it should be done - but I think this is what coreycondardo was aiming to do
[03:55:39] sevenseacat: there is no problem with putting a loop with three lines of code in it, in a view, which is all this should be.
[03:55:49] coreycondardo: which answers my q.
[03:55:58] coreycondardo: but lightswitch05 i also get what you are saying, and it???s very helpful
[03:56:13] coreycondardo: also sevenseacat i love your fix to my conditional :)
[03:56:37] lightswitch05: if you are trying to clean up your templates - you could always move it into a partial
[03:57:24] sevenseacat: oh goody, pointless overheard
[03:57:47] sevenseacat: moving it into a partial 'cleans up' nothing
[03:57:58] lightswitch05: can't partials be cached?
[03:58:19] coreycondardo: here is the update snipper from my form view
[03:58:20] coreycondardo: https://gist.github.com/coreycondardo/e8216fbddd5f1c1e36cb
[03:59:18] sevenseacat: coreycondardo: i like it. i'm not entirely sure the label would be connecting to the checkbox properly, but other than that i like it
[03:59:50] coreycondardo: when you say connecting, what do you mean?
[04:00:38] sevenseacat: the for value on the label should be the same as the name of the field, so that when you click the label, it toggles the checkbox
[04:01:01] coreycondardo: nope, doesnt work :)
[04:02:13] coreycondardo: https://gist.github.com/coreycondardo/01cf72f5f504a40603f4
[04:03:38] lightswitch05: you could do fragment cacheing for Task::HOURS
[04:04:15] sevenseacat: not when the content depends on @task.checkin_times
[04:04:38] sevenseacat: that'd give you some really frustrating caching bugs
[04:05:57] lightswitch05: sevenseacat: have much rspec knowledge? I have a problem no one seems eager to help with: https://stackoverflow.com/questions/25815741/set-header-in-rspec-3-request
[04:06:08] coreycondardo: this is probably poorly writte, in that case checkin_times has nothign to do with the instance of the task object.
[04:07:18] sevenseacat: mmm request specs, the redheaded stepchild of rspec tests
[04:07:44] lightswitch05: yeah, thats what I'm finding out
[04:09:18] sevenseacat: anything here help? http://stackoverflow.com/questions/9654465/how-to-set-request-headers-in-rspec-request-spec
[04:11:26] lightswitch05: the answers that us the `@request` var are wrong for request specs. Request specs don't have a `request` var... because that would make too much sense. The one talking about sending the header with each request works - but its the least DRY thing I can think of for authentication used in every API request
[04:11:49] coreycondardo: thank you guys sevenseacat and lightswitch05 your continued support is really great. i appreicate it :)
[04:20:54] lightswitch05: oh well - I'm going to bed. Got to do work programming in the morning - enough of this fun programming stuff
[04:21:18] sevenseacat: i know them feels
[04:21:25] sevenseacat: ACTION is doing the work programming stuff
[04:22:14] lightswitch05: maybe one day I'll be successful at merging the two
[04:22:28] sevenseacat: isnt that the great fream
[04:33:54] shortCircuit__: hia.. i am back
[04:38:44] shortCircuit__: what are hooks and stubs in rails
[04:39:23] sevenseacat: i'm guessing you mean in tests, not in rails.
[04:40:15] shortCircuit__: i actually don't have any idea .. i heard about those two words .. only thing i could find about hooks are they are associatd with callbacks
[04:41:13] sevenseacat: well you work out what you actually want to ask, then come back and ask it.
[04:43:13] shortCircuit__: could you give me some link where i can find a few thing about those to get started
[04:43:34] sevenseacat: sure. http://google.com
[04:45:04] shortCircuit__: :D i am trying that .. fine .. maybe later
[04:45:50] sevenseacat: if i dont know what you want to know, i cant help you learn it.
[04:55:02] shortCircuit__: http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html in the Group User Avatar example it says we cant do @groups.avatar << Avatar,new . is this because Avatar class doesnot have a belongs_to :group and hence no group_id in avatars table?
[04:56:51] s2013: anyone here dealt with multiple manifest files? i have a manifest file called admin.css and admin.js i have separate admin layout.. in it i included = javascript_include_tag "admin"
[04:57:00] s2013: but i get require_tree argument must be a directory
[04:57:08] s2013: i dont have require_tree cause i dont want to load the entire tree in admin.js
[05:06:06] helpa: 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.
[05:07:21] s2013: dont know how much code could help since its literally like 2 lines.. the ones i pasted but ok
[05:07:48] s2013: i wonder if its just your natural reaction to type !code or something of that nature without reading what people writes but i forgive you
[05:08:48] s2013: you arent cool enough for that cydd
[05:08:50] s2013: https://gist.github.com/ss2k/71dd95b5b42f9b658585
[05:09:15] sevenseacat: see, thats a lot more than 2 lines isnt it
[05:09:18] sevenseacat: and the error message?
[05:09:30] s2013: yeah but if i remove all that except the javascript_include_tag its the same error
[05:09:36] cydd: i just emailed a wall street guy i saw on tv a question and he asked me to call him, which is scaring me cause im awkward on the phone.
[05:09:39] s2013: require_tree argument must be a directory
[05:09:45] s2013: show upto his house cydd
[05:10:03] cydd: it's probably a mansion in the hamptons
[05:10:23] s2013: take a chopper there
[05:10:32] s2013: i know a wall street guy who lives in the hamptons
[05:10:56] Radar: Radar kicked s2013: plz
[05:11:10] s2013: i did paste the code Radar
[05:11:11] Radar: ACTION was never here
[05:11:19] s2013: and im pasting the trace
[05:11:22] Radar: s2013: there is no require_tree in your code.
[05:11:31] s2013: yeah which is what my question was regarding
[05:11:36] cydd: s2013 is new to the internet
[05:11:39] Radar: So it's probably in one of the extensions.
[05:12:16] s2013: ok i think i see it
[05:12:17] sevenseacat: which is why i asked for the full error.
[05:13:04] s2013: sorry.. its super late and im fixing someone elses bugs.. anyways hold on
[05:13:14] Radar: s2013: You know the rules and so do I.
[05:13:24] Radar: s2013: We're no strangers to debugging your code.
[05:13:31] sevenseacat: oh man, im going to have that in my head all day now
[05:13:37] s2013: have what
[05:13:45] Radar: s2013: A full stacktrace is what I'm thinking of.
[05:13:50] Radar: And I would usually get this from many other guys./
[05:13:54] s2013: no i think i found it
[05:14:00] Radar: I just want you to show me what your code is doing.
[05:14:07] Radar: You've got to make me understand.
[05:14:16] sevenseacat: i am literally laughing out loud
[05:14:22] s2013: literally?
[05:14:33] Radar: I'm never going to give it up. I'm never going to let you down. I'm never going to run around and debug your code unless you post all of it.
[05:14:43] Radar: I'm never going to make you cry.
[05:14:47] Radar: I'm never going to say goodbye.
[05:14:57] s2013: Radar, its ok im coming to melbourne so you never have to
[05:14:59] s2013: Radar Astley
[05:15:25] Radar: ACTION bows
[05:17:36] shortCircuit__: what is happening!! :O
[05:17:40] s2013: we are singing
[05:17:59] s2013: hows work Radar
[05:18:10] Radar: why are you coming to Melbourne?
[05:18:19] s2013: to be your protege
[05:18:32] s2013: nah im not.. not soon anyways but maybe next year
[05:19:28] s2013: oh ok now it works.. damn man. i spent like 30 minutes on this stupid thing..
[05:19:35] sevenseacat: for rubyconf in february???
[05:19:35] s2013: maybe i need to sleep
[05:19:43] s2013: is rubyconf in melbourne?
[05:19:46] s2013: i thought it was in san diego
[05:19:52] s2013: or is there a separate one for you down under folks
[05:19:53] Radar: Rubyconf AU is in Melbourne
[05:19:54] sevenseacat: rubyconf au -_-
[05:20:02] s2013: oh thats not the real one
[05:20:07] s2013: are you going sevenseacat ?
[05:20:11] sevenseacat: ACTION punches s2013
[05:20:23] s2013: i might go to the one in san diego though
[05:20:25] sevenseacat: saying we're not real, gtfo
[05:20:31] shortCircuit__: http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html "destroy is called (by overwriting before_destroy) or to massage attributes before they're validated (by overwriting before_validation)" massage?? wth
[05:20:45] s2013: yeah you gotta relax the attributes shortCircuit__
[05:20:48] Radar: shortCircuit__: yes, mainly shoulder rubbing
[05:20:55] s2013: its the new rails way
[05:21:09] s2013: maybe if i can get my company to pay for it i might go
[05:21:12] s2013: is there a railsconf au?
[05:22:18] s2013: Radar, start one
[05:22:29] s2013: you could be the down under dhh. dudhh
[05:23:17] s2013: i was wearing my railsconf tshirt today. seems like yesterday
[05:25:03] sevenseacat: i dont wear my rubyconf shirt often.... bright red close-fitting shirt and hot weather is a bad combination.
[05:25:21] s2013: man dont talk about hot weather
[05:25:23] s2013: im in texas now
[05:25:41] s2013: surprisingly it was cool this weekend.. but generally it feels like you are in an oven
[05:25:57] sevenseacat: hell, i wear the envato tshirt i picked up, more often than my rubyconf shirt >_>
[05:26:19] s2013: is it black and green?
[05:26:36] sevenseacat: no, dark blue
[05:26:46] s2013: my favorite shirt is a shirt that says worlds greatest redneck on it
[05:28:54] sevenseacat: my favorite shirts are probably all the band tshirts i wear
[05:29:56] s2013: wideband?
[05:30:18] s2013: i actually dont have any band tshirts. maybe i should get some.. mine ar emostly sports related
[05:31:02] sevenseacat: i've just picked them up from concerts ive been to
[05:31:27] s2013: yeah i never bought them.. i should.. whats your favorite band
[05:32:15] sevenseacat: of all time? iron maiden
[05:32:37] s2013: i cant decide between backstreet boys or nsync
[05:35:15] sevenseacat: my taste in music http://www.last.fm/user/karpie
[05:35:55] s2013: sounds dangerous
[05:36:08] s2013: ive been composing more lately
[05:39:09] s2013: https://www.youtube.com/watch?v=JzIK5FaC38w probably my favorite band sevenseacat
[05:53:41] waseem_: s2013: It's good.
[05:55:36] s2013: thanks waseem_
[06:06:29] shortCircuit__: if User belongs_to Group and Group has_many Users , then would setting counter_cache: true help to find the number of members in a group?
[06:07:10] sevenseacat: yes, because the number would be stored as part of the Group model.
[06:11:12] shortCircuit__: umm.. the column name would be group_count (as per the example in the guides) , so wouldnot that be no. of groups an user is in?
[06:11:44] sevenseacat: well no, if a user belongs to a group, by definition he is only in one
[06:11:57] sevenseacat: a counter cache would be the other way, users_count on a Group
[06:12:39] waseem_: shortCircuit__: Will a user always be in _only_ one group?
[06:13:03] sevenseacat: then your associations are a big naffed
[06:13:05] waseem_: shortCircuit__: You need to think over your associations then.
[06:14:06] shortCircuit__: brb ... need to shut down
[06:29:42] shortCircuit__: why can't i see any messages before i post one
[06:31:00] rvanlieshout: shortCircuit__: ?
[06:31:13] sevenseacat: because no-one posted one?
[07:00:29] klay: I need help
[07:02:52] klay: I changed adapter from SQLite3 on PostgreSQL. Launched deploy - all ok, Capistrano's deploy scenario runs rake db:migrate - all ok, but server not working :(
[07:03:15] klay: I received http://vpaste.net/y8nud
[07:03:15] shortCircuit__: i have to clarify a few things. i has messed up
[07:03:25] helpa: What "didn't work"? Did your server not start? Did your computer explode? Did your webpage turn bright pink? Did your client not pay your bill on time? You may have to be more specific. A Gist (http://gist.github.com) of the code that doesn't work (and the error you are getting) will be helpful.
[07:03:46] rvanlieshout: klay: what part of that error is unclear to you?
[07:03:58] klay: rvanlieshout: http://vpaste.net/dPiBI
[07:04:05] klay: rvanlieshout: http://vpaste.net/0xEiA
[07:04:23] klay: ^ this is on current release on production
[07:04:27] rvanlieshout: you've restarted unicorn?
[07:04:41] shortCircuit__: https://gist.github.com/aghosh47/3b76f2b25134ec039a87 in here ... what would i loose, i omitted the through: :users in the Group class
[07:06:00] rvanlieshout: klay: what if you run a rails server manually? (e.g. RAILS_ENV=production bundle exec rails server)
[07:08:31] klay: rvanlieshout: in console ok, but how i can test it in browser? just typing url?
[07:08:38] klay: rvanlieshout: before I started working with a database - everything worked perfectly
[07:08:49] rvanlieshout: with the port number attached to that url
[07:10:32] klay: but why does not work in a normal state?
[07:11:06] rvanlieshout: because your unicorn wasn't restared properly i assume
[07:12:51] rvanlieshout: shortCircuit__: you can figure this out
[07:13:33] klay: rvanlieshout: Excuse me, I'm a newbie. Maybe I should show you what the configuration files? my unicorn files https://github.com/sergeyklay/persona/blob/master/config/unicorn.rb
[07:13:46] klay: rvanlieshout: and https://github.com/sergeyklay/persona/blob/master/config/unicorn_init.sh
[07:13:56] rvanlieshout: klay: stop unicorn and verify that it has been stopped
[07:14:32] shortCircuit__: is writing a belongs_to on the other side of has_many mandatory?
[07:14:55] helpa: shortCircuit__: Why don't you try it and find out for yourself?
[07:14:55] rvanlieshout: shortCircuit__: !try
[07:16:08] klay: rvanlieshout: http://vpaste.net/51RPF Hm, but server still available
[07:16:20] klay: rv http://klay.me/
[07:16:40] rvanlieshout: klay: then something else is serving that
[07:16:49] rvanlieshout: and than it makes sense that restarting unicorn doesn't matter
[07:16:54] rvanlieshout: lsof -i tcp:80
[07:18:28] daryllxd: Hello all, QQ, is it advisable to test ActiveRecord relations and validations? things like User.should have_many posts and User.should_validate_presence_of :first_name
[07:18:57] sevenseacat: they're one liners, why not?
[07:19:28] klay: rvanlieshout: i stop nginx http://vpaste.net/Zjb1W but server still available
[07:19:28] daryllxd: one of the other devs says it is overtesting/unnecessary since we're testing Rails
[07:19:34] daryllxd: functionality.
[07:19:41] sevenseacat: you're not testing rails, you're testing that you're using rails as you intend
[07:20:48] tmoore: klay: your stack trace shows gems loaded from /var/www/persona/shared/bundle but your `bundle show pg` shows it installed in /home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems
[07:23:34] klay: I have gone to the server by IP address. This time browser reported - 404. Then I run unicorn and nginx all began to work by IP and URL! what is it?
[07:24:52] klay: rvanlieshout: how do disable this ugly caching
[07:25:13] rvanlieshout: that was an assumption though
[07:26:56] shortCircuit__: ok, so through open the gates to JOINS ..
[07:29:30] rvanlieshout: somewhat like that
[07:33:04] shortCircuit__: o, if there were no through Group.first.avatars would find avatars.group_id instead of avatars.user_id .. now, iff there is a PK - FK betwen tables, only then we can write has_many/one and belongs_to .. and we cannot do Group.first.avatar << Avatar.new would fail .. because there is no group_id in avatars
[07:37:41] shortCircuit__: so in the last case why not use a JOIN ?
[07:37:58] shortCircuit__: although the question is awful
[07:38:03] sevenseacat: you're not wrong
[07:38:14] sevenseacat: on that last point
[07:38:39] wpp: Happy Monday! I
[07:38:50] shortCircuit__: o sorry, i gorgot to save the file
[07:39:29] rvanlieshout: and know that rails tries to use a separate query over a left join
[07:39:40] shortCircuit__: its because the user_id is not set
[07:39:50] KarateMonkey: I am trying to follow the example here - http://guides.rubyonrails.org/plugins.html - I am having a problem at the end of section 3 when executing "rails console". It brings up the help for the rails command instead of loading the console. I am on Rails 3 and not 4, not sure if that makes a difference. How to get a console to fiddle around with the library's methods? Rails server and console work fine for regular non-plugin rails p
[07:39:55] shortCircuit__: yes i am seeing that in the console
[07:40:42] shortCircuit__: no i am still wrong
[07:40:48] shortCircuit__: ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection: Cannot modify association 'Group#avatars' because the source reflection class 'Avatar' is associated to 'User' via :has_one. this is the error
[07:40:55] wpp: I'm trying to put a RestClient request into delayed job, obviously it doesnt work :) I'm calling conversion.delay.start! and start! just raises an ArgumentError (for testing) But the job runs, aka the row is deleted from delayed_jobs and no last_error is written. Can someone help?
[07:42:00] shortCircuit__: now this Reflection is a new thing
[07:42:03] klay: rvanlieshout: tanks
[07:43:41] wpp: here is a gist https://gist.github.com/wpp/cf8a2b4ccecf5aa8a130
[07:44:25] wpp: I script/delayed_job restarted the thing with the same result.
[07:45:37] shortCircuit__: http://apidock.com/rails/ActiveRecord/HasManyThroughCantAssociateThroughHasOneOrManyReflection :
[07:46:02] sevenseacat: shortCircuit__: you wanna break down exactly what you're trying to do?
[07:47:23] shortCircuit__: i am trying to understand how the assocciation works... and why in the rails api it says "@group.avatars << Avatar.new # this would work if User belonged_to Avatar rather than the other way around"
[07:47:45] sevenseacat: okay i see a group and an avatar there
[07:49:50] wpp: AAHHH I got it!
[07:50:04] wpp: The problem is: delayed_job deletes failed_jobs by default
[07:50:36] wpp: so after x attempts (if failed or success) the row (job) gets deleted anyway
[07:50:39] wpp: This can be fixed by configuring delayed_job to not do that :)
[07:51:00] shortCircuit__: yes, the only link between the Group and Avatar is user .. like in the previous case when i did Group.first.avatars , rails fired a JOIN query trying to find the avatars.user_id = groups.user_id .. but why can't then a new avatar be created.. because the user_id is unknown?
[07:51:23] sevenseacat: no seriously, if you're going to start talking about all these things, you better show some code
[07:51:54] shortCircuit__: i posted a gist .. i will post the codes i am executing ..
[07:51:59] sevenseacat: i also think you're drastically overcomplicating these concepts
[07:52:02] sevenseacat: where is the gist
[07:56:30] shortCircuit__: https://gist.github.com/aghosh47/3b76f2b25134ec039a87 here
[07:57:15] sevenseacat: https://gist.github.com/aghosh47/3b76f2b25134ec039a87#file-gistfile3-rb-L10 not fine
[07:57:39] sevenseacat: no seriously wtf is with this code
[07:57:48] sevenseacat: you cant call @user.create and get an avatar
[07:58:39] sevenseacat: and you cant add an avatar like that because an avatar is only connected to a group through a user
[07:58:47] sevenseacat: therefore you need the user in the middle
[08:00:34] shortCircuit__: user has_one :avatar .. and my avatar has user_id .. is my migration wrong?
[08:00:57] shortCircuit__: wait i made a few mistakes
[08:01:15] Radar: so yes you did make some mistakes :P
[08:03:40] shortCircuit__: updated https://gist.github.com/aghosh47/3b76f2b25134ec039a87
[08:04:13] shortCircuit__: Radar: my bad i am a terrible learner
[08:10:34] _lazarevsky: I would like to send an http GET request programatically and also send a parameter through called balls
[08:10:36] _lazarevsky: how can I do that?
[08:10:49] rvanlieshout: _lazarevsky: !g ruby HTTP get request
[08:13:09] shortCircuit__: sevenseacat: am i still wrong? the migration is wrong?
[08:14:12] wpp: Unbelievable, whole friday afternoon wasted, spent 20 mins on it monday morning -> done. sleep and rest is underrated
[08:17:44] defswork: wpp - not when you've had kids its not
[08:18:27] wpp: defswork I can only imagine.
[08:24:33] wpp: anybody have experience with live-streaming (server-sent events)?
[08:24:57] shortCircuit__: can this be less difficult
[08:26:54] shortCircuit__: how ..its not that i am not reading ...
[08:28:22] rvanlieshout: are you reading what you code precise enough?
[08:29:31] shortCircuit__: that is where i am trying to improve
[08:29:59] shortCircuit__: achieving that would be 60% of the job
[08:30:28] rvanlieshout: you have to understand every peace of code you write
[08:30:32] rvanlieshout: and it's not all magic
[08:30:37] rvanlieshout: it's not even a bit of magic
[08:30:47] defswork: I understand all the code I write today
[08:30:58] defswork: it's when I look at it tomorrow I have problems
[08:31:40] vasilakisfil: hello! In activemodel serializers is there any option for has_many to rename the association key ? like has_many :association, as: different_name
[08:32:30] defswork: vasilakisfil, has_many :association_name, class_name:
[08:32:35] folippi: I have a model Invoice. In it's after_initialize it's supposed to http GET an invoice id from another server (already does). I want to save the invoice_id in the Invoice objects AND in it's table in the database (ActiveRecord as usual). But I can't for the life of me figure out how to in the initialize write something to the database AND have it saved permanently. Sorry for being such a noob, but how do you do that?
[08:32:56] defswork: you have a model that does a GET ?
[08:33:16] rvanlieshout: vasilakisfil: http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-has_many
[08:34:54] defswork: vasilakisfil, you are from the off defining the association name - the default is to derive the class name from the association name but you can specify it if your association has a non-default name
[08:35:32] folippi: defswork: well, yeah it needs to get an sring "id" from a remote server, so in the initialization it does a get. But I can't figure out how to save that to the database
[08:35:48] defswork: I'd pour petrol on it now
[08:36:16] defswork: you need something higher up that does that kind of thing
[08:37:57] vasilakisfil: rvanlieshout and defswork did you see that I was asking about activemodel serializers and not for activerecord associations ?
[08:38:34] _lazarevsky: rvanlieshout: I keep getting Errno::ECONNREFUSED: Connection refused - connect(2)
[08:38:45] folippi: defswork: Ok, petrol is pouring, I'll make it work first and then light it on fire (make it proper). How can you change a property of a model from itself, and save it to the DB?
[08:39:06] defswork: folippi, self.something = whatever ; self.save
[08:39:33] defswork: (Self is optional as it's the current scope anyway)
[08:39:51] shortCircuit__: when i write a through what should i say to myself, i mean how should i interpret it ... like class Author has_many :comments , through: :posts , i would interpret it as? umm.. comments should have a post_id ... i don't know .. :( :(
[08:39:54] _lazarevsky: rvanlieshout: uri = URI('http://lazarevs-1.desktop.company-name.com/ping:3000') -> Net::HTTP.get(uri)
[08:40:11] _lazarevsky: rvanlieshout: I can't explain what I'm doing wrong. When I access the same url through the browser all is well
[08:40:36] _lazarevsky: the url is behind a VPN so you can't access it unfortunately
[08:42:56] mauro1254: Hi guys, I'm working on a rails 4.1.6 app and I handle exception the way explained here: http://blog.plataformatec.com.br/2012/01/my-five-favorite-hidden-features-in-rails-3-2 [3. Flexible exception handling]
[08:43:35] mauro1254: How can I use the same way to rescue from ActionController::InvalidAuthenticityToken
[08:44:46] defswork: mauro1254, I just handle it in my base controller that all controllers inherit from
[08:45:32] mauro1254: defswork: following the guide, I hadded match '/422', to: 'errors#change_rejected', via: :all to routes.rb
[08:46:06] mauro1254: But... If I simulated a request with a wrong authenticity token it doesn't work.
[08:46:53] mauro1254: In application_controller.rb I have protect_from_forgery with: :exception
[08:47:56] mauro1254: Do I need to add something else in order to let errors_controller (action: change_rejected) to handle the exception?
[08:48:49] shortCircuit__: i am about to blast..
[08:49:04] shortCircuit__: class Author < ActiveRecord::Base
[08:49:06] shortCircuit__: has_many :posts
[08:49:07] shortCircuit__: has_many :comments, through: :posts
[08:49:09] shortCircuit__: has_many :commenters, through: :comments
[08:49:12] shortCircuit__: class Post < ActiveRecord::Base
[08:49:13] shortCircuit__: has_many :comments
[08:49:16] shortCircuit__: class Comment < ActiveRecord::Base
[08:49:18] shortCircuit__: belongs_to :commenter
[08:49:27] defswork: you're gonna get kb'd in a second
[08:50:32] defswork: mauro1254, I've no idea why you are trying to do that when a straightforward exception handler work
[08:50:41] defswork: kick banned
[08:56:27] mauro1254: I handle 404 & 500 exceptions using a controller, as specified at the link posted... I would like to handle InvalidAuthenticityToken the same way ...
[08:56:40] rvanlieshout: shortCircuit__: what's the problem?
[08:56:46] dazonic: Payment model, amount column is a decimal??? why do I need to convert to array or risk getting whack values when I convert to float?
[08:57:04] liquid-silence: any suggestions for software to manage multiple projects
[08:57:30] shortCircuit__: rvanlieshout: i have made a little inference of how the associations would be.. please tell me how much right/wrong i am
[08:58:24] shortCircuit__: ok, has_many :posts , which means their is a posts table.. and an author_id in it, then there is has many :comments , through: :posts, which means posts table has a comment_id and and comments table should have a author_id which it would get from the posts table
[08:58:28] dazonic: @payments.sum(:amount) == 2128; @payments.to_a.sum(&:amount) == 1832
[08:58:56] rvanlieshout: shortCircuit__: it means you access comments through posts
[08:59:06] rvanlieshout: so not .comments, but .posts -> .comments
[09:00:29] shortCircuit__: and then similarly for commenters , it first access the comments table and thn the posts table
[09:02:55] shortCircuit__: so Author.first.commenters it would JOIN commenters.comment_id to comments.id and then then posts.comment_id = comments.id and get the corresponding posts.author_id ??
[09:03:25] Wolland_: dazonic: what do you get with @payments.map(&:amount).sum
[09:04:38] dazonic: @Wolland_ 1832, the correct value
[09:04:43] rvanlieshout: shortCircuit__: forget about that sql conversion for now
[09:04:46] rvanlieshout: thikn in models
[09:07:12] dazonic: @Wolland_ column is a decimal
[09:08:15] Wolland_: first line is doing this: @payments.inject(0) { |sum, p| sum + p.amount }
[09:08:21] Wolland_: and you are getting wrong value?
[09:08:52] Wolland_: that's equivalent of @payments.sum(:amount)
[09:12:27] Wolland_: is 2182 by any chance = 1832 + value of the first amount?
[09:19:46] moviendo_: join #ruby-lng
[09:22:01] Wolland_: whats wrong with #ruby
[09:23:36] liquid-silence: defswork I have been looking at redmine but I am not sold on it
[09:24:06] defswork: liquid-silence, redmine is ace - it does everything
[09:24:21] liquid-silence: yeah, I'm looking at Jira currently
[09:24:29] defswork: even repo integration
[09:24:34] Lauer: I use both redmine and jira
[09:24:46] Lauer: Jira just seems to big sometimes
[09:24:55] Lauer: redmine with right plugins are simple and stable
[09:25:01] Lauer: ... and free :)
[09:25:37] defswork: redmine is also a great place to look at great coding
[09:26:21] Wolland_: whatever that means
[09:28:46] shortCircuit__: ok .. was having lunch
[09:30:47] shortCircuit__: is there a way to generate two models in one rails g command?
[09:31:14] Wolland_: sadly redmine looks the same as 3 years ago. why is it so ugly.
[09:32:26] rvanlieshout: shortCircuit__: no
[09:33:25] rvanlieshout: nobody cares imo
[09:33:28] shortCircuit__: i believe you :)
[09:35:18] rvanlieshout: there is no issue in running it twice
[09:35:23] rvanlieshout: or create the model files yourself
[09:35:51] Wolland_: or && commands
[09:37:10] shortCircuit__: but creating model files and a separate migration is good, there are a lot of create_tables migration being generated..
[09:42:12] mityaz: currently I have in my index view the following: if current_user.bla1? then render 'blab', render'bla2'... else render '..'
[09:42:21] mityaz: is their a cleaner solution for this?
[09:42:43] mityaz: should I use separate controller for each user type? or I better use Presenters?
[09:43:54] masscrx: I would like to make possibility in rails app to change view (columns in table) per user, what should I look for ?
[09:49:41] defswork: masscrx, you might be able to write a computer program to do that
[09:50:28] masscrx: defswork: ?
[09:51:06] masscrx: where you are finding such cool jokes ?
[09:53:17] shortCircuit__: has_many :jokes, as: :trollable
[09:54:21] awestroke: masscrx: what do you mean by "change view"?
[09:55:21] _lazarevsky: mikecmpbll: ping!
[09:55:37] _lazarevsky: I need help guys
[09:55:47] _lazarevsky: anyone here comfortable with the Net:HTTP lib?
[09:55:53] masscrx: awestroke: I descripe scenario, so user login to the app, and have table with columns which can change (ex. columns order) or add new column, and this view is saving dynamicaly (after each change of user)
[09:55:54] awestroke: _lazarevsky: I think I've used it
[09:56:02] _lazarevsky: awestroke: great
[09:56:27] awestroke: masscrx: so users should be able to change the database schema from the browser?
[09:56:29] _lazarevsky: awestroke: I am trying to access a url which behind our company's VPN
[09:56:30] masscrx: my question is related to some js library by maybe some user here has knowledge how to design it
[09:56:38] masscrx: awestroke: nope, only view
[09:56:53] _lazarevsky: awestroke: I keep getting Errno::ECONNREFUSED: Connection refused - connect(2)
[09:56:58] awestroke: masscrx: why?
[09:57:08] _lazarevsky: awestroke: I can't even behind to think where to start debugging
[09:57:28] awestroke: _lazarevsky: do you know which line is throwing that?
[09:57:59] Macaveli: When does the patching for rails 3 stop?
[09:58:00] _lazarevsky: ruby1.9/1.9.1/net/protocol.rb:141:in `read_nonblock'
[09:58:10] _lazarevsky: awestroke: ruby1.9/1.9.1/net/protocol.rb:141:in `read_nonblock'
[09:58:40] masscrx: awestroke: because my client's user A want to have table with columns in this order: COLUMN_A, COLUMN_B, COLUMN_C, but another user wants to have : COLUMN_A, COLUMN_C, COLUMN_B and another only two columns: COLUMN_A, COLUMN_B
[09:59:38] masscrx: so I think that I need to implement some gem for 'config' per user but what next
[09:59:41] ests: _lazarevsky have you tried to make a similar request, f.i. using `curl` just to test if it works?
[10:00:43] awestroke: masscrx: why not just show the columns in different orders in your view.html.haml/erb/slim instead of mucking around the database
[10:00:44] _lazarevsky: ests: curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
[10:01:02] awestroke: _lazarevsky: try to find the first line in the stack trace that has your filename in it
[10:01:16] masscrx: awestroke: one more time, I dont want to touch db, only view
[10:01:32] awestroke: masscrx: so you're not talking about sql views?
[10:01:38] masscrx: awestroke: no
[10:01:51] masscrx: about rails views
[10:02:10] _lazarevsky: ests: maybe I should set the use_ssl flag to true before making the request aye
[10:03:23] ests: masscrx so how do you want to store per users settings?
[10:03:28] awestroke: masscrx: you could have a text column on your User model that serializes. then put a hash there in the form of {:columns => [:column_a, :column_c]}
[10:04:13] masscrx: ests: settings will be stored in db
[10:05:36] masscrx: awestroke: so maybe make another table for settings, and there keep all data, ok some idea is creating in my head ;]
[10:05:37] pduersteler: hi all. I'm trying to hide a loading indicator when a remote form receives results / the request is finished, however, I can't seem to find the right event to bind to, or have something else wrong. https://gist.github.com/pduersteler/b20b6b91b449923d35be any ideas?
[10:05:51] ests: _lazarevsky also try curl with option --insecure
[10:05:52] mikecmpbll: _lazarevsky: looks like it can't verify the SSL cert
[10:07:31] _lazarevsky: mikecmpbll: ests: says "document has moved
[10:08:03] _lazarevsky: mikecmpbll: ests: <html><head> <title>302 Found</title> </head><body> <h1>Found</h1>
[10:08:24] _lazarevsky: <p>The document has moved <a href="https..........</p>
[10:08:32] mikecmpbll: 302 is redirect.
[10:08:39] _lazarevsky: the page i'm request is a load balancer
[10:08:56] awestroke: pduersteler: I think remote forms use jquery-ujs
[10:08:59] _lazarevsky: it delegates requests to one of the two production servers
[10:09:14] _lazarevsky: mikecmpbll: so not too sure how to proceed :/
[10:09:19] ests: _lazarevsky so, http.use_ssl = true
[10:09:32] _lazarevsky: ests: kk let me try that
[10:09:45] mikecmpbll: if curl can't verify the cert, i doubt net/http will be able to
[10:09:53] ests: _lazarevsky and http.verify_mode = OpenSSL::SSL::VERIFY_NONE
[10:10:04] mikecmpbll: ^terrible advice.
[10:10:07] ests: _lazarevsky but don't use it in prod ;)
[10:10:34] _lazarevsky: what else is there left to do
[10:10:38] ests: _lazarevsky just for testing purposes
[10:10:42] mikecmpbll: figure out what's wrong with their SSL
[10:10:55] _lazarevsky: dude.. this is internal SSL
[10:11:31] pduersteler: awestroke: AFAIK jquery-ujs does fire ajax:* events, at least the js source says so
[10:11:52] awestroke: _lazarevsky: you should be able to set the internal CA as trusted in some way, importing it or something
[10:12:05] _lazarevsky: mikecmpbll: ests, @mike you were right
[10:12:05] awestroke: pduersteler: it might only fire it on the form element though
[10:12:50] pduersteler: awestroke: aah, okay, that could be..
[10:14:09] _lazarevsky: mikecmpbll: ests: uri = URI.parse("https://internal.website.com") -> http_request = Net::HTTP.new(uri.host, uri.port) -> http_request.use_ssl = true -> http_request.verify_mode = OpenSSL::SSL::VERIFY_NONE -> http_response = http_request.get(uri.request_uri) ===> => #<Net::HTTPFound 302 Found readbody=true>
[10:14:39] mikecmpbll: yes. the URL you're getting is returning a redirect.
[10:14:50] _lazarevsky: how come the request is not forwarded?
[10:15:13] awestroke: _lazarevsky: there might be a follow_redirects flag for the net::http request object
[10:15:52] mikecmpbll: you can always follow the redirect manually by getting the 'location' response header.
[10:16:24] _lazarevsky: ok so I can say while the retStatus is HTTP::Redirector (302) then follow the redirect?
[10:16:41] _lazarevsky: awestroke: there is not such flag.. thanks for the suggestion though
[10:16:51] ests: _lazarevsky maybe check out this http://stackoverflow.com/a/6934503/409475
[10:16:55] mikecmpbll: sure, something like that, i don't know about the response classes much
[10:17:45] mikecmpbll: or use a decent http library, rather than net/http
[10:18:12] _lazarevsky: mikecmpbll: it's not as easy
[10:18:14] awestroke: like mechanize or httparty
[10:18:19] _lazarevsky: this is a script which will be called from a cronjob
[10:18:20] mikecmpbll: what's not as easy?
[10:18:28] ests: _lazarevsky https://github.com/markets/awesome-ruby#http
[10:18:29] _lazarevsky: I wanna keep this as minimal as possible
[10:18:59] _lazarevsky: ests: so I should use fetch instead of get aye?
[10:19:51] ests: _lazarevsky the #fetch is just a name of the custom function that user proposed
[10:20:35] ests: _lazarevsky I don't know if this works, I usually use Farraday or econ
[10:27:30] nettoweb: guys, I have a forum app that my topics has_many anwers, but how i can show topics with no answer? need I a join?
[10:29:00] rvanlieshout: Topic.includes(:answers).where(answers: { id: nil })
[10:30:22] mikecmpbll: + .references(:answers) probably :p
[10:33:18] mikecmpbll: i tend to just use eager_load(:answers) because the includes + references verbosity annoys me.
[10:36:25] shortCircuit__: so that now i understand associations better than my previous state, i am left with ... query interface callbacks ..i read about stale object tho ...
[10:43:27] _lazarevsky: mikecmpbll: ests: I just wanted to let you know that I got it working
[10:43:35] mikecmpbll: _lazarevsky: good lad.
[10:43:38] _lazarevsky: ests: that script you gave me.. I slighty motified it, but it works beautifully
[10:43:40] _lazarevsky: thanks so much guys :)
[10:43:43] ests: _lazarevsky cool, cheers
[10:47:42] nettoweb: rvanlieshout I got this error trying that https://gist.github.com/osnysantos/d75052081314ab4db672#file-gistfile1-txt
[10:53:10] wpp: here comes a stupid question: If I want to save a timestamp (unix epoch) in a column, what datatype should I store it in?
[10:54:40] wpp: int should be fine right?
[10:54:59] wpp: (unsigned)
[10:57:29] zeff: why do you need the integer epoch value? your database will store the timestamp in an efficient byte form, and then you get all the benefits of the ruby date object when interacting with it
[10:59:45] zeff: but to answer your question, wpp, yes an unsigned integer works fine if you think you wont need dates before the epoch
[11:01:07] zeff: wait i'm wrong, it might not be large enough
[11:01:53] zeff: unsigned int is 4 bytes, ruby stores the time as 8 bytes: http://www.ruby-doc.org/core-2.1.2/Time.html
[11:03:12] zeff: wpp: if the database you're using can handle something like a "Long", then use that, otherwise add some function that converts it to a string on save, and into a number on load
[11:05:30] wpp: zeff sorry for not replying earlier, got myself a coffee. Yeah I shoul've been clearer, my orignal idea was to time.to_i.to_s and store that value in the database, now I'm thinking why not use :datetime in the migration?
[11:05:53] zeff: wpp: exactly :)
[11:06:26] wpp: zeff :)
[11:06:54] wpp: zeff do you happen to know though, if I you :datetime in the migration (mysql) will it be stored as date, datetime or timestamp?
[11:07:24] wpp: datetime probably
[11:07:47] wpp: zeff yeah nvm :) thanks anywho!
[11:07:50] zeff: http://stackoverflow.com/questions/409286/datetime-vs-timestamp
[11:09:25] Macaveli: Anyone know when the Rails 3 support ends? I can't find it online
[11:11:43] DaniG2k: so, Ive added a new secret to my secrets.yml file
[11:11:47] DaniG2k: restart the console
[11:11:53] DaniG2k: (making sure its in development mode)
[11:12:04] DaniG2k: and it's nowhere to be found in Rails.application.secrets
[11:12:06] wpp: Macaveli http://weblog.rubyonrails.org/2013/2/24/maintenance-policy-for-ruby-on-rails/
[11:14:15] Macaveli: wpp there is not date when the support ends
[11:15:11] Macaveli: "Only the latest release series will receive bug fixes. When enough bugs are fixed and its deemed worthy to release a new gem, this is the branch it happens from."
[11:15:16] wpp: Macaveli well I don't think there is a date for rails 5 release yet, but whenever that hits "The current release series and the next most recent one will receive patches and new versions in case of a security issue."
[11:15:51] wpp: Macaveli yeah so it depends on the release of rails 5 (probably at railscon?)
[11:16:48] Macaveli: So when do you suggest upgrading to rails 4, I need to find a good reason to convince the management of making the investment to upgrade to rails 4
[11:17:23] zeff: wait until 4.2
[11:17:51] wpp: zeff howcome?
[11:18:21] zeff: it has barely enough changes to the "rails way" of doing things that you might as well wait
[11:18:29] zeff: like activejob, configuration stuff, etc
[11:20:48] wpp: Macaveli I upgraded from 3.2.18 to 4 in july or so and it was pretty painful to be honest. (but also my first major upgrade because I started with rails 3)
[11:21:13] Macaveli: I will plan it as soon as possible
[11:21:17] Macaveli: i hate upgrading
[11:21:27] wpp: Macaveli but zeff makes a good point, you might want to go straight for 4.2
[11:21:38] wpp: Macaveli yes upgrading is a little iffy
[11:22:06] wpp: Macaveli but its also the point where good test coverage pays off
[11:22:17] Macaveli: i'm not testing :/
[11:22:39] wpp: Macaveli but its also the point where good test coverage WOULD pay off :)
[11:23:13] Macaveli: How can you estimate an upgrade to rails 4?
[11:23:31] Macaveli: It will probally take me 2 weeks or more of frustration
[11:25:34] zeff: Macaveli: the first thing to do is go over every gem you're using and check it's compatibility with rails 4
[11:25:53] zeff: then check out the upgrade guides and modify any code that has variations in it
[11:26:16] Macaveli: i'm going to be so fucked with ckeditor
[11:26:23] zeff: and also clean up the inevitable straggler and hack code left around
[11:26:55] wpp: Macaveli another suggestion: for the 4 upgrade there is a book available (I guess for free by now) from andy lindemann
[11:26:55] wpp: http://upgradingtorails4.com/ i think
[11:26:55] wpp: Macaveli depends on the size of your application etc. It's not a hard science though.
[11:28:31] Macaveli: Will If somethings doesn't work it will throw an error probaly
[11:29:05] Macaveli: This is going to be the hardest bit wpp (I've created the topic) http://stackoverflow.com/questions/25198463/upgrading-attr-accessible-from-rails-3-to-rails-4
[11:29:28] wpp: Macaveli nah was not that big of a deal if you just you attr_accessible gem
[11:29:48] wpp: Macaveli honestly checkout that ugprading book I think its free and goes step by step
[11:29:54] wpp: Macaveli It is well worth it
[11:30:05] Macaveli: alright thanks
[11:30:09] Macaveli: i'll download it!
[11:30:19] Macaveli: to my new ereader
[11:30:27] Macaveli: man that's an awesome toy, well worth the money
[11:33:48] shortCircuit__: when is left outer join fired? in includes() queries?
[11:37:38] basldex: can I access my app's class from within an engine? I need to change its eager_load_paths
[11:39:39] basldex: without knowing its name of course
[11:41:49] DaniG2k: im writing a mailer for a contact form. If the form was invalid, instead of re-rendering the whole page, is there a way to just render the contact form part again?
[11:42:04] DaniG2k: or like, use javascript to scroll to the bottom of the page (where the contact form is?)
[11:42:45] DaniG2k: otherwise the whole page gets re-rendered and the user finds himself at the top of the page when teh contact form is at the bottom
[11:46:53] basldex: appearently it's Rails.application
[11:48:44] zeff: DaniG2k: use validation in javascript to notify any errors in input
[11:49:22] DaniG2k: zeff: I think I found what I'm looking for: http://stackoverflow.com/questions/2068887/rails-render-action-to-target-anchor-tag
[11:49:27] DaniG2k: only problem is I can't get it to work :P
[11:49:39] DaniG2k: I have <%= form_tag(send_mail_path, :id => 'cform', :name => "cform", :anchor => 'form') do %>
[11:49:59] DaniG2k: and if the form is not valid then I do
[11:50:04] DaniG2k: render :action => "home#form"
[11:50:11] DaniG2k: unfortunately, this doesnt work :P
[11:50:23] DaniG2k: the error message is Missing template index/home#form
[11:52:01] zeff: try render :action => "home", :anchor => "form"
[11:52:11] DaniG2k: doing that right now
[11:52:52] DaniG2k: it doesnt go to the bottom of the page :(
[11:54:14] DaniG2k: maybe i need to use javascript
[11:54:45] zeff: when you use the form helper with anchor attribute did you check the source and make sure it posts to the action with the anchor?
[11:55:28] DaniG2k: zeff: yes the code for the form looks like:
[11:55:33] DaniG2k: <form id="cform" name="cform" method="post" anchor="theForm" action="/en/send_mail" accept-charset="UTF-8">
[11:55:46] zeff: ok so anchor is then an html attribute
[11:55:49] DaniG2k: and I try going there with render :action => "home", :anchor => 'theForm'
[11:55:56] zeff: what you want is action="/eb/send_mail#theForm"
[11:56:17] DaniG2k: I'm generating the form code with this:
[11:56:17] DaniG2k: form_tag(send_mail_path, :id => 'cform', :name => "cform", :anchor => 'theForm')
[11:58:09] zeff: try this: <%= form_tag(send_mail_path + '#theForm', :id => 'cform', :name => "cform") do %>
[11:58:12] DaniG2k: hmm no it doesnt work even if I put form_tag '/en/send_mail#theForm'
[11:58:57] DaniG2k: still goes to the top of the apge
[11:59:30] zeff: try doing #cform as the name
[11:59:34] zeff: sorry anchor
[11:59:48] zeff: <%= form_tag(send_mail_path + 'cform', :id => 'cform', :name => "cform", :anchor => 'form') do %>
[11:59:54] zeff: you have cform as the name attribute
[11:59:57] zeff: so the anchor has to go to that
[12:00:27] DaniG2k: that worked!! :D
[12:00:34] DaniG2k: zeff: thanks! :D
[12:00:41] zeff: no problemo
[12:00:48] Macaveli: @mikecmpbll In relation to this So http://stackoverflow.com/questions/25184295/managing-large-scale-apps-via-rails you answered. How do you size Different CSS styles , the code I can put in the admin section but different css styles how do I manage that?
[12:00:59] Macaveli: and different deploy locations?
[12:00:59] DaniG2k: works like a chaaaaaaarm
[12:02:52] zeff: Macaveli: have admin.css and application.css manifests, and include what you need in either of those
[12:03:04] zeff: then in the admin layout, use the admin.css manifest, and for the app use the other
[12:03:42] Macaveli: zeff what are manifests?
[12:04:14] zeff: it's just the word for your compiled CSS main file, where you *= require my_css.css
[12:04:27] Macaveli: alright if we thinkg this trough
[12:04:37] Macaveli: your app will have a default CSS
[12:04:56] Macaveli: when the app is hosted online (deployed)
[12:05:06] Macaveli: the customer can upload a new css file and it will overwrite the default one
[12:05:10] Macaveli: do you mean that?
[12:05:19] zeff: oh i see what you're trying to do
[12:05:45] zeff: so put those CSS files in your DB and then in the client layout head include that last
[12:05:54] zeff: the client CSS in the db i mean
[12:06:12] Macaveli: so I would still have multiple customer branches?
[12:06:25] marahin: Guys. Is it possible to run a sidekiq worker manually?
[12:06:34] marahin: rvanlieshout: how do?
[12:06:43] marahin: There's no info at their website nor on github, as far as I've seen |:
[12:06:55] rvanlieshout: you want to start the worker of perform a task?
[12:07:19] marahin: I want to 'run' the perform method of an worker (based on sidekiq gem)
[12:07:28] rvanlieshout: FoobarWorker.new.perform
[12:07:32] Macaveli: zeff the problem is we have currently 2 customer and have 4 branches per customer and 1 development branch for us. And all the branches all different.
[12:07:45] Macaveli: and this makes deploying very hard
[12:07:50] marahin: rvanlieshout: using rails c?
[12:08:01] zeff: Macaveli: hold up a sec, are you talking about git branches that customers maintain?
[12:08:05] marahin: rvanlieshout: I am new to workers, and I want to start one on a existing -running- app, through cli
[12:08:10] chills42: marachin: you might want to "use 'sidekiq/testing/inline'
[12:08:21] Macaveli: zeff branches that we maintain. Each customer has an DEV / QAS / PRD system
[12:08:29] marahin: chills42: you could've just mara(TAB) to autocomplete my nick :P
[12:08:33] DaniG2k: does anyone know of any nice flag icons?
[12:08:43] DaniG2k: country flag icons*
[12:09:20] chills42: thanks... just got back into IRC... it's been a while
[12:10:08] marahin: yw, IRC > any other realtime messager
[12:10:08] zeff: Macaveli: if you have seperate branches for clients that need to sync with your main CSS updates, if it's branches from the same repo then just pull a CSS branch into the clients each time you update them. Otherwise, make a folder in your assets/css that's a sub-repository and do the CSS stuff there
[12:10:30] Macaveli: zeff it's much morethan that
[12:10:47] marahin: rvanlieshout: thank you for your help! rails c & Worker.new.perform worked great. :)
[12:10:57] Macaveli: what if 1 customer wants 2 H1 and the other 1 H1. I should make it customizable in the rails admin section.
[12:11:11] Macaveli: But the whole code will have a million IF's after a while
[12:11:13] marahin: It seems that I have issue with scheduling (whenever gem), wondering what's wrong... |:
[12:11:26] marahin: Anyways, idling back on. Cheers and have a great day!
[12:11:41] zeff: Mavaveli: if you want them to customize CSS through the actual interface of your app, then make their CSS in the database
[12:12:14] zeff: and add some logic in application_controller or somewhere else that sets a @client_css variable to the client's db css if they are logged in
[12:12:24] zeff: otherwise null
[12:13:01] zeff: then in the <head> include the <style><% @client_css %></style
[12:14:18] Macaveli: zeff I think this is an awesome option: http://stackoverflow.com/a/25184740/611588
[12:14:30] Macaveli: but is that scalable for 10 customers I think probaly not
[12:15:13] zeff: Macaveli: no, it's not really scalable.
[12:15:45] zeff: if you want clients to be able to customize their app to a large enough degree that they can control HTML/CSS/JS, then you need to entirely rethink your strategy
[12:16:11] zeff: one way might be to have modules of html/css/js that they can include or not include on their whim
[12:16:26] zeff: then your view renders the page based on the modules of frontend code they decide to include
[12:16:53] zeff: you then control the design of the modules to make sure they integrate, and give some control over CSS since that's harmless
[12:18:03] zeff: so ClientA has modules [users, dashboard], and users: [login, reset, new] where clientB has modules [users, something] where users: [login, reset] but no new
[12:18:45] zeff: then your view is intelligent enough to include the proper partials for the modules from the DB
[12:19:20] zeff: and you can do more complex stuff like have modules on a grid system, and let the client specify where on the page the module exists, to what manner, and so on
[12:19:53] zeff: you tell them what the CSS selectors are for the modules and give them the ability to modify CSS as they like
[12:20:19] zeff: and the CSS is stored in the DB for that particular client table
[12:22:54] shortCircuit__: can i upload muzic to soundcloud using rails?
[12:23:07] rvanlieshout: it's just impossible
[12:23:50] rvanlieshout: for you that is
[12:23:54] rvanlieshout: for everybody else it's possible
[12:23:56] no-ob: Hi folks. I am trying to send some textfields data from the erb form to the model and only the last value of the textfield would come in the params. Here is my form_for https://gist.github.com/anonymous/0d04bce62dd6d445085d
[12:24:01] zeff: shortCircuit__: https://developers.soundcloud.com/docs/api/guide#uploading-files
[12:24:15] no-ob: Can anyone please help me with this? I would really be greatful for the pointers. Thanks
[12:24:51] rvanlieshout: no-ob: a) you don't send thing to a model.. you send things to a controller
[12:25:11] zeff: no-ob: you're setting every form input id/name to "value"
[12:25:12] rvanlieshout: b) read about fields_for. your form elements have a same name and a browser will only submit the last one
[12:25:15] zeff: so it will only send the last one
[12:25:51] mrbubbles: hi guys, quick question :) i'm using RVM to manage my gemset and it's been working fine, but when I logged into my server today it seesm to have 'lost' the gems. The correct gemset is selected (rvm gemset list) but gem list shows the system gems
[12:26:09] zeff: mrbubbles: are you on the correct ruby version as your app?
[12:26:10] mrbubbles: If I do 'ls `rvm gemdir`/gems' I can see that the correct gems are there, but it's not showing them
[12:26:58] zeff: if you don't have a ruby version set in your gemfile it will load the last used one
[12:26:59] no-ob: Thanks zeff, rvanlieshout
[12:27:11] mrbubbles: gemsets for ruby-2.1.2 (found in /home/ec2-user/.rvm/gems/ruby-2.1.2) => energexuk-api
[12:27:12] mrbubbles: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
[12:27:15] mrbubbles: So that all looks good I think
[12:27:45] zeff: can you just re-run bundle install?
[12:27:58] mrbubbles: I can do, just curious as to why it's done this
[12:28:07] mrbubbles: -bash: bundle: command not found
[12:28:20] zeff: did you set RVM in your PATH?
[12:28:35] mrbubbles: rvm 1.25.30 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
[12:28:40] mrbubbles: So that's okay yeh?
[12:29:23] mrbubbles: weird, logged out of my server and ssh'd back in and it's working now
[12:29:26] mrbubbles: very odd. thanks anyway guys :)
[12:30:19] no-ob: rvanlieshout: can you please once elaborate?
[12:30:28] ronn__: i am having a problem...when i am opening my terminal and writing rails s,instead of the server it is getting an error.
[12:30:34] rvanlieshout: no-ob: what should i eloborate?
[12:30:37] ronn__: WARN TCPServer Error: Address already in use - bind(2)
[12:30:52] rvanlieshout: ronn__: then something else is using port 3000
[12:30:58] zeff: ronn__ something is already running on either port 80 or 3000
[12:31:11] zeff: do a ps -a and find out if rails is running
[12:31:20] rvanlieshout: ronn__: lsof -i tcp:3000
[12:31:58] ronn__: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
[12:31:59] ronn__: ruby 7295 kreetiuser 6u IPv4 196184 0t0 TCP *:3000 (LISTEN)
[12:32:06] rvanlieshout: well there you go
[12:32:10] rvanlieshout: that ruby process is listening on port 3000
[12:32:36] ronn__: hw to stop that?
[12:32:49] no-ob: rvanlieshout: I tried to remove the :value activity.value but still I am getting the same thing
[12:32:57] no-ob: only the last param that I send will reach
[12:33:01] rvanlieshout: no-ob: your form fields have the same name
[12:33:17] rvanlieshout: no-ob: <input type="text" name="foo" /><input type="text" name="foo" /> will only submit one
[12:36:55] rvanlieshout: no-ob: so you want to use fields_for or give them a unique name yourself
[12:37:02] rvanlieshout: or a name that ends with a []
[12:37:06] rvanlieshout: so that it's accepted as an array
[12:37:51] no-ob: rvanlieshout: aha
[12:40:04] no-ob: rvanlieshout: trying that
[12:42:31] no-ob: rvanlieshout: <%=f.text_field :value, :value => #{activity.value}%>
[12:43:44] zeff: no-ob f.text_field :value <- is a symbol, which represents the param[:symbol] that gets received
[12:44:08] rvanlieshout: look at the html it produces
[12:44:08] zeff: you need to set the value of that to whatever your param name is
[12:44:29] zeff: your loop block does not have a |value| in it, so that will just end up as the word "value"
[12:44:49] zeff: in which case the params object uses the last submitted one as precedent
[12:48:08] no-ob: zeff: aha
[12:48:24] no-ob: zeff: then it should be activity.value?
[12:48:29] no-ob: instead of :value?
[12:48:43] rvanlieshout: look at the html it produces
[12:48:50] rvanlieshout: don't just try to guess things here
[12:50:40] no-ob: rvanlieshout: okay, man! Hopefully it works
[12:50:49] rvanlieshout: cause it would be the same
[12:50:53] rvanlieshout: but you have to understand the problem first
[12:52:12] no-ob: Yeah, I got your point. I need to have name changed for every textfield
[12:52:26] rvanlieshout: and it's ok if that name is foo[]
[12:52:28] no-ob: That's what I am trying to figure out how do I do that in form_for erb
[12:52:47] rvanlieshout: what do the documentation tell you about the name?
[12:52:54] rvanlieshout: the documentation of text_field
[12:55:28] no-ob: rvanlieshout: yeah in the html output the name and id are always same
[12:55:33] no-ob: that's why it is taking it
[12:55:40] no-ob: it's like hardcoded string for name and id
[12:55:44] rvanlieshout: it's not hardcoded
[12:55:48] rvanlieshout: it's easy to change
[12:56:07] wpp: whatever happend to railscasts? is ryan bates ok?
[12:56:10] cheeti: hi my ajax function not working perfectly in mozilla but it's working in chrome why?
[12:56:38] no-ob: rvanlieshout: thanks it worked
[12:56:39] sevenseacat: cheeti: !reasons
[12:56:43] sevenseacat: cheeti: !reason
[12:56:59] no-ob: :name => activity_value, :id => activity_value
[12:57:01] basldex: especially when it comes to different browser behaviours
[12:57:06] no-ob: rvanlieshout: thanks again =)
[12:57:10] no-ob: and zeff =)
[12:58:13] zeff: no problemo
[12:58:50] wpp: nvm http://www.reddit.com/r/rails/comments/1ysbdb/any_news_about_ryan_bates_of_railscasts_is_he/
[13:00:43] cheeti: hi my ajax function not working perfectly in mozilla but it's working in chrome why? it's showing error message in mozilla and success message in chrome. https://gist.github.com/sabizuk/6954c20c9b0a1cb41c6b
[13:01:01] cheeti: <sevenseacat> hi my ajax function not working perfectly in mozilla but it's working in chrome why? it's showing error message in mozilla and success message in chrome. https://gist.github.com/sabizuk/6954c20c9b0a1cb41c6b
[13:01:14] helpa: cheeti: You have not provided enough information to debug your problem. Please provide this information: https://gist.github.com/radar/5384431
[13:01:14] rvanlieshout: cheeti: !debug
[13:01:16] cheeti: <helpa> hi my ajax function not working perfectly in mozilla but it's working in chrome why? it's showing error message in mozilla and success message in chrome. https://gist.github.com/sabizuk/6954c20c9b0a1cb41c6b
[13:01:16] helpa: cheeti: 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.
[13:01:16] rvanlieshout: cheeti: !code
[13:01:32] rvanlieshout: cheeti: and indent your code
[13:01:33] wpp: cheeti dont spam the folks
[13:01:55] helpa: cheeti: 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.
[13:01:55] elaptics: cheeti: !auto
[13:05:27] cheeti: that is 1300 lines of can i send all those?
[13:05:41] rvanlieshout: cheeti: no.. what is 1300 lines?
[13:05:51] rvanlieshout: your gist didn't contain an error to start with
[13:12:46] sevenseacat: debugging ajax stuff is hard - typically we would need to see the JS code, the ajax request, the ajax response, and then what actually happens with that response
[13:13:54] tbuehlmann: what do you call "ascending" and "descending"? directions?
[13:27:29] erGoline: hi :) I'm struggling with a problem using prawn gem, anyone has used it before and has a little time to help me? I need to know how to run a prawn repeater (http://prawnpdf.org/docs/0.11.1/Prawn/Document.html#method-i-repeat) conditionally, ex. different header for different pages
[13:30:37] ronn__: https://www.ruby-forum.com/topic/4414510
[13:30:48] sevenseacat: the docs look pretty comprehensive on the repeat method
[13:30:53] sevenseacat: what parts are you having problems with
[13:31:23] ronn__: i am facing this problem too but here it is written that in the action i have to mention..i cant get where i should mention the current_user.relationships.build
[13:31:35] universa1: ronn__: what problem are you facing?
[13:32:39] ronn__: they want to clean the view part..so they have transferred the build action from form to controller..
[13:32:51] ronn__: so where should i include that part..
[13:33:21] universa1: ronn__: what are YOU trying to do? show YOUR code! ...
[13:33:36] sevenseacat: psh what do you need to see that for
[13:33:44] sevenseacat: just tell him where to include that part
[13:35:11] ronn__: https://github.com/arnabpaul0333/Michael-Hartl-Tutorial/blob/6ca6bfb17ab6173ce2c81be9253caa027b4ebb36/app/views/users/_follow.html.erb
[13:35:30] ronn__: i want to move the build action to controller...
[13:35:54] sevenseacat: ahhh instance variables in partials -_-
[13:36:47] sevenseacat: so move it to the controller, and assign the result to a variable
[13:36:51] sevenseacat: then use that variable in the partial
[13:37:04] sevenseacat: though preferably it would be a local variable, not an instance variable
[13:40:02] ronn__: ok..thnx fr the soln..
[13:40:37] mdunbavan1985: Hey does anyone know how to get the value of a selected relationship onto the frontend in rails, I have authors for posts and when I select the post author I want to show their name etc on the front end
[13:40:59] sevenseacat: just access the association? i dont get the problem
[13:41:07] erGoline: sevenseacat: I'm unable to use it conditionally, I tried this way https://gist.github.com/anonymous/2d13209380242e2621b9 but it doesn't work
[13:41:29] sevenseacat: well thats a syntax error for starters
[13:41:40] erGoline: sevenseacat: the repeater number two is used on all pages
[13:42:40] lightswitch05: hello sevenseacat
[13:43:41] sevenseacat: good evening lightswitch05
[13:44:14] lightswitch05: its morning now, your not still at work are you?
[13:44:35] sevenseacat: at home watching tv
[13:52:31] erGoline: sevenseacat: any idea about the conditional repeater? :)
[13:52:59] centrx: erGoline, can't you just put an if-statement in the block
[13:53:02] mdunbavan1985: universa1: sorry had a phone call
[13:53:54] mdunbavan1985: I have got this which only shows the author when I publish the author with the post @book.author.name
[13:54:20] mdunbavan1985: I want to get the author event when you attach it via a checkbox
[13:54:52] mdunbavan1985: Is that confusing?
[13:54:54] universa1: before saving? directly when you select it in the browser? after saving?
[13:55:14] universa1: before/after you submitted the form...
[13:56:17] mdunbavan1985: so before I publish a post there is a list of authors that have already been added into the site and I am basically trying to add an author thats already been added before I save the post and when I save it I want the author to be shown
[13:56:54] erGoline: centrx: already tried this solution, doesn't work, it is like the repeater is executed after all the pages were written, so the control variable (section) has always the last value
[14:01:33] mdunbavan1985: universal: http://pastebin.com/T13qt5uq
[14:02:19] mdunbavan1985: universal: http://pastie.org/9555632
[14:04:46] mdunbavan1985: The author is there but its just not showing on the show page for the book with @book.author.name
[14:04:48] workmad3: mdunbavan1985: if you only want to allow already-existing authors through, make use of a collection_select for author_id in the form, allow 'author_id' in the book params and don't use accept_nested_attributes_for or author_attributes
[14:05:31] mdunbavan1985: workmad3: hmm thats how my whole author being added is working
[14:06:02] mdunbavan1985: workdmad3: I can add authors on their own
[14:06:25] workmad3: mdunbavan1985: yes... so you probably want the setup I just gave :P
[14:07:06] mdunbavan1985: workmad3: <%= f.association :author, as: :check_boxes, value_method: :id, label: 'Authors' %>so this is not the best approach
[14:07:32] mdunbavan1985: workdmad3: I want to allow both
[14:07:43] workmad3: mdunbavan1985: then you're gonna have fun figuring out the code for that
[14:07:49] workmad3: mdunbavan1985: it's not a normal use-case and complicates things
[14:08:09] workmad3: (by 'normal use case' I mean 'one rails supports out-the-box easily')
[14:09:17] mdunbavan1985: workmad3: The basic idea is you add a book and associate an author by adding that with the book, if you add another book and the author has already been added you just select that associated author that was already assigned to another book as the author can have many books
[14:10:56] vasilakisfil: hello! How can I use find_by with multiple ids? find works but not find_by like find_by(id: [1,2])
[14:11:16] sevenseacat: vasilakisfil: find will only ever return the first. you want more than one, use where.
[14:12:30] mdunbavan1985: workmad3: that should be a straightforward thing and it works when I add an author to the book but I am hitting a brick wall as to how to retrieve that data on the frontend
[14:12:37] vasilakisfil: sevenseacat to have consistency in my code in which I don't know if I will get 1 id or multiple ids, I will always use where.. does this sound right ?
[14:13:04] sevenseacat: you should always know what you're going to get.
[14:27:06] mdunbavan1985: So trying to get an association into the frontend is not possible right?
[14:27:50] universa1: i honestly still don't udnerstand what you mean by: retrieve it on the front-end
[14:28:19] paolochiodi: Hi, is there a way to point ActiveResource to an ipaddress, while still providing a server name (eg: I can???t edit hosts file)
[14:28:46] universa1: paolochiodi: what?
[14:28:53] centrx: mdunbavan1985, Everything in the code base can be made accessible to views
[14:29:18] manfred-s: paolochiodi: Yeah, but you would have to monkey patch something to make it send the correct Host header.
[14:29:20] mdunbavan1985: universal: I mean once I have associated an already added author onto another book I need to get that value (name, biography etc) into that books show page
[14:29:48] mdunbavan1985: centrx: thats what I thought but my code seems to not work
[14:29:50] universa1: mdunbavan1985: so? it doesn't matter how you associate the author to a book.
[14:29:59] paolochiodi: manfred-s: there???s no default method for it?
[14:29:59] universa1: mdunbavan1985: create a gist with your view.
[14:30:31] manfred-s: paolochiodi: No, you can only set the ???site???
[14:30:32] universa1: mdunbavan1985: in your show action you access it through @book.author.whatever ...
[14:30:50] paolochiodi: manfred-s: thank you
[14:31:02] manfred-s: paolochiodi: You're welcome!
[14:31:03] mdunbavan1985: universal: https://gist.github.com/mdunbavan/67a7e2d9311721681563
[14:31:17] universa1: mdunbavan1985: so? what is not working?
[14:31:43] mdunbavan1985: universal: @book.author.name @book.author.biography
[14:32:49] universa1: mdunbavan1985: you get an error?
[14:33:06] mdunbavan1985: just nothing no error it shows no data]
[14:33:21] universa1: mdunbavan1985: then your associated author has no name and no biography...
[14:33:33] universa1: mdunbavan1985: open up rails console and inspect the data.
[14:34:30] helpa: mdunbavan1985: How to use Gist properly: https://github.com/radar/guides/blob/master/using-gist.markdown
[14:34:30] workmad3: mdunbavan1985: !gist-usage btw
[14:39:37] mdunbavan1985: universal: yeah you were right
[14:48:47] Freedom_: i???m working with some legacy code and have noticed url params in form_for was smart enough to switch to collection path if passed-in parameters was nil. Looks like this was removed somewhere between 4.0.0 and 4.1.5. Anyone knows if there is a quick workaround for this or should i start rewriting all the views?
[14:50:43] cheesedanish: Is there a rails gem that lets you proxy http requests and will re-write in document urls so that they also go through the proxy?
[14:55:17] emachnic: cheesedanish: Best bet would be to use something like Nginx to do that
[14:57:31] cheesedanish: emachnic: thanks!
[14:57:56] manfred-s: Freedom_: I would rewrite the views, but can you give us a concrete example?
[14:58:07] Freedom_: manfred-s: one moment
[15:00:25] Freedom_: manfred-s: something like this http://pastie.org/9555765
[15:01:38] Freedom_: manfred-s: and there???s tons of similar views all around the app
[15:04:56] manfred-s: Freedom_: So you're reusing the views for the new and update?
[15:05:12] Freedom_: manfred-s: yes
[15:05:51] manfred-s: Freedom_: I would set @forum_post = ForumPost.new in the new actions in the controller.
[15:06:21] manfred-s: Freedom_: And then you can use form_for([@forum_post.topic_id, @forum_post]) I think.
[15:06:22] Freedom_: manfred-s: won???t work. in fact it is set
[15:06:48] Freedom_: manfred-s: it???s not nil as i wrote in pastie. i???ve just investigated.
[15:06:57] manfred-s: Freedom_: Or form_for([@forum_post.topic_id, @forum_post].compact)
[15:09:04] Freedom_: manfred-s: i???ll try and play around with .compact idea. might do the trick though the routes and model names are not ???the rails way???.
[15:09:28] Freedom_: manfred-s: probably because of desired url schema
[15:09:48] manfred-s: Freedom_: I'm afraid you will need so custom URL code in that case.
[15:10:36] ale__: Hello everyone, I am making my first rails app which is a form that registers users on a db, the problema is that none of the inputs are being saved, here is all my code http://pastebin.com/pU3NTJg5
[15:10:47] Freedom_: manfred-s: yeah. just wanted to check i haven???t missed something :) that???s how things are when taking over someone else???s project
[15:11:35] ale__: Sorry guys, here is my pastie: http://pastie.org/9555774 If someone could help me I'd really aprecciate that
[15:12:35] manfred-s: ale__: Code looks fine, the problem is probably in the view / html.
[15:12:52] manfred-s: ale__: I would change @user.save! to if @user.save though.
[15:14:18] ale__: manfred-s: But sqlite 3 is not saving records fine. Check this: http://pastie.org/9555776
[15:14:54] manfred-s: ale__: Yes, I think the error in in your form / html. Can you show your views?
[15:15:08] ale__: manfred-s: Sure, one second
[15:15:43] ale__: manfred-s: Here it is the new user form http://pastie.org/9555780
[15:17:30] h4b0: hi all :)
[15:21:41] manfred-s: ale__: Ah, I missed the attr_accessor thing. You can remove that from the User class.
[15:22:54] ale__: manfred-s: Anyway after submiting the form this is shown: {"name"=>"asd", "email"=>"asd", "encrypted_password"=>"asd"}
[15:23:02] manfred-s: ale__: http://stackoverflow.com/questions/4370960/what-is-attr-accessor-in-ruby
[15:23:12] ale__: manfred-s: Which means that the data is actually being sent!
[15:23:43] manfred-s: ale__: Yes, it will work when you remove the attr_accessor part in the User class.
[15:24:07] ale__: manfred-s: And you are fully right! Which was my mistake?
[15:24:30] manfred-s: ale__: Please read the top answer in the StackOverflow question I just pasted.
[15:24:45] ale__: manfred-s: Thank you very much!
[15:24:58] manfred-s: ale__: You're welcome!
[15:30:19] h4b0: Guys I have problem with one test(capybara).I made autocomplete directive in angular with jquery-ui and it working fine on website, but i have problem with pass integration test(capybara). I use poltergeist as driver with phantomjs. Probably problem is that, i use watch(angular) function for input(model), which giving permission to autocomplete after written sign hash '#'.And this is funny
[15:30:19] h4b0: cuz when I break test with binding.pry and i manually write instructions that working fine :) In autocomplete i use source from json(ajax).. problem can be here too ;/ Problem is that capybara didn't see suggests ;/ http:/http://pastebin.com/ssvrP9iM - Test htttp:http://pastebin.com/DqQnvANa -
[15:30:19] h4b0: watch function
[15:34:06] h4b0: i waste my day today on that ;/
[15:34:43] manfred-s: h4b0: That sounds more like a JavaScript / architecture problem than a Rails problem. I'm not sure if people here will be able to help you.
[15:35:50] h4b0: hmm i think this is problem with capybara
[15:36:05] h4b0: cuz on website that working fine :) and on pry working too
[15:36:40] manfred-s: h4b0: Right, it's probably some memoization / caching problem in Capybara.
[15:37:33] chridal: Hello! I am getting a very cryptic error: ActionController::RoutingError (undefined method `serialization_scope' for UsersController:Class):
[15:37:38] chridal: anyone seen anything like that before?
[15:39:44] centrx: chridal, Is your routes config pointing a controller action/method that does not exist
[15:41:26] h4b0: hmm maybe someone know how to slow down fill_in or find(#input).set(value) in capybara :D
[15:41:28] chridal: No, because if I remove that line everything works fine
[15:41:55] chridal: it's just that when I use functions that actually depend on the serializer having access to the current_user scope, it suffers
[15:53:18] chridal: Seems there was a bug in acitive_model_serializers gem
[15:53:20] shlant: anyone have experience with unicorn zero downtime deploys and rbenv? It keeps using the unicorn exec from an old releast
[15:53:22] chridal: thanks though
[16:20:20] SloggerKhan: When using active model serializer how do you create permission/role/authorization dependent attributes?
[16:29:05] shwoodard: hey all, i changed my assets.prefix and then I changed it again and some assets are still trying to be requested from the first prefix. I've restarted the server. Anyone know how to fix this?
[16:39:15] rhizome: all you did was change the prefix and restart something?
[16:49:43] mwlang: I???m trying to set up capistrano deployment, but have a problem with a locally included gem, rb-event that???s conditionally included on the developer???s mac-based sandbox, but not needed on a linux server: https://gist.github.com/mwlang/dafc4cf2a4bb9e0bda2e How can I better structure this so I don???t get the message, ???you have deleted from the Gemfile: rb-fsevent??? when the cap deploy command is run?
[16:51:16] momomomomo: mwalsher: don???t do conditional things in your gemfile
[16:56:28] tuelz: is there a way to achieve calling try on an array to get the id element? e.g. `array.try(:last)[:id]`
[16:56:48] tuelz: or do I just need to use a conditional?
[16:58:30] capin: hello, i'm currently an undefined method `each' for nil:NilClass error, https://gist.github.com/ipatch/6b65fc96a95c6a8ff0a9
[16:59:26] tuelz: capin: throw your error trace into that gist please
[16:59:29] centrx: capin, @users must be undefined? and use @users.each instead of for x in @users
[17:00:14] tuelz: centrx: you read code mighty fast
[17:00:54] tuelz: I had time to scroll through looking for an error log by the time you found a problem, lol
[17:01:58] centrx: for loop jumped out
[17:02:53] tuelz: looks like you're sending @user to the view and trying to loop through @users instead capin
[17:03:16] tuelz: oh just kidding
[17:03:27] tuelz: not only am I slow at reading code, I'm also bad at it
[17:03:56] mwlang: Is it enough that rb-fsevent is in the development/test group?
[17:04:04] tuelz: although you are calling @users in a partial and not sending that variable to the partial
[17:04:13] mwlang: I???m just not 100% sure when I deploy if development/test is picked up or ignored.
[17:06:27] rubyonrailed: Is there some sort of script to change rails 3.2 relationships to 4 syntax?
[17:09:34] capin: centrx: what would the for loop statement look like?
[17:10:18] centrx: capin, "my_array.each do |element|" instead of "for element in my_array"
[17:10:51] centrx: capin, the Ruby parser converts the for into the each, so that is why the error message pertained to .each
[17:16:08] mwlang: my question is answered by the capistrano script. After removing the conditional, cap deploy works and I see on the command line: ???--deployment --quiet --without development test???
[17:16:17] lastk: Hi, is there a way to make all my controller methods always render a json object instead of try render one view ?
[17:16:46] capin: centrx: so i changed the problematic line to "<% @users.each do |user| %>" but im still getting "undefined method `each' for nil:NilClass"
[17:16:49] mwlang: so that tells me development and test groups aren???t deployed.
[17:16:55] lightswitch05: lastik: maybe you are looking for the respond_with method?
[17:17:08] centrx: capin, right, @users is still undefined/set to nil
[17:18:05] capin: centrx: :/ do i need to set it in the controller?
[17:18:48] lastk: lightswitch05, well, the problem is if i have a blank method on my controller, it will still render a page :(
[17:19:00] centrx: capin, It look like you already have a line setting @users in #show, but it is not setting it to what you think it is
[17:19:35] lightswitch05: lastk: render nothing: true
[17:20:01] tuelz: also, he's not passing the @users to the partial is he? Been a while since I've done a rails partial, but you used to have to explicitly pass those
[17:20:41] lastk: lightswitch05, for each method? thats the problem lol
[17:21:13] lightswitch05: lastk: what are you trying to do? Why do you have so many blank controller methods?
[17:22:16] lastk: lightswitch05, right now i just want make sure all routes are working, and responding with json, after that im going to implement
[17:26:21] lightswitch05: lastk: using `respond_to` & `respond_with` will allow you to setup json responses easily. As for not wanting to do `respond_with nil` in a bunch of empty methods - it might just be easier to only create the routes as you implement them and not have a whole bunch of dead routes.
[17:27:53] lastk: lightswitch05, thanks, i think i will stay with respond_with/to this way
[17:28:54] lightswitch05: lastk: just an FYI, in rails 4.2 they are moving the respond_with/to out of rails into its own gem. I have no idea why this decision was made. Anyone else have any input on that?
[17:29:20] lastk: yeah, I was reading something about it other day
[17:29:35] lastk: but it is no problem, just a little project to a interview
[17:33:10] Lauer: Hmm, isn't it possible easy to move from a mssql to a mysql database?
[17:36:22] lightswitch05: lastk: I did some research, this is why respond_with/to was moved to its own Gem: https://github.com/rails/rails/pull/12136#issuecomment-50216483
[17:37:00] bricker`work: arrgg google hangouts is SO CLOSE to being a google voice replacement... I can now READ texts from my computer, I just can't send them... well this will all be irrelevant when I get an iphone I guess
[17:45:41] aaa: I am trying to find all records for a certain year but for some reason it gives me incorrect results. for example .where(date:Time.new("2013").all_year) gives me all the records between February 2013 and January 2014 (Including Feb 2013 and Jan 2014 months). any ideas?
[17:50:36] rhizome: what is ".all_year?"
[17:50:51] bricker`work: great question
[17:51:20] bricker`work: here it is http://api.rubyonrails.org/classes/DateAndTime/Calculations.html#method-i-all_year
[17:51:25] lightswitch05: I just ran it in my console: got this: irb(main):002:1> ).all_year
[17:51:25] lightswitch05: => 2013-01-01 00:00:00 +0000..2013-12-31 23:59:59 +0000
[17:51:54] rhizome: weird, didn't come up in the googles
[17:52:09] bricker`work: rhizome: it probably changed it to search for "rails all year", same thing happened to me
[17:52:43] bricker`work: google has failed us
[17:53:17] rhizome: YOU ARE CORRECT, SIR
[17:53:58] lightswitch05: aaa: when you run that in dev - what does the resulting SQL look like?
[17:54:43] rubyonrailed: I'm migrating to rails 4 and am getting this error about a scope that previously worked. Could someone explain whats happening? https://gist.github.com/anonymous/234804bde9850afa9de1
[17:55:03] bricker`work: rhizome: Showing results for "YOUR ERECT IRS"
[17:55:42] bricker`work: rubyonrailed: "private" is a reserved keyword in ruby, choose a different name for your scope
[17:56:11] bricker`work: rubyonrailed: the only change is that ActiveRecord is no longer allowing you to override reserved methods
[18:00:43] lightswitch05: anyone have strong opinions on request specs and controller specs and when to use them?
[18:01:10] bricker`work: lightswitch05: use them for controller logic.
[18:01:26] bricker`work: or rather, logic which is in the controller
[18:01:36] yaymukund: is there an elegant way to create multiple objects in a single transaction? it looks like `create` does one transaction per object ( http://stackoverflow.com/questions/2509320/saving-multiple-objects-in-a-single-call-in-rails#comment2506883_2509367 )
[18:02:01] lightswitch05: bricker`work: right - but how would you decide on either a request spec or controller spec?
[18:02:40] aaa: rhizome, so any ideas? :D
[18:02:51] Jon30: aaa = Jon30
[18:03:09] tubbo: lightswitch05: typically my controller tests will be testing the response ("if i have X params, i should get Y response with Z headers"), and my request/feature specs will be testing the page ("if i click X button, i should see Y form and be able to type Z text into B input")
[18:03:34] bricker`work: lightswitch05: request tests are higher-level... test from the user perspective. Controller tests test the response codes, response bodies, etc. Very useful for testing APIs.
[18:03:48] tubbo: lightswitch05: controller tests use a mocked HTTP layer so they aren't really great for testing what your shit looks like, but they are nice for testing basically what will happen when an HTTP object comes in and starts requesting things from your controller class.
[18:04:03] bricker`work: lightswitch05: the request tests don't care about your controller, they just care that the user interaction works as expected.
[18:05:54] lightswitch05: ok thank you guys - thats along the lines I was thinking, just wanted to be sure
[18:06:15] lightswitch05: Jon30: what does the resulting SQL look like when you run the year scope?
[18:07:45] Jon30: lightswitch05, SELECT "drive_files".* FROM "drive_files" WHERE "drive_files"."folder_id" = ? AND (date < '2014-01-01 05:00:00.000000') AND ("drive_files"."date" BETWEEN '2013-01-01 05:00:00.000000' AND '2014-01-01 04:59:59.999999')
[18:08:18] lightswitch05: Jon30: looks like you are having time zone problems
[18:08:24] Jon30: looks like it
[18:08:31] Jon30: i hate timezones
[18:08:35] _ritchie_: I am setting up forms to update an ActiveRecord model object and I find that I have several different use cases that only update 1-3 distinct attributes, is it a better practice to write different control actions to handle individual cases or handle different cases with a conditional in the update action?
[18:09:30] Jon30: is there an alternative to all_year? hmm
[18:09:54] tubbo: _ritchie_: nah, it's best to just always mass-assign all attributes you get in update(), and use strong_parameters to filter out params that would be harmful
[18:10:18] _ritchie_: tubbo: why is that?
[18:10:25] tubbo: _ritchie_: you just PUT /yourmodel/1 with the payload { "yourmodel": { "attr": "new_value" } }
[18:10:46] lightswitch05: Jon30: just fix your timezone issues. What do you have for `config.time_zone` in config/application.rb
[18:11:18] tubbo: _ritchie_: not to answer a question with a question, but why do *you* need multiple update actions?
[18:11:20] Jon30: it's commented out
[18:11:23] Jon30: lightswitch05,
[18:12:31] Jon30: I set to the correct time zone, same issue.. hmm
[18:12:46] _ritchie_: tubbo: well in one case I have to parse the the form data to get the attribute value, it's a date + time coming from 2 fields, a date field and a time field, and in another case I'm directly updating from the form data
[18:13:22] lightswitch05: Jon30: I think its because your DB is using UTC - and Time is using your local
[18:13:29] tubbo: _ritchie_: why not have a virtual attribute (attr_accessor) in your model, and then in a before_validation callback do the date/time parsing from the param stuffed in that virtual attr?
[18:13:53] _ritchie_: tubbo: hmmmm that is a good idea, I like that approach
[18:14:02] _ritchie_: tubbo: thanks!
[18:14:32] _ritchie_: also helps keep the controller logic skinnier
[18:15:42] lightswitch05: Jon30: leave your rails app in UTC - try using this in your scope: Time.utc('2013')
[18:16:20] lightswitch05: Jon30: Time.utc('2013').all_year
[18:19:33] shwoodard: rhizome: yeah...all I did was change the prefix and restart. some assets tags picked up the change and others did not
[18:23:25] Jon30: lightswitch05, ok sec
[18:27:20] Jon30: lightswitch05, better but now it's not showing january of that year
[18:27:40] lightswitch05: Jon30: what does the SQL look like now?
[18:28:58] Jon30: lightswitch05, SELECT "drive_files".* FROM "drive_files" WHERE "drive_files"."folder_id" = ? AND ("drive_files"."date" BETWEEN '2013-01-01 00:00:00.000000' AND '2013-12-31 23:59:59.999999')
[18:30:21] lightswitch05: Jon30: looks legit to me. Are you sure you have records for january?
[18:30:46] Jon30: lightswitch05, perhaps the record for january is set to 2013-01-01 00:00:00.000000
[18:30:49] Jon30: i'll have to look it up
[18:33:10] Jon30: lightswitch05, i know for a fact that january is there because it was showing up before.. but under the wrong label :)
[18:33:16] Jon30: under the label of the previous year
[18:33:51] Jon30: lightswitch05, ok the date field has "2013-01-01"
[18:34:24] lightswitch05: Jon30: so it is working now or no?
[18:34:37] Jon30: lightswitch05, nope.. it ignores the january record
[18:34:58] Jon30: so i got 2 sections on the site.. 2013 and 2012.. both are missing january
[18:36:50] lightswitch05: according to http://www.techonthenet.com/sql/between.php the BETWEEN statement is inclusive - so '2013-01-01 00:00:00.000000' would still work. perhaps your folder_id is wrong
[18:38:50] Jon30: lightswitch05, nope :(
[18:39:17] Jon30: I guess i should try to do greater than 2012-12-31
[18:39:20] Jon30: to get the january
[18:39:59] lightswitch05: Jon30: what database are you using?
[18:40:11] Jon30: lightswitch05, sqlite in development
[18:40:32] lightswitch05: is it opensource?
[18:50:03] abarro: Hi guys, where is thebestplace to put a static content that will be repeated. Ex telephone number (that I maybe need to change in future) across multiple files? I was thinking on putting it on my application_helper.rb
[18:51:05] centrx: abarro, yes that sounds okay
[18:51:19] abarro: cool! thanks @centerx
[18:51:37] lightswitch05: @abarro you could make the telephone a config
[18:52:00] lightswitch05: application_helper.rb works too
[18:52:11] ckboii89: can someone explain to me what exactly does paperclip do?
[18:52:16] ckboii89: is just file attachment for rails?
[18:53:24] abarro: thanks gor the idea @lightswitch05
[18:55:35] rubyonrailed: Hey, i'm upgrading from rails 3.2 to rails 4 and upgraded my paperclip gem from 2.x to 4.x. Now i'm getting this error in rspec https://gist.github.com/anonymous/2820202079d7e9eb61f3 Does anyone know whats going on?
[18:56:06] Jon30: lightswitch05, i just ended up doing this: where("date > ? AND date < ?", Time.new("2012").utc.end_of_year ,Time.new("2013").utc.end_of_year).pluck(:date)
[18:56:36] lightswitch05: Jon30: and that fixed it?
[18:56:47] Jon30: lightswitch05, yes sir
[18:57:32] lightswitch05: Jon30: well... thats odd since that one website said the BETWEEN statement was inclusive. but glad you figure it out and thanks for the update
[18:57:52] Jon30: lightswitch05, thanks for your help :)
[18:58:20] lightswitch05: Jon30: no problem, got to do something while the admins attempt to get our DB running again
[18:58:24] dda: rubyonrailed: Looks like the spec/shoulda_macros/paperclip.rb file may have outdated code.
[19:00:15] momomomomo: lightswitch05: ???one website said ??? ???
[19:00:24] momomomomo: not a good rule generally to follow what one website said :p
[19:00:45] lightswitch05: momomomomo: yes, thats a red flag :)
[19:00:52] dda: rubyonrailed: Paperclip already ships with some shoulda macros, if I'm not wrong. Try to look into it.
[19:01:20] pipework: ckboii89: What wasn't clear about the README on github?
[19:02:42] ckboii89: nvm i understand now
[19:02:58] ckboii89: im just trying to crop a picture
[19:03:00] momomomomo: BETWEEN is inclusive http://www.postgresql.org/docs/9.3/static/functions-comparison.html
[19:03:04] momomomomo: in postgresql anyhow
[19:03:12] lightswitch05: ok, just to give me a bit more credt, sqlite.org says the between operator is inclusive https://www.sqlite.org/lang_expr.html
[19:03:37] ckboii89: i was getting confused the difference between imagemagik and paperclip
[19:04:29] tubbo: imagemagick is just a library for processing images, paperclip handles uploading them
[19:13:29] mwlang: where is HTTPI defined? I???m using it to handle controller requests in my rspec specs and it works fine when rspec is run via guard with ???spring rspec??? but when I simply run ???rake spec??? HTTPI generates this error: ??? uninitialized constant HTTPI (NameError)???
[19:14:49] mwlang: nevermind, just asking y???all was enough to finally (finally!) find it on my own.
[19:20:38] makerop: how can i use rspec to test values of a hash?
[19:20:39] makerop: https://gist.github.com/makerops/9be4c726759c79baea13
[19:21:34] makerop: I know I'm not blocking it right, but im not sure why
[19:23:41] mwlang: makerop: !gist
[19:23:58] mwlang: sorry, gist your code
[19:24:00] makerop: did i not gist correctly?
[19:24:14] mwlang: I don???t know.. I just joined the room.
[19:24:29] makerop: https://gist.github.com/makerops/9be4c726759c79baea13
[19:26:15] mwlang: makerop: which line is throwing the error?
[19:26:33] makerop: subject.value.each
[19:26:45] makerop: the err is at the top of the gist
[19:26:58] makerop: I want to iterate over the value of the subject's value, and test each one for the version
[19:27:36] makerop: it's a hash with several key/vals
[19:28:19] mwlang: I think what the err is saying points at line #17???I haven???t used subject in a while, but I think #17 needs to be moved outside the ???it ???should return 0 or greater??? do block.
[19:29:03] mwlang: I???m just not sure with a dynamically delcared describe/it construct.
[19:31:05] mwlang: makerop: its actually line #14 now that I re-read that whole thing.
[19:34:44] makerop: mwlang, can i not call subject.value?
[19:35:37] mwlang: Not in this case???you???re calling subject outside the it block. which means you???re declaring subject at that point.
[19:57:02] textual_1337: When alternating sending requests from different browsers, the request that arrives when I inspect the controller is the previous one. Why might would I get the same info for requests from a different browser? I'm using Rails 3.2.16 and the open-source version of Phusion Passenger (and also testing on WebRICK). On the other hand, I don't see this behavior in Unicorn.
[20:37:03] rhizome: hard to say
[20:42:02] glundgren: hey guys, a very noob doubt, how can i update a field, based on params AND a calculated date? i mean, i have a form with start_date, and days, i want to change the final_date based on the number of days
[20:42:37] glundgren: in the method, i have only @titular.update(titular_params)
[20:43:12] glundgren: can i add a method in the strong params?
[20:43:20] glundgren: to calculate the final_date?
[20:43:25] glundgren: how can i do it?
[20:44:58] disconnekted: instance.final_date = DateTime.now + n.days
[20:45:04] disconnekted: instance.save
[20:45:18] glundgren: disconnekted: can i do it without changing the update?
[20:45:41] glundgren: so i have to call every field
[20:45:44] glundgren: and then save
[20:46:01] Wolland: you save it once
[20:46:09] disconnekted: just the one you want to update, the rest will be filled out if your params are assigned via a form helper
[20:47:07] glundgren: in this case, the date is from a nested form
[20:47:56] Wolland: or you can handle it on the front end and pass calculated value in your params
[20:48:08] glundgren: how i instance.ins_attributes[0].final_date = DateTime.now + n.days
[20:48:55] glundgren: i have to count how many attributes, then check if the field is empty
[20:48:59] glundgren: then calculate the date
[20:49:49] disconnekted: Do it in the create action. if final_date == nil assign it the value.
[20:51:08] rhizome: describe a little more what you want to do. you may be able to handle it by implementing a custom setter on the model
[20:52:55] glundgren: rhizome: i want to calculate a finaldate when creating/updating based on start_date (datetime) and days (int) fields,
[20:53:34] zorak8: in the first example of this
[20:53:34] zorak8: http://guides.rubyonrails.org/active_record_validations.html#errors-add
[20:54:08] zorak8: how the error know that the name have symbols?
[20:54:12] Wolland: glundgren: what's the start date?
[20:54:34] glundgren: its a field in model, a date_field
[20:54:38] Wolland: I guess, why not just get final date from user?
[20:54:44] Wolland: why do you need days?
[20:54:56] glundgren: because its like a credit, and have a due date
[20:54:56] Wolland: you can calc days from start end dates
[20:55:19] glundgren: yeah i can calculate it thorught the controllers
[20:55:36] glundgren: but i want to record it, to make things easier
[20:55:59] Wolland: I think you will make things harder instead
[20:56:05] rhizome: are the days and the final_date in the same model?
[20:56:22] rhizome: and start_date?
[20:56:34] glundgren: in the same model
[20:57:07] rhizome: what changes when the form is submitted? nothing, just recalculating?
[20:57:40] glundgren: yes, i want to calculate/recalculate the day
[20:57:43] glundgren: when saving the record
[20:57:49] glundgren: that is a nested_attribute
[20:57:54] rhizome: but none of those attributes are changing?
[20:58:25] glundgren: i want to know how can i do it
[20:58:29] glundgren: the best way to do it
[20:58:36] rhizome: then answer questions :)
[20:58:48] glundgren: they are changing
[20:58:54] glundgren: if the user updates
[20:59:24] rhizome: it sounds like final_date is the only thing that's changing. do start_date or days ever change?
[21:00:00] disconnekted: and is the user updating the same model where your final_date is located?
[21:00:12] glundgren: yes, it can be changed
[21:00:19] rhizome: what is "it?"
[21:00:35] glundgren: days or start_Date
[21:01:29] rhizome: regardless, it doesn't really matter. i would use a helper or virtual attribute method on the model. def final_date; start_date + n.days; end
[21:01:33] Wolland: start_date + days = final_date
[21:01:49] glundgren: its the best way to do it, then?
[21:02:07] rhizome: it involves less logic, callbacks, etc.
[21:02:42] rhizome: if it's just for display, use a helper, if you're calculating with it, a method.
[21:02:47] elaptics: I missed the start of this conversation but I'll just +1 rhizome anyway :)
[21:04:55] glundgren: thanks guys
[21:05:24] glundgren: i was in doubt if this field was really needed, thanks for pointing me out
[21:05:25] rhizome: sure thing. note this also means you can get rid of the final_date attribute on the model
[21:06:24] Wolland: what if you want to search for it?
[21:06:30] zorak8: in the first example of this
[21:06:33] zorak8: http://guides.rubyonrails.org/active_record_validations.html#errors-add
[21:06:35] zorak8: how the error know that the name have symbols?
[21:07:09] wicketn00b: When alternating sending requests from different browsers, the request that arrives when I inspect the controller is the previous one. Why might would I get the same info for requests from a different browser? I'm using Rails 3.2.16 and the open-source version of Phusion Passenger (and also testing on WebRICK). On the other hand, I don't see this behavior in Unicorn.
[21:07:11] Wolland: I guess you can calculate it on the query side, but it's more painful
[21:07:25] rhizome: Wolland: left unspec'd ;)
[21:07:38] elaptics: zorak8: that's just an example message you can supply
[21:07:42] Wolland: true again.
[21:08:11] rhizome: it's easy enough to upgrade for more complex behavior
[21:09:34] zorak8: the example dont work?
[21:10:32] zorak8: how can i make so that works?
[21:12:08] rhizome: what's a good way to implement mandatory associations? case is basic vs. optional features/subscriptions
[21:17:56] elaptics: zorak8: you'd need to do something like: errors.add(:name, "can't contact chars...") if name.match /@|!|#/
[21:18:16] elaptics: zorak8: wherein the the regular expression you list all the characters you don't want it to accept
[21:18:23] Wolland: rhizome: you mean like validations?
[21:18:46] zorak8: ok, thanks elaptics
[21:19:57] rhizome: Wolland: it would probably have to be a validation, yeah.
[21:21:16] Wolland: probably mix of presence, associated validates
[21:21:44] rhizome: they should probably not be able to be removed as well
[21:22:29] Wolland: sure, they don't have to have that method at all and be removed through parent association only
[21:22:30] rakm: This isn't a rails specific question, but I want to set up a system that archives email from a group email address. Does anyone know of anything that exists already that we can install on our own servers?
[21:22:31] rhizome: which makes me wonder whether the mandatories should be kept outside of the "subscription" model per se
[21:22:51] rhizome: i.e. creating an account means these associations are assumed
[21:22:56] rakm: It basically needs to systematically archive email to a single address and make it searchable
[21:23:15] rhizome: could probably make multiple associations for subs, one for mandatories and one for optionals
[21:23:44] Wolland: I guess it depends on your specific needs
[21:24:13] rhizome: rakm: depending on your email system there are usually ways of delivering to an archive box behind the scenes
[21:24:44] rhizome: automatic b/cc
[21:24:48] Wolland: but mandatory child objects should be created when parent is created, rest is just normal optional stuff
[21:25:05] rakm: rhizome: i work at megacorp and don't have visibility into the email system itself. current strategy is to add an "Archiver" account to each group that needs to be archived
[21:25:15] rhizome: yep. i'm thinking down the road that the optionals could be part of a nested form where the mandatories aren't touched
[21:25:41] Wolland: rakm: elasticsearch maybe?
[21:26:20] Wolland: rakm: http://logstash.net/docs/1.4.2/inputs/imap
[21:26:23] rakm: Wolland: yes, if I were to put together my own system, I would use some sort of smtp gem/module + elasticsearch
[21:26:37] Wolland: logstash + es + imap
[21:26:45] rhizome: rakm: if it's like pop3, then you might have a race condition where an email is deleted from the group box before the archiver can download it
[21:27:15] rakm: no, there will be no deleting
[21:27:49] rakm: Wolland: that looks cool. checking it out
[21:32:16] stef1a: if i set actionmailer.config.raise_delivery_errors = false, the errors will still be logged, right?
[21:50:27] xibalba: hey folks, i'm trying to install cucumber to go through my RSpec book and I'm hitting the following issue on my OSX machine :l http://puu.sh/bAzbQ/d02d70be37.png
[21:52:17] joelataylor: does Rails store the DB table structure in it???s model?
[21:52:33] xibalba: i think config/schema.rb
[21:52:43] centrx: joelataylor, no
[21:52:46] centrx: joelataylor, well, what do you mean
[21:52:50] stef1a: db/schema.rb
[21:52:59] stef1a: /db/schema.rb
[21:53:06] joelataylor: well, I???d like to add some new rows to an existing table
[21:53:14] joelataylor: do I manually create a new migration?
[21:53:21] stef1a: yes, you create a migration
[21:53:24] stef1a: you don't edit /db/schema.rb
[21:53:27] joelataylor: or can I define the fields in a model somewhere and auto generate a migration?
[21:53:33] pipework: joelataylor: No.
[21:53:36] helpa: joelataylor: http://guides.rubyonrails.org/migrations.html - Migrations Guide by Frederick Cheung
[21:53:36] pipework: joelataylor: !migrations
[21:53:37] stef1a: no. manually create a new migration.
[21:53:49] pipework: by manual, they mean use the migration generator.
[21:54:05] joelataylor: haha, ok I think I understand
[21:54:12] stef1a: yes indeed
[21:54:33] joelataylor: I have been reading that guide - but just wanted to double check that the model didn???t define the table schema
[21:56:42] xibalba: it seems pulling in the latest cucumber did the trick, that other version must be broken
[22:00:27] NBarnes: Stupid question: what does a * mean before an argument in rdoc?
[22:01:48] agent_white: NBarnes: Like this? http://stackoverflow.com/questions/5249537/naked-asterisk-as-parameter-in-method-definition-def-f
[22:02:22] NBarnes: No, like, just method(*arg)
[22:02:36] NBarnes: My brain doesn't work from hours of working with Twitter's API today
[22:06:23] magg: hello i???ve trying to add a css and js to the asset pipeline, but i can???t get compiled file
[22:06:38] momomomomo: NBarnes: ah, you had to work with one of the most well documented APIs? damn!
[22:06:54] NBarnes: I didn't say things couldn't be worse. :P
[22:07:38] NBarnes: Technically, I'm trying to work with the twitter gem. Which is radically less well-documented.
[22:07:40] magg: basically i added a swagger.js and swagger.css files in a rails engine
[22:08:34] magg: the files???s content can be found here: https://github.com/d4be4st/swagger-ui_rails??? just a require line in each file???. i can???t get the precompile to work with those two files
[22:09:44] glundgren: rhizome: how can i do a .where to a method in a model? i mean, like that method you mentioned
[22:10:02] glundgren: i tried attr_accessor
[22:10:07] glundgren: not working...
[22:12:12] momomomomo: glundgren: time to hit the docs / google
[22:12:23] glundgren: momomomomo: ok
[22:14:21] Xapht: Hello everyone, wondering if anybody could shed some light on why I cant install spree_multi_store on 2.3-stable? How is a HABTM an undefined method? Gemfile: https://gist.github.com/RyanSugarwork/ad977b2a98a7b49f3c2a Error: https://gist.github.com/RyanSugarwork/4158f57c32087ca5799e
[22:17:18] glundgren: momomomomo: hard to find :P
[22:17:30] helpa: How to ask good questions and get great answers: http://www.mikeash.com/getting_answers.html
[22:17:52] NBarnes: Basically, I'm trying to figure out why http://rdoc.info/gems/twitter/Twitter/REST/Tweets:oembeds isn't working for me and wondering if it's because I'm too noob to read the docs correctly. It looks like it takes an Enum of Tweet objects, yes?
[22:18:18] momomomomo: Xapht: #spree
[22:19:24] momomomomo: NBarnes: https://github.com/sferik/twitter/blob/master/spec/twitter/oembed_spec.rb
[22:20:27] Anup2015: I have joined this community through irc for the first time. Hope you all can get my message
[22:20:34] NBarnes: Anup; I see you
[22:20:40] Anup2015: thanks a lot!!
[22:22:35] glundgren: guys, how can i use a method in model to make a .where ? ex.: in a nested model, i have def final_date start_date + number_of_days.days end, then, in the parent model, i make a nestedinstances.where('final_date < ?', Time.today) but it doesnt seem to work
[22:22:45] glundgren: how can i do it?
[22:24:35] NBarnes: momomomomo; the spec doesn't appear to have actual examples of the use I'm looking for.
[22:24:47] NBarnes: it appears to be entirely concerned with proper recognition of URI resources.
[22:25:45] momomomomo: NBarnes: bummer, I???d look around on GH or ask on the mailing list if you can???t get the desired result
[22:25:57] NBarnes: Yeah, I'm coming up on that.
[22:27:30] NBarnes: What does method(*arg) mean, though?
[22:27:59] cs44: anyone using Okta with rails/
[22:28:02] agent_white: It catches the rest of the args.
[22:28:20] cs44: i'm giving https://github.com/primedia/okta_saml a test drive
[22:28:21] NBarnes: So it has arg as a parameter along with whatever else is passed?
[22:28:31] cs44: curious to hear what other have implemented
[22:28:47] elaptics: what is okta?
[22:29:12] cs44: one of these "enterprise" single sign on services
[22:29:32] cs44: like Omniauth apparently
[22:29:46] agent_white: NBarnes: It's called the "splat operator" in ruby. http://endofline.wordpress.com/2011/01/21/the-strange-ruby-splat/
[22:31:14] NBarnes: thank you, agent_white
[22:32:45] NBarnes: Ah, ok, I see.
[22:33:06] agent_white: I just think of it as a net that catches everything else.
[22:33:37] NBarnes: method(*arg) will take an arbitrary number of parameters and stuff them all into an enum called 'arg'
[22:33:45] agent_white: Then you have a splat without a keyword tied to it, and the double splat. http://stackoverflow.com/questions/18289152/what-does-a-double-splat-operator-do
[22:34:56] pipework: Ruby-on-trails of tears
[22:42:13] NBarnes: ARG NO. It works in pry but not in the app!? Kaaaaaahhhhhnnnnn!
[22:43:01] momomomomo: NBarnes: unit test
[22:43:37] NBarnes: Stop being right, it's rude and makes others pout.
[22:43:47] pipework: It also gives me gas.
[22:47:21] NBarnes: Also, you want embarrassing... problem solved. Variable name typo on my part.
[22:47:38] NBarnes: I'm going to go take a vow of silence and live out my humiliating in a monastery.
[22:48:46] momomomomo: that???s not embarassing, that???s a common bug, which is why unit testing can be important; though, I haven???t been doing much of it myself lately :p
[22:49:05] NBarnes: I usually skim on unit testing and go right for functional testing.
[22:51:39] pipework: NBarnes: Must be slow, comparatively.
[22:52:02] pipework: I generally push my tests down as far into the depths of the system as reasonable presuming that it's worthwhile to do so.
[22:52:20] NBarnes: I try to do that. But I do tons of front-end work, where I find it's not often practical to do so.
[22:52:46] Limix: devise vs doorkeepers? Any thoughts? I need roles as well. Thanks
[22:53:21] momomomomo: I???ve used devise + cancan in the past; my newest app is just a bunch of engines, though, with roles as engines as well
[22:53:45] momomomomo: a la http://tech.taskrabbit.com/blog/2014/02/11/rails-4-engines/
[22:53:47] rhizome: Limix: authentication and authorization are different things
[22:54:32] Limix: I need both
[22:54:45] Limix: does doorkeeper do authorization as well?
[22:54:55] Limix: In the past I???ve used pundit and devise
[22:54:55] momomomomo: I don???t know , did you read their README
[22:55:11] Limix: it seems like it does, just hoping to get some feedback
[22:55:25] momomomomo: ???Doorkeeper is an OAuth 2 provider for Rails.???
[22:55:43] momomomomo: authorization being ???roles??? etc is not in the scope (for your app) of just doorkeeper, plainly
[22:56:37] Limix: so can you use doorkeeper with pundit? Whats a good combo these days for authentication and authorization?
[23:01:01] startab: Is there a more convenient way to permit nested parameters than something like `params.require(:first_name, :{:course => :title}, {:course => :duration})`?
[23:02:34] momomomomo: course: [:title, :duration]
[23:04:11] SloggerKhan: Is Pundit reputable?
[23:04:24] rubyonrailed: I'm upgrading from 3.2 to 4.1 and having problem with creating a object. User.create(params) works, but I can't use `post :create, :user => params` Does anyone have an idea?
[23:04:56] startab: I was under the impression the array value meant the controller would be have to receive the parameter as an array contraining hashes with the permitted attributes therein, e.g. course: [:title, :duration] == [{:course => {:title => "foo", :duration => "bar"}, etc]]
[23:05:06] startab: *containing
[23:05:47] momomomomo: rubyonrailed: http://edgeguides.rubyonrails.org/action_controller_overview.html#strong-parameters
[23:06:15] momomomomo: startab: try it
[23:06:44] elaptics: SloggerKhan: yes, pundit is great
[23:07:04] SloggerKhan: I just came across it and am wishing I'd found it earlier.
[23:07:10] rubyonrailed: I'm using the protected_attributes gem for now, shouldn't that allow me to post?
[23:07:59] SloggerKhan: Every damn google search for authorization/permission/roles always seems to lead to CanCan or CanCanCan.
[23:09:18] momomomomo: cancan was great when I used it
[23:09:30] momomomomo: just add a role bitmaska nd you???re good to go
[23:09:53] twilling: i'm very interested in RoR. I'm coming from another language and I'm wondering what you think is the minimum knowledge one must have before they can be accepted as a junior level Rails engineer?
[23:11:02] momomomomo: twilling: know ruby, know rails
[23:11:10] helpa: Learn Ruby by reading this book - http://manning.com/black3 - The Well-Grounded Rubyist by David A. Black
[23:11:24] momomomomo: http://www.railstutorial.org/
[23:11:45] twilling: I guess that's partly what I mean - what is "knowing"?
[23:12:13] twilling: Obvioulsy the ability to write CRUD applications but how far beyond that do you think?
[23:12:32] twilling: Just looking for some opinions :)
[23:13:10] twilling: momomomomo: also, thanks for the titles. I hadn't heard of TWGR before
[23:13:28] SloggerKhan: momomomomo: They're incredibly unwieldy if you have a lot of models and have less than clear ways of controlling access to attributes. Just the fact that Pundit makes it easy to have policies for post/put attributes and have a policy for each model makes it seem a lot better than the CanCan family.
[23:14:24] momomomomo: IIRC I had some pretty dope nested association role definitions SloggerKhan
[23:14:49] momomomomo: twilling: a good tip is to get learning, rather than asking about what point you should learn to
[23:15:02] glundgren: whats better? [1,1,1].reduce(:+), [1,1,1].inject(:+), [1,1,1].sum(:+)?
[23:15:31] momomomomo: whichever you prefer
[23:15:34] pipework: glundgren: In what way?
[23:15:40] momomomomo: sum seems to be more expressive in this instance
[23:15:41] glundgren: performance
[23:16:04] pipework: glundgren: You have access to the same benchmark tools I do. Use 'em! :D
[23:16:21] momomomomo: pipework: glundgren it???s a waste of time to benchmark that
[23:16:23] glundgren: pipework: i dont know any, wich one can i use?
[23:16:30] momomomomo: glundgren: use any one which you like
[23:16:33] pipework: glundgren: If you're curious, try benchmark
[23:16:45] twilling: momomomomo: i'm of the mindset that you can never learn enough and that being humble is an important quality for a great engineer. i'm not asking for validation or anything. i know what a junior PHP dev looks like but I'm not sure how RoR devs equate
[23:16:52] momomomomo: if you care about performance that in-depth, you wouldn???t be using ruby; but yes, benchmark it for your own interests
[23:17:05] glundgren: no, im not worried about it
[23:17:10] glundgren: but as im writing code
[23:17:15] glundgren: this kind of issues comes to mind
[23:17:22] momomomomo: glundgren: that???s a non issue
[23:17:24] pipework: glundgren: Profile before worrying.
[23:17:39] glundgren: sorry, this kind of curiosity :0
[23:17:50] SloggerKhan: twilling: I'd hire a junior rails dev who didn't know rails if I thought they were a good coder.
[23:17:51] pipework: glundgren: Then benchmark for the fun of it.
[23:17:52] momomomomo: N+1 will hurt you many times worse https://github.com/flyerhzm/bullet
[23:19:21] twilling: SloggerKhan: those employers win lots of points with me. i'm very impressed when an employer will make that kind of investment in someone to allow them to learn on the job
[23:19:48] momomomomo: twilling: it???s with the expectation that you???ll be learning on the job frequently
[23:19:48] glundgren: planos.map { |p| p.quantidade.to_i if p.data_fim > Time.now }.sum solved this way
[23:20:04] glundgren: the .where with model method ...
[23:20:28] twilling: momomomomo: i think that's the best way to learn. but the other side of that is that i think you have to be the type of person who is motivated to learn too
[23:20:36] twilling: which i assume the interviews usually weed out
[23:20:44] twilling: (cont) those types of people
[23:21:14] NBarnes: That's the best way to hire people. If you invest in people, the people invest in you. If you treat your coders like mercenaries, they'll behave like mercenaries.
[23:21:48] glundgren: whats better or its irrelevant? planos.sum(:quantidade) or planos.map{|p| p.quantidade }.sum
[23:22:00] momomomomo: twilling: to give you an example of what it???s like to be in an engineering role that???s actually expected to learn constantly (rather than those that say you???ll need to be a quick learner, and put you in maintenance mode) is a couple months back I had to pick up some java, write a couple hadoop jobs, configure a hadoop cluster, serve thousands /hits/second and deploy to production in a month
[23:22:00] NBarnes: I had a position which I liked and wanted to make a longer-term commitment to. They, in not _quite_ so many words, told me to go piss up a rope.
[23:22:15] NBarnes: When they tried to retain me with a raise six months later, I, in turn, told them to piss back down the rope.
[23:22:16] momomomomo: you won???t be obviously there yet, but any employer understands that you need to be able to learn
[23:22:23] momomomomo: and it???s expected
[23:22:51] momomomomo: oh, and I also had to do some large scale web crawling, etc etc etc
[23:23:05] momomomomo: all employers understand that challenges require learning
[23:23:23] momomomomo: well, the ones worth working for anyhow
[23:24:31] twilling: momomomomo: careful when you say "all" :) my first gig had me spinning up websites with horrible deadlines. but it was a learning experience. lots of trial by fire. i learned the basics of setting up a VPS and have since managed my own VPS' ever since and became much more of a full-stack developer rather than someone who was really focused on front-end. Which ultimately showed
[23:24:31] twilling: me that I really enjoy programming
[23:24:51] momomomomo: "momomomomo: well, the ones worth working for anyhow"
[23:25:06] twilling: oops :) i agree
[23:25:29] momomomomo: ok irc time is up, gotta go
[23:30:45] twilling: NBarnes: that's a bummer. it's really hard to come back from feeling unappreciated as an employee
[23:30:51] twilling: unappreciated/disrespected
[23:33:11] rubyonrailed: What is this? https://gist.github.com/anonymous/4e6fc8cb174968df1883
[23:37:10] startab: Do Rails shops tend toward RSpec, test_unit/minitest, or down the middle?
[23:40:14] joelataylor: how can I run a ruby command in osx terminal?
[23:40:54] twilling: joelataylor: do you just want to a single command or do you want a console where you can run them?
[23:41:14] joelataylor: twilling: yeh, like print the current DateTime
[23:41:28] joelataylor: I guess a console would be more appropriate
[23:41:47] twilling: joelataylor: np
[23:41:57] twilling: ctrl+z to get out
[23:47:15] RxDx: please, I am requesting a json with "created_at":"2014-09-15T22:18:39.080Z"... Im trying to parse it with a library that has this setter: .setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") but im getting a "com.google.gson.JsonSyntaxException: 2014-09-15T22:18:39.080Z"... anyone know the correct pattern?
[23:54:10] Radar: "with a library" which library?