« Back to channel list

#RubyOnRails - 17 September 2013

« Back 1 day Forward 1 day »
[00:00:38] EminenceHC: Radar: In the future I will have multiple separate profiles like student connected to the user model. The user model will have common fields but Student will have fields that don't apply to any of the other models.
[00:07:03] butblack: How can I use ActiveRecord to filter for all posts that have a user_id of 3?… I put a gist together to provide a sample https://gist.github.com/ebbflowgo/6588376
[00:11:33] EminenceHC: Radar: I cleaned up the code and put them into separate files. https://gist.github.com/charlesnutter/6588229
[00:12:45] gwillen: butblack: Post.find_by_user_id(3) or Post.where(:user_id => 3)
[00:12:54] gwillen: sorry, find_all_by_user_id
[00:13:28] Radar: EminenceHC: sounds really complex :(
[00:14:32] gwillen: butblack: oh, hm -- can you explain your data model a little more? What does 'post_id' represent? What are the objects in the table, if they're not posts (since a post can be one or more of them)?
[00:15:30] butblack: gwillen: a post is just that an article, a post may have many users authoring it so my posting table has post_id and user_id
[00:17:22] EminenceHC: Radar: As opposed to what? Single table inheritance? Or compared to putting all the fields in one user model?
[00:17:39] Radar: EminenceHC: all the fields in one model would make more sense to me
[00:17:53] Radar: I don't understand right now why student and users are two separate tables if they're representing the same real-life entitires
[00:17:57] Radar: entities*
[00:18:21] EminenceHC: Radar: It just seems like there may be like 50 fields that belong to a student and only 5 or so that belong to a counselor.
[00:18:35] Radar: EminenceHC: then create one table for students and one table for counselors
[00:18:42] Radar: different login areas for both
[00:19:52] EminenceHC: Radar: So if they were in separate tables they would have a has many relationship to user?
[00:20:00] butblack: gwillen: I updated my question to make it more clear https://gist.github.com/ebbflowgo/6588376
[00:20:22] butblack: gwillen: essentially, I'd like all entries for the posts that have user_id 3
[00:20:31] butblack: gwillen: returning the user_id
[00:20:40] butblack: but that's not necessary, it can just be the entries
[00:21:00] gwillen: butblack: so, the design is a little weird
[00:21:05] Radar: EminenceHC: yes
[00:21:29] gwillen: butblack: do you have any more data on the Posting model than what you're showing us? Is it all just duplicated for all the entries with the same post_id?
[00:21:47] gwillen: butblack: like, presumably you have a post_text column or equivalent; do you just have many copies of it?
[00:21:54] gwillen: or do you have a separate Post model for that?
[00:22:07] butblack: gwillen: well there is a post model and a user model
[00:22:37] gwillen: butblack: I don't see any post text, or title, or anything like that on the model you're showing us. Where does that go?
[00:23:00] butblack: gwillen: in the post model.. this is the foreign key relationship
[00:23:22] EminenceHC: Radar: If I am dealing with students could I call methods inside of the user controller?
[00:23:28] Radar: EminenceHC: which methods?
[00:23:31] gwillen: butblack: ahh ok, so there's Post and Posting, which are separate, and Posting connects between Post and User? Is that right?
[00:23:37] foucist: butblack: Posting.where(:user_id => 3) returns an array of the two posts, post 7 and 8 does it not?
[00:24:06] gwillen: butblack: so you're asking for all the Postings for a particular user, but don't you just want the Post?
[00:24:06] EminenceHC: Radar: Instead of calling User.create I would like to call Student.create and have it automatically create a user.
[00:24:12] gwillen: butblack: (or the Posts?)
[00:24:42] butblack: id like all associated users with the posts
[00:24:57] butblack: gwillen: I can write it out in two lines.. give me a sec
[00:25:01] gwillen: butblack: I see, what you want is the users
[00:25:06] butblack: gwillen: yes
[00:25:21] gwillen: butblack: if it were me, I would do it in two steps -- first get the Posts, then get the Users from the Posts
[00:25:39] gwillen: butblack: do you know about has_many :through?
[00:25:42] gwillen: it will be helpful here
[00:25:52] butblack: gwillen: that's how it's setup
[00:27:22] gwillen: butblack: hold on, I'm looking something up
[00:27:29] butblack: gwillen: it would be something like below https://gist.github.com/ebbflowgo/6588376
[00:27:29] Radar: EminenceHC: Why not have a StudentsController and a CounsellorsController?
[00:28:28] gwillen: butblack: so for x I would do something like User.find_by_id(3).posts
[00:28:44] gwillen: butblack: you can set that up if you have has_many :posts :through => :postings on User
[00:29:25] gwillen: butblack: then I think I would do User.joins(:posts).where(:posts => {:id => x})
[00:29:30] gwillen: butblack: that should find all the users in one query
[00:29:42] butblack: gwillen: kk let me have a try
[00:29:42] gwillen: oh, add .uniq on the end to avoid duplicates
[00:29:46] butblack: gwillen: yeah ;)
[00:30:00] gwillen: it feels like there might be a slightly nicer way but I can't come up with it
[00:30:30] EminenceHC: Radar: That is fine I was planning on doing that polymorphic or not but it seems like if I dont use polymorphic the controller wouldn't assume properties of the user model?
[00:30:57] Radar: EminenceHC: What User model? I thought we agreed on there being a Student model and a Counsellor model?
[00:31:42] EminenceHC: Radar: Well both of those models would have common fields, like user name..
[00:32:02] EminenceHC: Radar: It seems I dont want to repeat myself and add the user name field to both models?
[00:32:18] Radar: EminenceHC: Please hire a consultant who can talk you down from the ledge of STI.
[00:34:08] foucist: EminenceHC: how's Radar's driving?
[00:35:57] butblack: gwillen: I had to do something like this User.joins(:posts).where(:posts => {:id => x.pluck(:id)})
[00:36:26] gwillen: butblack: hm, as far as I know you shouldn't have to do that
[00:36:34] butblack: gwillen: adding the pluck, the non-pluck didn't work I was getting an error of "there is no parameter $1"
[00:36:51] gwillen: butblack: can you pastebin the actual error in its entirety?
[00:36:56] gwillen: I'm curious because that _should_ work
[00:37:30] butblack: gwillen: give me a sec
[00:37:31] gwillen: butblack: as long as the User model has :id as the primary key, but that's the default as long as you don't mess with it
[00:37:34] gwillen: butblack: thanks
[00:39:51] butblack: gwillen: updated : https://gist.github.com/ebbflowgo/6588376
[00:44:32] gwillen: butblack: curious. Since you've got something that works I won't worry too much about it, I guess.
[00:44:41] gwillen: butblack: but that really should work.
[00:44:53] butblack: gwillen: yeah, I thought so too, I'll throw in some testing so if it ends up breaking I'll know
[00:45:00] gwillen: butblack: *nods*
[00:45:39] s2013: isnt this valid total += reg.num_seats
[00:45:50] s2013: or am i confused and there is another way to do total = total + reg.num_seats
[00:46:20] butblack: s2013: what's your error?
[00:46:27] optobear: s2013: the two are equivalent in ruby, yes
[00:46:34] s2013: NoMethodError: undefined method `+' for nil:NilClass
[00:46:38] s2013: ill paste the code one sec
[00:46:43] s2013: i was just trying in console
[00:47:10] s2013: m.registrations.each { |r| total += r.num_seats } this is what i was trying. maybe i made a stupid error
[00:47:35] optobear: s2013: so, it's applying the + operator to a nil...
[00:47:49] s2013: i guess i gotta declare total = 0 beforehand
[00:48:00] SegFaultAX: Or use inject
[00:48:17] optobear: s2013: see also ^
[00:48:24] SegFaultAX: m.registrations.inject(0) { |memo, reg| memo + reg.num_seats }
[00:48:33] s2013: oh i forgot about inject
[00:48:46] s2013: thats what i love/sort of dislike about ruby. 20 ways of doing the sam ething
[00:49:06] SegFaultAX: s2013: Some would say that's a feature.
[00:49:48] s2013: why is it inject(0)?
[00:50:01] optobear: s2013: that's the starting value
[00:50:12] SegFaultAX: s2013: Supplying an explicit initial value.
[00:50:32] SegFaultAX: s2013: Try it! [1,2,3,4].inject(0) { |a, b| a + b }
[00:51:15] s2013: so a is total usually and b the iteration?
[00:51:26] s2013: not iteration but you know what i mean
[00:52:23] SegFaultAX: s2013: http://ruby-doc.org/core-2.0.0/Enumerable.html#method-i-inject
[00:52:32] s2013: yeah i was reading that
[00:53:15] s2013: http://paste.ubuntu.com/6117340/ is this valid or should i combine them into one method?
[00:53:47] s2013: how would you do it?
[00:54:11] SegFaultAX: s2013: Probably like you have it. Although I might memoize total seats.
[00:54:19] s2013: what does memoize mean?
[00:54:33] SegFaultAX: s2013: Save the calculation so I don't have to do it over and over.
[00:54:48] s2013: oh how would i save it? also it would change though as more people register
[00:54:57] optobear: s2013: it's valid. whether you want to use 2 methods or 1 is down to whether you want to call each of the methods anywhere else imho
[00:55:02] SegFaultAX: @total_seats ||= ... is the common idiom.
[00:55:43] s2013: optobear: gotcha. but it wont affect performance right if there are 2 methods vs 1?
[00:55:54] SegFaultAX: s2013: Not in any meaningful way.
[00:56:00] optobear: s2013: not to a degree that you should care about
[00:56:05] poli: Does ryanb/nested_form gem still works on rails4? If not, are there alternatives?
[00:56:12] SegFaultAX: I mean, every method call has /some/ cost.
[00:56:21] SegFaultAX: But this is Ruby we're talking about, it's slow no matter what you do. :)
[00:56:23] s2013: SegFaultAX: hmm isnt the ||= to check if something is nil or not and then set it to something if it is nil?
[00:56:35] s2013: but the cost is negligible right
[00:56:39] SegFaultAX: s2013: Yes. And all instance variables are nil.
[00:56:57] SegFaultAX: Undefined instance variables, that is.
[00:56:59] s2013: SegFaultAX: yes i know that but what im saying is what if it changes
[00:57:10] s2013: lets say first time it checks that method its 5. second time its 10,e tc.
[00:57:25] SegFaultAX: s2013: Then don't memoize it.
[00:57:27] optobear: s2013: ||= sets it if it is falsy. nil is falsy, undefined is falsy, false is falsy
[00:57:54] s2013: yeah optobear. SegFaultAX thats what im saying so should i just leave it the way it is?
[00:58:11] s2013: anyway to cache it and check if # of registrations changed or not?
[00:58:11] SegFaultAX: s2013: Up to you. We don't know your application like you do.
[00:58:38] SegFaultAX: If each instance of `m` is short lived (eg a single request) it very likely does not matter.
[00:59:02] SegFaultAX: That is to say, the number of registrations is unlikely to change between invocations in a single request.
[00:59:15] SegFaultAX: If it's long-lived, caching it might be less than ideal.
[00:59:27] s2013: oh ok gotcha
[00:59:51] optobear: if you hit both methods independently, use 2 methods, if not, use 1. if there's any chance that memoization may give you a wrong value, don't do it
[00:59:52] s2013: but this caching thing is cool. i did that to few things that wont change
[01:00:04] s2013: learned something new
[01:00:59] SegFaultAX: Although without context, "total_seats" sounds wrong.
[01:01:08] SegFaultAX: Maybe "seats_reserved" or something?
[01:01:17] optobear: s2013: but feel free to use it where appropriate (i.e. where the underlying values won't change)
[01:01:29] optobear: s2013: +1 SegFaultAX
[01:01:33] SegFaultAX: ACTION is assuming `#seating` is the total number of available seats
[01:01:49] s2013: true SegFaultAX i was just trying to do something quick on console
[01:01:49] optobear: sounds right
[01:01:51] s2013: im changing it
[01:01:57] s2013: meant to put total_seats_registered
[01:02:00] s2013: reserved*
[01:02:01] s2013: but got lazy
[01:02:30] SegFaultAX: s2013: Anyway, sounds like you're on a roll. Good luck!
[01:25:38] poli: Should I keep /public/assets under git?
[01:27:11] sevenseacat: thats for precompiled things
[01:27:21] sevenseacat: and it should be empty in dev
[01:27:31] Xander2: for file (documents) uploads - what's better carrierwave or paperclip, or no difference?
[01:27:36] poli: sevenseacat: That's what I suspected. Thanks.
[01:45:17] Xander2: for file (documents) uploads - what's better carrierwave or paperclip, or no difference?
[01:46:13] sevenseacat: pick one, try it
[01:46:51] helpa: Xander2: What you just asked could be classed as subjective. Subjective questions often start flamewars, which are tedious and boring. Try all the available options and see which one suits you the best.
[01:46:51] Radar: Xander2: !subjective
[01:47:16] sevenseacat: Radar: why are you here and not off playing GTAV
[01:47:50] Radar: sevenseacat: it has not arrived yet
[01:48:00] sevenseacat: lol sux 2 be u
[01:48:03] Radar: as a result I have an immense sadness within me that can only be filled by helping the noobs
[01:48:31] Radar: (post hasn't arrived today, typically arrives in the afternoon. Waiting impatiently until then)
[01:52:19] sevenseacat: why in this day and age can you still not manage twitter developer apps like facebook ones
[01:55:06] s2013: i made a big mistake. i named my controller/views/model the wrong thing. is there any quick fix or do i have to go fix each of them individually and rename files, etc?
[01:55:32] s2013: how much is gta v in au?
[01:56:08] Radar: s2013: $89 + shipping
[01:56:09] livecano: Hey guys, I'm trying to load some data using seeds.rb, but can't find a way to add data to a join table using a HABTM association, does seeds.rb work to generate data in a join table at all? thanks for any help
[01:56:18] Radar: s2013: you have to manually rename files
[01:56:28] Radar: livecano: show us the definitions of your habtm associations
[01:56:39] s2013: ok cool. and only $89? is it from online?
[01:56:43] s2013: how about at the store?
[01:56:48] sevenseacat: hah, dick smith are selling it for $79
[01:57:04] sevenseacat: JB is likely cheaper as well >_>
[01:57:10] s2013: ebgames au shows it as $110
[01:57:20] sevenseacat: EB is a complete ripoff
[01:57:36] livecano: I have a class Activity < ActiveRecord::Base
[01:57:36] livecano: # Associations
[01:57:36] livecano: has_and_belongs_to_many :plans
[01:58:02] livecano: and a class Plan < ActiveRecord::Base
[01:58:02] livecano: # Associations
[01:58:02] livecano: has_and_belongs_to_many :activities
[01:58:14] helpa: livecano: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[01:58:14] Radar: livecano: !gist
[01:58:26] Radar: sevenseacat: I bought it from JB. Pre-ordered.
[01:58:35] Radar: didn't know DS was selling it too
[01:58:40] s2013: jb audio or whatever?
[01:58:45] Radar: s2013: jb hifi
[01:58:53] s2013: sorry yea hifi
[01:58:55] s2013: not sure why i said audio
[01:59:04] Radar: livecano: plan.activities << activity_object_goes_here
[01:59:12] Radar: s2013: well, when two cousins love each other very much...
[01:59:23] s2013: whats that other store? the big electronic one
[01:59:24] sevenseacat: http://www.dicksmith.com.au/gta-v
[02:00:27] Radar: interesting… my local store appears to have it in stock
[02:00:39] Radar: Wish I had known about this earlier :)
[02:01:05] sevenseacat: i only saw it because i walk past one on my way to work every day
[02:01:11] s2013: harvey norman
[02:01:34] s2013: i went there to buy this thing.. and cheapeast one they had was $150
[02:01:47] s2013: i bought something similar in the us for $9.99
[02:01:48] sevenseacat: sounds about right
[02:02:00] livecano: This is the gist file https://gist.github.com/livecano/6589209
[02:02:35] Radar: livecano: [11:59:03] <Radar> livecano: plan.activities << activity_object_goes_here
[02:02:36] s2013: livecano: why are you doing User.find(1).id
[02:02:43] s2013: 1 is jus the id in that case
[02:02:50] helpa: livecano: How to use Gist properly: https://github.com/radar/guides/blob/master/using-gist.markdown
[02:02:50] Radar: livecano: !gist-usage
[02:02:51] s2013: unless you are using something else as primary key
[02:03:22] s2013: User.find(1) isnt the same as User.first
[02:03:59] livecano: yeah it is, I was using the foreign key for owner user belongs_to association
[02:04:18] livecano: ohh I see you point
[02:05:50] s2013: also to load it in seed data livecano you dont do it plan_a.activities << activity_a ... etc
[02:06:25] s2013: in Activity.create!(... add plan_id: plan_a.id
[02:07:06] s2013: also your join table isnt conventional.
[02:07:46] s2013: should be activities_plans (name of the table)
[02:08:38] s2013: although plan_a.activities << activity_a should work
[02:08:57] livecano: sorry I put the wrong table in gist I just updated
[02:10:20] s2013: do you get an error?
[02:10:28] livecano: yeah the table plans and activities get the information updated, but no error at all
[02:10:32] s2013: also sortty to nitpick its reservoir
[02:11:54] spyzer: hello guys, when there are five user types and i have to place a check like *is_<the type>* which lets me call is_admin, is_advisor etc. Is there some better way than using method missing?
[02:12:06] spyzer: and User is a model
[02:12:31] livecano: just updated reservoir, did seeds.rb support HABMT associations?
[02:12:47] livecano: I mean filling info in the join table?
[02:13:41] s2013: i dont see why not
[02:14:43] spyzer: i mean do people use it for the kind of use case i mentioned or do they make an API like *user.is_of_type(<the type>)*
[02:16:07] gwillen: spyzer: honestly I would be tempted to just write the 5 methods by copy-paste
[02:16:21] gwillen: I know it's slightly redundant, but they'll be _extremely_ short and there aren't that many of them
[02:16:34] gwillen: method_missing is a really big hammer for something like that, it will make the code harder to understand
[02:17:53] optobear: spyzer: kinda up to you. points for keeping it simple and esay to understand (+1 gwillen). fwiw, ruby convention prefers methods called x? to is_x
[02:18:32] livecano: can't find what is wrong, there is no error msg at all when running rake db:seeds
[02:18:44] pontiki: (that would be a good place for internal comments!)
[02:19:33] optobear: spyzer: e.g. having an x? method means you can write an rspec like a.should be_x
[02:19:51] spyzer: optobear: yeah
[02:20:06] sevenseacat: i would discourage the use of the is_ prefix
[02:20:22] gwillen: yeah, == sevenseacat, the ? suffix is traditional, use that
[02:20:40] jrobeson: hello peoples
[02:20:48] sevenseacat: morning jrobeson
[02:21:05] creativetim: i'm new to rails and want to build my own flagging system, but i'm a little lost on how i should be thinking about the associations. i know there are gems that do this, but i want to create my own.
[02:21:05] creativetim: i want a Voter to create Flags on Polls and Resources.
[02:21:14] jrobeson: sevenseacat, morning.. that's crazy talk
[02:21:28] pontiki: hi jrobeson
[02:22:05] scyllinice: Speaking of is_
[02:22:07] scyllinice: http://imgur.com/RkLJFVh
[02:22:11] eddrain: if i want to use a value from javascript in rails, how do I do that?
[02:22:13] jrobeson: doing anything fun pontiki ?
[02:23:07] scyllinice: eddrain: Post it to a controller action?
[02:23:09] creativetim: Polls has_many :flags
[02:23:10] creativetim: Resources has_many :flags
[02:23:11] creativetim: Flags belongs_to :voter
[02:23:12] creativetim: Voters has_many :poll_flags, through :polls, source :flags
[02:23:13] creativetim: Is that overkill?
[02:23:15] scyllinice: eddrain: Or do you mean share back and forth?
[02:23:24] jrobeson: visibleEh? hah
[02:23:27] s2013: creativetim: okay lets walk through this. whats resources?
[02:23:34] eddrain: how to post it to controller?
[02:23:51] s2013: do you want to track who flagged what or just sort of count it?
[02:23:56] scyllinice: You do plural model names?
[02:24:12] s2013: and yea you should singularize the model name
[02:24:12] spyzer: what is a good practice to enqueing mailers to sidekiq, sending from models or from controllers?
[02:24:13] pontiki: jrobeson: nah
[02:24:27] creativetim: s2013: Resources are links. I envision having a xref table where it houses who flagged what and a counter_cache on each model so I don't have to generate a bunch of queries.
[02:24:30] sevenseacat: spyzer: controllers.
[02:24:31] jrobeson: pontiki, :(
[02:24:39] pontiki: jrobeson: spent yesterday futzing with twitter bootstrap 3
[02:24:55] scyllinice: eddrain: Use jQuery
[02:25:00] pontiki: redid my online resume thing
[02:25:05] scyllinice: It's bundled with rails
[02:25:36] jrobeson: pontiki, less or sass?
[02:25:47] scyllinice: Is there a real choice?
[02:25:53] pontiki: neither, really, just using what's there
[02:25:55] eddrain: sorry but how to use Jquery to send info to rails?
[02:25:56] scyllinice: Only one of them makes sense
[02:26:17] scyllinice: eddrain: http://api.jquery.com/jQuery.post/
[02:26:18] creativetim: s2013: The basic function I'm creating is the ability for a Voter to Flag a Poll and/or Resource as inappropriate. After something has been flagged more than 10 times I don't want to return it in queries.
[02:26:32] s2013: ok. do you want to track who is flagging?
[02:26:32] scyllinice: eddrain: That's one way
[02:26:33] pontiki: jrobeson: i just used the cdn
[02:26:33] jrobeson: pontiki, ah so you just downloaded the css files
[02:26:44] creativetim: Yes, I would like to have a history of that.
[02:26:45] jrobeson: no fancy mixins and whatnot
[02:26:58] s2013: Voter has_many :resources, through: :flags
[02:27:01] s2013: id do it that way
[02:27:03] pontiki: jrobeson: still just dabbling with what's there
[02:27:07] jrobeson: i used bootstrap-sass this time
[02:27:11] pontiki: learning the new grid system
[02:27:36] s2013: Resources has_many :voters, through: :flags
[02:27:44] s2013: Flag belongs_to :voter as well as the :resource
[02:27:54] s2013: flag model should have voter_id and resource_id
[02:27:57] s2013: does that make sense?
[02:28:03] s2013: someone correct me if im wrong but thats how id approach it
[02:28:19] jrobeson: all i can say is show more code
[02:28:25] creativetim: It makes sense, for the most part.
[02:28:43] creativetim: Voter already has_many :resources because Voters create Resources in the first place.
[02:28:48] s2013: but that brings a question i have. can you have multiple association between two models?
[02:29:17] jrobeson: i feel like the thoughtbought people have a nice little approach going on as well for such things
[02:29:22] pontiki: you can, but you need to specify the keys and tables
[02:29:25] jrobeson: grids ands and whatnot
[02:29:26] s2013: creativetim: you can do Voter has_many :flags, class_name: 'Resource'
[02:29:39] s2013: pontiki: would that work you think?
[02:29:40] eddrain: scyllinice thank you
[02:30:02] pontiki: jrobeson: right now, my online res looks like someone who discovered they can use multiple fonts in a word doc
[02:30:07] creativetim: That doesn't make sense to me. It's as if you're saying Flags are Resources and that doesn't add up.
[02:30:09] s2013: Voter has_many :flags, class_name: 'Resource', through: :flaggings
[02:30:13] jrobeson: pontiki, :)
[02:30:29] jrobeson: are you looking for a new job?
[02:30:43] s2013: creativetim: flags aretn resources per say but that is how you are linking them
[02:30:50] pontiki: not too hard, jrobeson
[02:31:00] s2013: its just association
[02:31:04] jrobeson: ah.. just if the opportunity arises
[02:31:10] s2013: so you are associating voter and resource via flags
[02:31:13] jrobeson: always good to be prepared i suppose
[02:31:35] creativetim: Voter and Resource are already associated because a Voter creates each Resource.
[02:31:43] s2013: yes but the voter can also flag
[02:31:48] s2013: so thats a different type of association
[02:32:01] s2013: What if that voter didnt create the resource? how are they linked?
[02:32:12] jrobeson: i'd suggest against using the word resource as a plain word.. especially if you plan on using controllers for resources
[02:32:20] jrobeson: it'd be funny to write resources: resources
[02:32:24] s2013: yeah thats the other thing
[02:32:25] scyllinice: I did an interview today, but I totally suck at the technical portion of interviews. You know, the part that matters.
[02:32:33] creativetim: would voter.rb: has_many :resource_flags, through :resources, source :flags make sense?
[02:32:38] s2013: resources isnt a good name tbh
[02:32:55] pontiki: scyllinice: what did they have you do for the tech part?
[02:32:56] scyllinice: I'm totally skilled to do the work, but if you site me down in a room and watch me code the whole time, it doesn't go well for me. It's a curse :/
[02:32:56] s2013: change it to url or something like that
[02:33:04] creativetim: yeah, routes do get a little funny. o_O
[02:33:08] jrobeson: performance anxiety?
[02:33:14] s2013: brb but someone here can help im sure
[02:33:25] scyllinice: pontiki: Pair programming, which I haven't done much of (read: almost none)
[02:33:31] creativetim: thanks s2013!
[02:33:36] s2013: np good luck
[02:33:41] jrobeson: oh.. i'd totally fail that :(
[02:33:44] s2013: some companies take pair programming to the extreme and its stupid
[02:33:47] scyllinice: It makes me second guess myself, and I know better than that
[02:33:47] s2013: and waste of clients money
[02:34:00] scyllinice: So even the simplest things become hard
[02:34:02] pontiki: it's like any practice
[02:34:03] s2013: see pivotal labs
[02:34:08] jrobeson: i think it's an important skill to have.. i just don't have it (yet)
[02:34:31] pontiki: too much is not good, too little is not good, but finding where it's just right is goldielocks
[02:35:13] creativetim: i think, like anything, there's generally a balance to be struck that creates efficiency
[02:36:00] scyllinice: I did get a high five from the interviewer during the technical chat section though
[02:36:14] scyllinice: Apparently he is also a fan of composition over inheritance
[02:36:59] jrobeson: it's hard to find tutorials for rails stuff that use composition by default
[02:37:10] jrobeson: so you can get an idea on where people are coming from in that way
[02:38:08] jrobeson: scyllinice, and yet.. there is no no really decent datamapper ORM for ruby..
[02:38:27] jrobeson: and i don't mean the current datamapper orm :)
[02:39:35] pontiki: what would that be, jrobeson
[02:39:48] scyllinice: Why bother when you can monkey patch the hell out of everything and metaprogram the rest
[02:40:57] jrobeson: pontiki, like doctrine2 on php .. or hibernate
[02:41:33] jrobeson: scyllinice, but rom-rb seems to be a good effort
[02:42:28] jrobeson: scyllinice, http://rom-rb.org/ .. but it doesn't handle any rdbms yet :(
[02:42:32] pontiki: what is it about those that you consider "really decent" ?
[02:42:35] jrobeson: or use a real Unit of Work
[02:42:41] pontiki: i couldn't stand hibernate
[02:42:45] pontiki: but i hate xml, too
[02:43:01] jrobeson: ah i meant like how you worked with it in your code
[02:43:25] jrobeson: not how you define relations.. you could define relations in a way similiar to active record migrations just as easily in ruby
[02:43:30] pontiki: i also couldn't much stand writing java, so...
[02:43:37] jrobeson: most people in doctrine use yaml or annotations
[02:44:18] jrobeson: but yes.. in effect it would look almost the exact same as it does now
[02:44:24] pontiki: i never used doctrine in php
[02:44:47] jrobeson: the difference is where you use it .. the object has no save method. you don't inherit from a base class
[02:46:15] jrobeson: pontiki, i think that having an object responsible for persistence breaks the single responsiblity principle
[02:46:50] pontiki: i don't disagree with that, really
[02:47:45] pontiki: that models in rails a primarily about persistence does create problems
[02:47:57] pontiki: they don't have to be
[02:48:16] pontiki: and from an architectural point of view, it's really irrelevant
[02:48:56] pontiki: i think DHH felt you should just completely ignore the fact that models are persisting
[02:49:15] sevenseacat: i dont think its unreasonable that a model knows how to save itself
[02:49:17] jrobeson: you still have to call save on them though.. or create in this case
[02:50:24] pontiki: sevenseacat: i don't think it's unreasonable the model knows that, but it's not necessary to expose it, either
[02:51:08] jrobeson: it feels coupled and constraining in the current way
[02:51:16] jrobeson: at least ActiveModel is a thing now..
[02:54:28] jrobeson: i guess in the near future.. you'll just be able to pick the one you want and still be able to do all the stuff
[03:04:10] scyllinice: Like most things, apply the rule where it makes most sense. Don't just blindly apply it. It's just as bad as never using it
[03:23:03] echosystm: anyone her efamiliar with minimagick?
[03:23:41] helpa: Don't ask "does anyone use <thing>?". It's better to just state your problem and if anyone has used <thing> they will most likely answer.
[03:24:50] echosystm: ok, can anyone point me toward some details on how to resize an image from a stream?
[03:25:03] echosystm: i dont care what library is being used, as long as it is efficient
[03:25:23] echosystm: i must be able to define the stream myself though - its not a file, url, etc.
[03:26:10] echosystm: minimagick seems to be able to do this, but using some IOStream object i cant find anywhere in the docs or standard library
[03:27:20] krz: whats the best way to map time_zones to regions of the world
[03:27:22] jrobeson: echosystm, the IO docs talk about streams
[03:32:17] jrobeson: so far the only reference i found to iostream is from paperclip echosystm
[03:32:29] echosystm: jrobeson: thats what i just found too
[03:32:53] jrobeson: well i'm assuming that one can implement their own subclass of IO
[03:32:55] echosystm: so i have to include paperclip in my project to use an unrelated library
[03:32:59] echosystm: awesomesauce
[03:33:00] jrobeson: to build their own stream
[03:33:12] jrobeson: echosystm, i assume that was just an example
[03:33:23] jrobeson: if you have your own custom stream.. then build it.. and use it
[03:33:29] jrobeson: as long as it implements IO it should work
[03:33:37] optobear: krz: how do you mean?
[03:33:58] jrobeson: echosystm, when people say that it really does sound kinda whiny
[03:34:17] jrobeson: feel free not to use any of it.. and deal with it yourself
[03:34:20] echosystm: looking at the code... i need to implement something that just has a read(bufflenght) method
[03:37:08] krz: optobear: ive got a list of timezones. id like to convert/map them into regions of the world
[03:37:26] krz: i.e. Singapore/KL timezone = Asia
[03:37:42] sevenseacat: Asia, and parts of Australia
[03:38:09] krz: i think AU belongs to the Oceania region
[03:38:10] sevenseacat: unless you mean the named timezone and not just the offset
[03:38:38] jrobeson: timezones :(
[03:38:44] krz: yea just the named timezone, no offset
[03:39:16] sevenseacat: well you have the names there - Singapore and Kuala Lumpur, you know where they are on a map
[03:39:59] krz: well yea, but was wondering if there was some kind of library, database (similar to maxminds's geoip) but for mapping time zones to regions
[03:40:49] optobear: krz: what is a region in your concept? couintry? continent? state? province?
[03:41:13] krz: optobear: http://www.nationsonline.org/oneworld/countries_of_the_world.htm
[03:41:16] krz: region section
[03:41:22] krz: http://geography.about.com/od/lists/a/officiallist.htm
[03:41:25] butblack: can someone explain to me how this happens? https://gist.github.com/ebbflowgo/6589813 .. obviously I'm missing something in the request flow
[03:41:47] sevenseacat: what do you mean, 'how it happens'?
[03:41:56] sevenseacat: you mean how rails gets from a URL to params?
[03:41:57] butblack: how can you have params, request.params both have a params[:posts] == "" while request.url posts has values
[03:42:28] sevenseacat: because of the %23 i presume, i dont know what character that is
[03:42:31] butblack: I'm looking to continue the current params[:posts] but I don't know how to grab the current value of params[:posts]
[03:42:37] butblack: its' a # sign
[03:42:55] sevenseacat: right, so anything after a hash doesnt count in the params
[03:43:02] sevenseacat: never has, never will
[03:43:02] jrobeson: you can't get the anchor from ruby
[03:43:12] jrobeson: it's impossible. it's never sent to ruby or php or whatever
[03:43:33] butblack: sevenseacat: ah ok, so I need to get rid on the hash
[03:43:45] butblack: or pound sign or %23… whatever you want to call it
[03:43:57] butblack: thanks, I'll have a look
[03:44:29] sevenseacat: heh, when i think pound i think the british pound symbol
[03:45:11] optobear: krz: that's 2 different sets of region definitions
[03:46:40] butblack: I once read about Richard Feynman, when Richard was young, there was a time where some kid was laughing at him for not knowing the name of a bird… a few days later he was in the park with his Dad and asking him about the name.. in the end his Dad ended up saying something along the lines of… focus on the attributes not the name… always found that interesting
[03:47:25] butblack: … pointing out that the birds name in Hong Kong was completely different than what it was named in America
[03:48:15] optobear: krz: there is an unreliable mapping between countries, regions and timezones. the official ISO timezone list prefixes a "region" name to a timezone - http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
[03:48:26] optobear: krz: that may be as good as you can get
[03:49:39] s2013: how is the rails job market in australia?
[03:49:54] s2013: whats a good site to look for jobs in australia?
[03:50:01] sevenseacat: s2013: http://seek.com.au
[03:50:22] s2013: oh yea forgot about seek
[03:51:06] s2013: you think id have any luck applying there without being an australian
[03:51:21] optobear: krz: and the list is mapped between short and full tz name in ActiveSupport::TimeZone::MAPPING - http://api.rubyonrails.org/files/activesupport/lib/active_support/values/time_zone_rb.html
[03:51:35] optobear: krz: maybe that's what you want?
[03:51:46] sevenseacat: s2013: depends on if the jobs you apply for will accept international applicants'
[03:51:51] krz: ill have a look, thanks optobear
[03:52:23] s2013: how is the rails market in general? are there a lot of demands? in the us, we import tons of people from overseas to fill it jobs. like i think we let in about 700K people
[03:52:51] sevenseacat: better on the east coast than over here. focus your search in melbourne and sydney.
[03:53:12] s2013: yeah i really wanna live in melbourne mostly. lived in sydney for a year.
[03:53:14] optobear: s2013: market was pretty bouyant last i looked. https://groups.google.com/forum/#!forum/rails-oceania is a good place to ask for tips/contacts
[03:53:26] s2013: cool. thanks optobear
[03:53:51] s2013: i did go to university of sydney for a year, if that helps
[03:56:04] optobear: s2013: sydney probably has the bigger market still, but melbs is plenty big enough, and there's pretty high demand for rails. i'm in melbs and it's a lively scene
[03:56:41] s2013: yeah i dont mind sydney either. those are my top choices, sydney/melb. but then again i dont live in australia
[03:56:55] s2013: and am not a legal australian resident
[04:03:13] optobear: s2013: per sevenseacat, ask the employers whether residence is a requirement. some companies may sponsor you. demand may still be high enough
[04:03:37] s2013: yeah but im a newb so its different for me. but yeah ill probably just email some recruiters over there and explain my situation
[04:03:49] sevenseacat: its no different for you
[04:03:54] sevenseacat: you are not a special snowflake
[04:05:22] s2013: thats the whole point.. im a newb so not some special snowflake where it would be easy for me to get sponsored
[04:05:47] sevenseacat: well, do it your way then :)
[04:05:59] echosystm: what country are you in s2013 ?
[04:06:01] s2013: if i was actually skilled then it would be easier to get sponsored. thats what im saying but ill just email them and see what happens
[04:06:04] s2013: usa echosystm
[04:06:17] echosystm: why would you leave the usa? techn jobs are way better over there.
[04:06:45] s2013: they are.. its not even about jobs.. tbh even if the job didnt pay me shit id still doit. its more about the experience
[04:07:03] echosystm: i see, fair enough
[04:07:03] s2013: im only looking for a job to get better at rails and i figured if i can do a 6mos/1yr contract why not do it in another country
[04:07:14] s2013: i havent looked for a job in over 6 years
[04:07:50] s2013: where are you echosystm
[04:08:17] s2013: all the aussies are here now
[04:08:39] sevenseacat: well its the middle of the day, thats why
[04:08:49] s2013: yeah true
[04:08:51] echosystm: i worked in the us for 6 months last year. blew my mind how much people that totally sucked were getting paid.
[04:09:03] s2013: echosystm: where did you work? and yes its true
[04:09:16] echosystm: floria and california
[04:09:21] s2013: cool. how did you like the us?
[04:09:33] s2013: usa is far ahead when it comes to tech stuff than most countries. esp startups
[04:09:37] sevenseacat: lot less of that over here
[04:09:41] echosystm: it was pretty cool. american dream stuff.
[04:09:53] s2013: you enjoyed huge mexican feasts in cali?
[04:10:15] echosystm: nah i was only there for a few weeks and i was working 24x7
[04:10:27] s2013: we do work hard though.
[04:10:42] s2013: the pay here is very good for tech.
[04:11:00] echosystm: i saw a lot of incompetence and nepotism to be honest lol
[04:11:00] s2013: ex: my friend gets $100K + bonus as a mid level rails developer in detroit.. where you can buy a house for like $200
[04:11:24] s2013: well maybe at your company or where you worked. there is def a lot of incompetence especially in california cause they suck.
[04:11:28] echosystm: but thats probably just the companies i was exposed to
[04:11:29] s2013: nepotism exists everywhere
[04:11:48] Radar: til echosystm is in SA>
[04:11:49] s2013: but imo far less in the us than in other places.
[04:12:12] s2013: echosystm: have you heard of pivotal labs?
[04:12:33] s2013: they charge $60K/mo per team (pair of programmers who work together)
[04:12:40] s2013: i dunno. a lot of people i guess
[04:12:54] Radar: Pivotal is a boutique consultancy
[04:12:56] Radar: They do amazing work
[04:13:04] s2013: Radar: have you worked with them or know anyone there?
[04:13:10] Radar: I would rather pay them $60k/month than some idiot developers 5k/month for an entire year.
[04:13:16] Radar: s2013: I know a lot of people there.
[04:13:20] sevenseacat: a couple of the guys who used to work here went to pivotal
[04:13:25] Radar: I crashed in their boulder office for a week last year
[04:13:33] s2013: cool. they are huge though so hardly boutique i guess
[04:13:42] s2013: i met the founder of envy labs. if anyone has heard of them
[04:13:44] Radar: maybe boutique is the wrong word...
[04:13:46] echosystm: im so confused about pivotal
[04:13:50] s2013: specialized probably
[04:13:56] echosystm: do they own spring? what about pivotal tracker?
[04:13:58] Radar: ACTION tries to put it another way
[04:14:00] s2013: yeah pivotal tracker
[04:14:10] Radar: Pivotal is like the navy SEAL team of web dev.
[04:14:27] s2013: so they go after the terrorists (indian developers)
[04:14:27] echosystm: do they own springsource or is that a diffrent pivotal?
[04:14:51] Radar: s2013: It only seems like indian developers are bad because there's more of them.
[04:14:58] Radar: There are good indian developers too
[04:14:58] s2013: yeah i know Radar im mostly joking.
[04:15:44] s2013: but i had to manage a team of indian developers for a client once..never wanted to drive a car off a bridge more so than during those times
[04:16:07] shredding: I'm following the active admin tutorial here: http://www.activeadmin.info/docs/2-resource-customization.html#belongs_to and have a problem:
[04:16:32] s2013: but also one of the best programmers i ever worked with is indian
[04:16:36] shredding: It says: local variable "project" is not defined. That makes sense, as it's not defined. Or am I missing something here?
[04:16:54] sevenseacat: well this sucks, upgrading app from ree to 1.9.3 and everything is going slower
[04:26:44] dcope: when doing find_by_sql do you have to select by * ?
[04:30:26] s2013: yes dcope
[04:30:38] s2013: you basically write the sql query as if you would write any sql queries
[04:31:28] dcope: but rails is smart enough to query relationship tables when those are accessed, right?
[04:31:31] jrobeson: s2013, i wouldn't always select * in any sql query :)
[04:31:41] dcope: or do those have to be queried and joined in the the initial query?
[04:31:56] s2013: jrobeson: you don't. but im pretty sure dcope understood what i was saying and vice versa
[04:32:12] dcope: yep, i understood
[04:32:22] jrobeson: well the default queries rails does is in fact select *
[04:32:44] s2013: dcope: are you talking about when you use find_by_sql ?
[04:32:45] shredding: Found it: https://github.com/gregbell/active_admin/pull/2476
[04:32:50] dcope: s2013: yeah
[04:32:57] s2013: afaik find_by_sql just executes raw sql command unless im mistaken
[04:33:24] dcope: argh so i have to join in all the tables that serve as relationships off of the model i'm fetching?
[04:33:52] s2013: what exactly are you trying to do though?
[04:34:08] s2013: chances are rails has a way to do it already
[04:34:15] sevenseacat: well the better question is, why are you doing find_by_sql
[04:34:35] dcope: sure, so i have a Book model that has many Pages. pages has a view_count. I'm trying to order books by the most viewed pages
[04:34:55] dcope: does AR have helpers for this?
[04:35:12] dcope: i didn't see any so i just wrote a little query that gets the right data and then planned on using find_by_sql
[04:35:40] sevenseacat: do a join and an order? what am i missing
[04:35:58] dcope: sevenseacat: well the pages' view_count must be summed
[04:36:16] sevenseacat: so do a sum in the order?
[04:36:21] sevenseacat: youve got the query, care to share it?
[04:37:08] dcope: sevenseacat: http://pastie.org/private/ubccktpmvuafwzkumdw9w
[04:38:59] sevenseacat: the left outer join is where rails will likely give you trouble
[04:40:16] sevenseacat: why do you need the join?
[04:41:40] dcope: sevenseacat: ah, i actually dont. sorry, been going through different revisions of this.
[04:41:56] dcope: the query works fine without the join since there's the little subquery
[04:42:47] sevenseacat: right, so you could do something like Book.select(id and subquery).order(popularity) ?
[04:44:35] dcope: lets see.. one sec
[04:45:28] krz: at http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html how can i get the constant: mapping ?
[04:45:50] sevenseacat: krz: what have you tried?
[04:46:22] krz: nvm figured it
[04:46:31] optobear: krz: (13:51:20) optobear: krz: and the list is mapped between short and full tz name in ActiveSupport::TimeZone::MAPPING
[05:07:08] s2013: how do i comment out a big chunk of erb?
[05:07:39] optobear: s2013: <% if false %> is one way
[05:07:44] sevenseacat: by pressing delete?
[05:07:50] s2013: optobear: thanks
[05:10:55] dcope: sevenseacat: that worked
[05:11:01] dcope: took a few tries but got it. thanks :)
[05:17:42] s2013: i want to create a custom method called already_reserved? where it checks if the user hasalready reserved for that event. should i put that method in the user model? helper file? event model? controller? kind of confused
[05:23:12] optobear: s2013: i'd say that's business logic, so a model. best to write it so it sounds like as much as possible like natural language when you use it, with as few words as you can get away with. e.g. user.already_reserved_for?(event)
[05:23:20] s2013: let me show you waht i got
[05:23:38] s2013: http://paste.ubuntu.com/6117979/
[05:23:48] s2013: yeah similar to what you said
[05:25:40] s2013: actually i ran into a problem.
[05:28:09] s2013: basically self.registrations returns an array of different events that they are registered for
[05:28:29] s2013: how do i check if one of the registrations includes the argument?
[05:28:53] sevenseacat: registrations doesnt return an array, no
[05:29:04] s2013: what does it return?
[05:29:09] sevenseacat: have a look and see
[05:29:45] s2013: [#<Registration id: 1, user_id: 3, meal_id: 4, num_seats: 10, created_at: "2013-09-15 08:02:34", updated_at: "2013-09-15 08:04:10">]
[05:30:15] s2013: i mean its only 1 item there but isnt that an array?
[05:30:23] sevenseacat: check its class.
[05:30:30] s2013: what do you mean?
[05:30:44] sevenseacat: ask the object what class it is.
[05:31:03] sevenseacat: how are you defining registrations?
[05:31:10] s2013: let me gist
[05:33:02] s2013: https://gist.github.com/ss2k/1a0a080d4f0ef2c3ceba
[05:33:28] sevenseacat: is this an older version of rails?
[05:33:36] sevenseacat: registrations should definitely not be an Array
[05:33:45] s2013: what would it be?
[05:33:50] sevenseacat: an ActiveRecord::Relation
[05:34:56] s2013: they all return array
[05:35:18] s2013: but arent activerecord::relations just an array though?
[05:36:14] s2013: so what am i doing wrong?
[05:36:29] sevenseacat: hmm, whats going on here
[05:37:38] s2013: what do you mean? why isnt it returning activerecord:relation though? do you know
[05:39:20] sevenseacat: they still act like relations
[05:39:34] s2013: if i do .scoped.class it returns ar::r
[05:39:48] sevenseacat: they *are* relations, why do they say array
[05:39:55] s2013: irb(main):028:0> u.reservations.scoped.class
[05:39:56] s2013: => ActiveRecord::Relation
[05:40:05] s2013: but if i do u.reservations.class it returns Array
[05:40:14] sevenseacat: yeah im seeing the same behaviour
[05:41:16] s2013: i dont know. anyways now the thing is that i want to check within whatever is returend if one of the meals are the one that is passed as an argument
[05:41:18] sevenseacat: im guessing calling class evaluates the query and returns you the array
[05:41:33] s2013: http://stackoverflow.com/questions/4176716/is-it-possible-to-get-the-activerecordrelation-object-for-an-association
[05:42:26] sevenseacat: so you're passing in a meal, and you want to compare registrations to a meal?
[05:43:02] s2013: basically registrations (should have been reservations but i screwed up the name.. but oh well) are to a meal
[05:43:30] s2013: current_user.reservations.first.meal will return a meal for example
[05:43:57] s2013: so i want to check if any of the reservations are the meal that is passed. i can do it by looping but i figured there might be a better way
[05:44:31] tagrudev: morning d00ds
[05:44:56] sevenseacat: so something simple like registrations.where(meal_id: meal.id).any?
[05:45:19] s2013: http://paste.ubuntu.com/6118016/ this works
[05:45:22] s2013: but i know thats not the ruby way
[05:45:45] s2013: k that might be better. thanks
[05:46:07] sevenseacat: yeah that way is definitely not the way to do it
[05:46:15] s2013: i know. i was just trying to demonstrate what i wanted to do
[05:46:25] s2013: also do i need to do self.registrations or will just registrations work?
[05:46:25] sevenseacat: failing that, something like reservations.any? { |r| r.meal == meal }
[05:46:33] sevenseacat: try it and see
[05:47:54] s2013: yeah that should work. thanks
[06:00:09] s2013: how do i setup fog environment variables in development?
[06:02:15] sevenseacat: same way you would in production or anywhere else
[06:02:47] s2013: do i keep it in a file or declare it in the command line? im still a bit confused about that
[06:04:02] sevenseacat: the easiest way to do it would be to set them in your shell profile
[06:08:14] echosystm: i have a model with an associated file. would it be bad to have methods on that model for managing the file?
[06:08:48] echosystm: deletion, renaming, etc.
[06:08:57] echosystm: creating a stream object
[06:09:41] echosystm: how do you decide when and when isnt appropriate to put something in the model? i mean youve got all the db stuff mixed in there, so separation of concerns is pretty messy from the get-go
[06:10:00] sevenseacat: well the db stuff still only relates to that given model
[06:10:13] sevenseacat: a Product model only knows how to save/load/etc. Product objects
[06:11:08] echosystm: where would you put the file functions then?
[06:11:13] sevenseacat: on the file model?
[06:11:33] echosystm: so you create a model class for the file
[06:11:41] sevenseacat: huh? you said you had one
[06:11:56] echosystm: no i said i had a model with a file associated with it
[06:11:59] echosystm: i meant literally a file
[06:12:03] echosystm: not a file model
[06:12:18] sevenseacat: right, I thought you meant associated as in rails association
[06:12:29] echosystm: ok, i have my answer
[06:24:44] dweeb_: If I want to show products wihtout any related offers I do Product.includes(:offers).where(offers: { product_id: nil }) but what if I want to show products without offers that has price == 10?
[06:25:11] sevenseacat: then add that into the where
[06:26:41] kke: any grapists? in grape, is there some nice way to define custom types, such as UUID? many of my api's methods will take a bunch of uuid's as parameters and i'd like to have something like requires :uuid, :type => UUID that would do validation and what not
[06:28:15] jrobeson: kke, thanks for reminding me to checkout grape..
[06:28:18] jrobeson: that's neat stuff
[06:29:14] kke: i'm glad to have a project to create an api from scratch, i get to play with stuff :)
[06:29:57] jrobeson: kke, i just looked at the readme page.. what about that doesn't help you out?
[06:30:24] sevenseacat: grape looks pretty nice
[06:30:30] sevenseacat: ACTION makes note
[06:30:54] jrobeson: it shows custom validations right there
[06:31:05] jrobeson: seems like you could use a string type wit ha custom validation based off what's right on the readme
[06:33:05] kke: hmm yeah i think that's the simplest way
[06:33:26] liquid-silence: ok I am over trying to stream video's in rails
[06:33:52] liquid-silence: send_file(file_path, :disposition => 'inline', :stream => true, :file_name => file_name)
[06:34:01] liquid-silence: the video never starts playing
[06:34:04] jrobeson: sevenseacat, https://github.com/intridea/grape/wiki check those otut too
[06:34:16] liquid-silence: http://cl.ly/image/36470D3f0z2Q
[06:34:28] dsrx: i kicked around the idea of mounting a grape app within rails
[06:34:29] liquid-silence: sevenseacat there is also rails-api
[06:34:44] liquid-silence: which is a gem to make rails only api apps
[06:34:59] liquid-silence: https://github.com/rails-api/rails-api
[06:35:07] dsrx: because my app is separated into two components - a json API, and some permalink pages and then a 'main app page' which serves an angular application
[06:35:24] jrobeson: dsrx, an example like that is right ont he wiki
[06:35:35] sevenseacat: yeah thats what i was thinking of, except s/angular/ember/
[06:35:35] dsrx: I may do that down the road
[06:35:53] dsrx: the DSL for describing apis is really nice
[06:36:02] dsrx: especially the versioning
[06:36:38] liquid-silence: ok time to get back to try and fix this streaming shit
[06:37:05] sevenseacat: i wonder why people here dont use these kinds of gems
[06:37:16] liquid-silence: sevenseacat which?
[06:37:18] dsrx: streaming shit... sounds like a nasty problem :(
[06:37:38] sevenseacat: these api gems - i know we tried rocket_pants for one API and it sucked, but these others look better
[06:37:44] audaxion: streaming shit == diarrhea
[06:38:19] dsrx: that was the joke
[06:40:19] dsrx: the nice thing about writing integration tests rather than controller tests is that doing such a thing (replacing some rails controllers/views with Grape) is safer
[06:40:42] dsrx: if i were just testing rails controllers, i'd be stuck
[06:40:54] audaxion: ACTION agrees
[06:41:20] audaxion: i tend to skip unit tests for controllers in favor of integration tests
[06:41:21] jrobeson: there seems to be a million ways of writing rspec tests .. fun
[06:41:39] liquid-silence: rspec + capybara
[06:42:05] jrobeson: now that i finished my prototype enough to leran rails .. now it's time to do it over properly
[06:42:11] dsrx: capybara is kinda useless for testing a json api tho
[06:42:14] jrobeson: which means tests ..
[06:42:28] dsrx: what's that cucumber alternative that uses gherkin but doesn't require regex magic?
[06:42:55] dsrx: some other veggie, like arugula or something
[06:43:10] dsrx: oh, spinach
[06:43:33] dsrx: note to self: arugula is available on rubygems
[06:44:15] liquid-silence: but you have routing specs etc...
[06:44:46] dsrx: eh, I just have integration tests
[06:44:51] liquid-silence: you dont use capybara to tests those
[06:44:54] dsrx: request specs in rspec terms
[06:45:02] Radar: I use controller specs to test APIs
[06:45:06] Radar: am I doing it wrong?
[06:45:29] liquid-silence: I just prefer routing specs and request specs for API testing
[06:45:36] liquid-silence: especially for Grape API's
[06:45:49] liquid-silence: if its normal rails controllers used as a api then I don't see why not
[06:50:02] Radar: Controller tests that render their views.
[06:50:31] Radar: i.e. https://github.com/spree/spree/blob/master/api/spec/controllers/spree/api/products_controller_spec.rb
[06:50:49] liquid-silence: well it renders json
[06:50:53] liquid-silence: your checking the json
[06:50:56] liquid-silence: so I think its fine
[06:51:07] liquid-silence: but what do I know, you wrpte a book
[06:52:03] tomoyuki28jp`: Is there a easy way to share view template between rails and javascript?
[07:10:31] liquid-silence: has any one here ever done video streaming in rails, I have a controller action called stream send_file(file_path, :type => 'video/mp4', :filename => 'file.mp4',:disposition => "inline"), that method is then added as the source for the video tag, works in safari but not chrome
[07:14:47] krz: liquid-silence: does that scale?
[07:15:08] liquid-silence: what do you mean by scale
[07:15:26] krz: doesnt that take up a whole instance?
[07:15:41] liquid-silence: krz not even close to thinking of that yet
[07:15:49] liquid-silence: the other option is to stream video via node
[07:16:53] krz: itll take up an instance
[07:17:05] liquid-silence: what do you suggest ?
[07:17:06] krz: you can stream via s3
[07:17:18] liquid-silence: krz this is to replace s3 in essence :P
[07:17:26] liquid-silence: well at a much smaller scale ofcourse
[07:17:55] liquid-silence: seems node is the way to go
[07:18:01] liquid-silence: maybe making use of express or something
[07:18:40] krz: node just for streaming files? seems a bit over
[07:19:05] liquid-silence: and hash validation etc....
[07:19:23] liquid-silence: so it does way more then just streaming
[07:19:29] liquid-silence: it also does encoding etc..
[07:19:34] krz: id do the hash validation for cache expiry?
[07:19:44] krz: hash validation for cache expiry?
[07:19:53] krz: id do the encoding outside your server
[07:19:54] liquid-silence: custom hashes that expire on usage
[07:20:02] krz: yea cache invalidation
[07:20:15] liquid-silence: the user can only use the hash once
[07:20:20] krz: ah signed urls
[07:20:22] krz: s3 does that too
[07:20:30] liquid-silence: yeah we are not allowed to use s3
[07:20:40] liquid-silence: as the content providers are being retards
[07:20:57] liquid-silence: thats where my thinking is heading with using express
[07:21:11] liquid-silence: so that we can have a full on API + Streaming
[07:21:15] krz: id suggest encoding outside your server
[07:21:29] krz: via zencoder or other api service
[07:21:46] liquid-silence: yeah not phased about the encoding now
[07:22:00] liquid-silence: its more about the signed url's and actually getting video to stream correctly
[07:22:35] krz: just curious. how are the guys at s3 giving you a hard time?
[07:22:47] liquid-silence: krz not s3 itself
[07:22:51] liquid-silence: more the clients
[07:23:01] liquid-silence: they do not want their content outside of their data center
[07:23:36] liquid-silence: let me get back to figuring out which tech to use for this
[07:25:12] liquid-silence: so I am thinking either express or sails
[07:25:16] liquid-silence: not to use which one yet
[07:26:19] krz: id give sails a go if i were doing node
[07:26:24] krz: relatively new though
[07:27:59] jan1337z: question: I have an model that references many objects that will all be needed … how do I tell ruby /AR to load them all recursively so that its not done each time I access one references model?
[07:28:29] krz: jan1337z: eager load
[07:28:37] krz: via include
[07:28:45] krz: google railscast eager loading
[07:37:25] paniwani: i have about 500+ static images (which i need to make thumbnail versions of too) that i want available to my local app, my staging app, and my production app. does it make sense to use imagemagick or something similar to convert them locally, throw them onto Amazon S3, and then have all my apps look there for the images in my views?
[08:04:39] clocKwize: morning guys
[08:37:34] geojin: hello guys
[08:38:02] geojin: i am getting this error in console Uncaught TypeError: Object [object Object] has no method 'fileupload'
[08:38:25] sevenseacat: soundsjavascripty
[08:38:41] bastilian: geojin: you probably miss the jquery fileupload plugin.
[08:38:58] bastilian: look at the network tab an see if it is loading.
[08:41:55] geojin: <bastilian> do you mean gem i used gem
[08:41:55] krz: dont use those scripts
[08:42:05] krz: they never work 99% of the time
[08:42:20] ljarvis: 99% of never
[08:42:38] krz: use filepicker.io
[08:42:39] bastilian: geojin: no, in chrome, or whatever browser you use, see if the JS-file is loading.
[08:42:43] krz: pay for a service that actually works
[08:42:55] krz: if uploads is crucial to your business domain
[08:43:46] bastilian: krz: if one can not get a fileupload to work either by tackling code or asking for help, they should not code at all.
[08:44:00] krz: bastilian: maybe you should try it
[08:44:04] krz: and then come back here
[08:44:09] workmad3: now now guys
[08:44:32] bastilian: nope. would never use a service for something i can do on my own in shorter time and in a better way.
[08:44:32] krz: uploadify, plupload. all guarantee sucessful uploads
[08:44:42] helpa: http://i.imgur.com/tyViD.gif
[08:44:51] workmad3: krz: stop spouting marketing bullshit please
[08:45:15] krz: workmad3: i dont work for them
[08:45:36] bastilian: sounds like it though. :)
[08:45:45] workmad3: krz: I don't care, you're still spouting marketing bullshit when you come out with crap like 'they guarantee sucessful uploads'
[08:45:50] bastilian: geojin: whats the status?
[08:45:57] krz: jquery upload scripts have issues with browser compatibility. uploadify, plupload, etc
[08:46:15] krz: the only one ive seen stable is the upload script from mootools
[08:46:28] helpa: http://i.imgur.com/m9m3wr9.gif
[08:46:40] workmad3: krz: I'm not looking for an argument, or a discussion
[08:46:47] workmad3: krz: I'm just asking you to stop spouting bullshit
[08:46:57] workmad3: krz: I'm well aware of the state of play of js upload plugins
[08:47:21] krz: workmad3: they dont guarantee successful uploads. if it came out as a marketing spin. my bad
[08:47:34] workmad3: krz: right, you just contradicted yourself there
[08:47:37] sevenseacat: no-one 'guarantees' anything
[08:47:54] sevenseacat: and if you do, you're a liar
[08:47:54] workmad3: krz: you're the one who said they *did*
[08:48:09] workmad3: krz: I'm well aware that they don't
[08:48:17] tagrudev: failure is a guarantee
[08:48:22] krz: ACTION scrolls up
[08:48:32] workmad3: krz: as I said, I don't actually want a discussion... I'm just saying - stop spouting bullshit please
[08:48:47] krz: workmad3: I didnt say "they guaranteed successful uploads"
[08:48:54] krz: workmad3: i think you thought i implied it
[08:48:58] bastilian: kids, stop it. i wanna help geojin to get his uploads working.
[08:49:07] workmad3: krz: your words - 'krz> uploadify, plupload. all guarantee sucessful uploads'
[08:49:11] sevenseacat: ' krz: uploadify, plupload. all guarantee sucessful uploads'
[08:49:13] workmad3: krz: that's not 'implying'
[08:49:19] workmad3: krz: that's *stating*
[08:49:38] krz: ah that, i thought you were referring to the api service
[08:49:47] krz: back to work. movie is over
[08:51:15] sevenseacat: 'oh shit they proved me wrong, gotta run'
[08:51:38] krz: ACTION snatches some popcorn on the way out
[08:52:02] bastilian: ACTION gives a shit literally
[08:53:08] DaniG2k: guys if I'm using turbolinks and I have two jquery functions that look like this, how can I make it work without having to reload the page? https://gist.github.com/DaniG2k/6591807
[08:53:56] sevenseacat: ACTION suddenly becomes very busy
[08:53:58] workmad3: bastilian: you probably want to clean that off your chair before it stains
[08:54:23] geojin: <bastilian> no not working
[08:54:47] workmad3: DaniG2k: easiest way is to do $(document).on 'click', 'form .add_fields', ...
[08:55:19] geojin: here in my gist at 22 line shows an error an browser consolehttps://gist.github.com/anonymous/6591658
[08:55:31] DaniG2k: workmad3: i think i tried that already but it broke the js
[08:55:32] workmad3: DaniG2k: also, there's a jquery turbolinks gem that will refire the jquery.ready callbacks every time turbolinks changes the page
[08:55:49] DaniG2k: workmad3: yeah i heard about that...jquery-turbolinks?
[08:55:57] workmad3: unsurprisingly, yes
[08:56:01] DaniG2k: that might be a good idea
[08:56:05] bastilian: geojin: does "/jquery-file-upload/jquery.fileupload.js" exist?
[08:56:26] workmad3: DaniG2k: I'm curious how using the live selectors 'broke' your JS though
[08:56:29] workmad3: DaniG2k: as that shouldn't be the case
[08:57:43] geojin: <bastilian> i am using rails4 i kept jquery-file-upload in public folder
[08:58:12] DaniG2k: workmad3: i think it had to do with me using prev and before and whatnot. it started selecting the wrong thing
[08:58:21] DaniG2k: workmad3: im using jquery-turbolinks. works well now :)
[08:58:48] bastilian: geojin: what browser are you using? can you see if it gets loaded or gets a 404 error?
[09:04:03] geojin: <bastilian> i am using chrome at my console it shows Uncaught TypeError: Object [object Object] has no method 'fileupload'
[09:06:10] bastilian: geojin: where the console is, there is also a tab called "Network" click on it and reload the page, try to find "/jquery-file-upload/jquery.fileupload.js" there and see if it is red or not.
[09:11:37] clocKwize: Just signed up for this http://happybearsoftware.com/security-workshop anyone else attending?
[09:13:51] geojin: <bastilian> inconsole at network it doesnot shows any message jquery-file-upload.js is visible
[09:18:10] geojin: <bastilian> i add jquey-file-upload folder directly to public folder is it correct way or need to be done any other way
[09:19:02] bastilian: putting it into public is fine, for now, but you should take a look at the rails asset-pipeline.
[09:19:58] bastilian: geojin: there has to be a row with jquery-file-upload. can you try and press CMD+SHIFT+R to reload?
[09:22:03] BrazenBraden: any one interested in a little refactoring? :P http://hastebin.com/kuwiviyati.rb
[09:22:21] BrazenBraden: ( im still stuck in PHP :( )
[09:23:13] Xeago: BrazenBraden: first step would be to return early
[09:23:26] Xeago: instead of the if condition: return false if rolse.blank?
[09:24:33] BrazenBraden: return false if roles = User::ModuleUser.where(user_id: user.id).blank?
[09:24:35] Xeago: your code only takes the first role btw
[09:24:46] elaptics: BrazenBraden: what is this method for?
[09:24:52] Xeago: I would not do the assignment in the if statement
[09:24:54] BrazenBraden: yea i know.. tis still very much being worked on
[09:25:08] Xeago: line 10-15 are broken
[09:25:13] Xeago: you aren't looping over each of the role
[09:25:19] Xeago: just the first of them
[09:25:19] BrazenBraden: elaptics: just a silly helper method to check if someone has a certain permission or not
[09:25:28] Xeago: and then you return the false or true
[09:25:48] elaptics: BrazenBraden: usually better to put this thing in the model itself
[09:26:04] BrazenBraden: oh ok.. as a scope?
[09:26:23] elaptics: BrazenBraden: just a method e.g. is_admin?
[09:26:42] elaptics: BrazenBraden: then it can just check itself for the required criteria
[09:26:44] Xeago: why not use User::Role.where(id: roles.map(&:role_id), name: 'admin').exists?
[09:26:50] BrazenBraden: Xeago: by specifying different role.role_id's in the loop, wouldnt i be getting different results every time?
[09:26:56] Xeago: checks if any of the roles are an admin
[09:27:05] Xeago: BrazenBraden: you are returning in both of the conditionals
[09:27:25] Xeago: you are not aggregating them
[09:27:30] Xeago: (how do you spell that word?)
[09:27:43] BrazenBraden: looks good to me :P
[09:28:08] elaptics: BrazenBraden: does a user has_many :roles?
[09:28:23] BrazenBraden: so, roles.map will loop through all the roles?
[09:30:53] BrazenBraden: Xeago: that line you gave me.. would that replace the entire conditional mess i have?
[09:31:04] elaptics: BrazenBraden: how about https://gist.github.com/andyh/88766ee0b765281ecf0c
[09:31:18] BrazenBraden: elaptics: the table structure is a little more complex though
[09:31:23] Xeago: BrazenBraden: mostly
[09:31:43] elaptics: BrazenBraden: in what way?
[09:31:45] Xeago: elaptics: that loops over all roles in ruby tho
[09:31:53] BrazenBraden: elaptics: ok... it goes something like this..
[09:32:02] BrazenBraden: I have a Users table
[09:32:19] BrazenBraden: that is connected to a UserModules table (which is the middle table in a many to many)
[09:32:20] elaptics: Xeago: didn't say it was efficient :) Just nice and simple - can be optimized
[09:32:32] BrazenBraden: The UserModules is connected to a Modules toble and to a Roles table
[09:32:40] BrazenBraden: so essentially,
[09:32:56] BrazenBraden: a user can have many roles to many modules
[09:33:04] BrazenBraden: well, at the moment, one role per module
[09:33:13] BrazenBraden: but can have access to many different modules
[09:34:12] clocKwize: BrazenBraden: you should gist your models (User, Module, UserModules etc…) only the relations will do, so we understand better
[09:34:41] elaptics: BrazenBraden: what clocKwize just said :)
[09:35:27] BrazenBraden: is this what you mean?? http://hastebin.com/muvunukaho.py
[09:35:49] BrazenBraden: (working in an engine FYI)
[09:36:04] BrazenBraden: (hence the 'Module User' junk)
[09:37:47] BrazenBraden: let me known... i am still very much confused by the relational stuff.. in my mind, user_modules should 'belong_to' user and not the other way around.. but that is how I understood the docks
[09:38:30] elaptics: BrazenBraden: so do you want to be able to check a users role for a given module?
[09:39:00] BrazenBraden: yea.. essentially, each module will have a 'is_<module>' call to check if they can access that module
[09:39:32] BrazenBraden: unless there is a better way to do it?
[09:41:09] geojin: <bastilian> bro first time it needs to be refresh and next time it working fine , what might is the reason
[09:42:00] elaptics: BrazenBraden: currently is it only a single role that a user can have for a module? So either one role or none?
[09:42:25] BrazenBraden: they are either say, admin or subscriber or user or editor
[09:42:32] BrazenBraden: but not user AND editor
[09:42:34] BrazenBraden: one role per module
[09:43:46] elaptics: BrazenBraden: and you'd want to check what role they are for a given module?
[09:44:16] BrazenBraden: so for example, if no role assigned, they dont have any access and dont even see the item in the menu
[09:44:24] BrazenBraden: any other role will show the menu item
[09:44:36] BrazenBraden: but within the controller the functionality will be limited to role
[09:47:58] elaptics: BrazenBraden: your user model doesn't seem to reference the modules or roles directly?
[09:48:35] elaptics: would expect you'd have: e.g. has_many :modules, :though => :module_users
[09:50:35] dangerousdave: I was looking at hosting with Heroku (I currently have a shared host) and then discovered Elastic Beanstalk. Does anyone have any opinions on these?
[09:50:36] BrazenBraden: i see.. like i said, im still trying to wrap my head around the way rails handles relationships
[09:51:34] BrazenBraden: ok..so user will have many modules and many roles? and will that works backwards as well? roles and modules will have many users?
[09:51:46] elaptics: BrazenBraden: it would make sense to me that you'd have that so you can just query the user object itself for its roles and modules
[09:52:08] elaptics: BrazenBraden: yes, that's what the join table is for
[09:52:18] ShinySides: hey guys, quick question, is there a way to disable the label from showing up on a form helper input?
[09:52:36] elaptics: ShinySides: what are you using?
[09:52:51] workmad3: BrazenBraden: quick warning though... do not call an ActiveRecord model 'Module'
[09:52:56] workmad3: BrazenBraden: you'll get errors ;)
[09:53:11] ShinySides: elaptics, this is the line I'm using = f.input :terms, :as => :boolean
[09:53:18] workmad3: ShinySides: simple_form?
[09:53:21] elaptics: ShinySides: is that simple_form?
[09:53:32] ShinySides: I'm not sure, I have been using what they gave me
[09:53:39] elaptics: ShinySides: if so, set :label => false
[09:53:50] ShinySides: I tried that and didnt work :S
[09:53:54] jrobeson: you'll know by the name of the form
[09:53:57] elaptics: ShinySides: does the form_for look like simple_form_for….
[09:53:59] jrobeson: by the name of the form block
[09:54:10] jrobeson: yes form_for is rails simple_form_for is .. well.. :)
[09:54:15] BrazenBraden: workmad3: thanks for the tip
[09:54:44] ShinySides: I have semantic_form_for
[09:54:44] jrobeson: how crazy should i go with validations i wonder
[09:55:04] elaptics: that sounds like formtastic - not so familiar with that
[09:55:18] elaptics: I would imagine you can do something similar to simple_form to disable the label
[09:55:33] BrazenBraden: ok elaptics, i will rename my table and invest some time trying to understand the relational side of rails as well as make the changes you suggested.. i'll get back to you later. thanks for your time..
[09:55:39] ShinySides: hmm I used a "hack" to get rid of it in css like color: rgba(255,255,255,0); but it doesnt work in IE8
[09:55:48] jrobeson: if i have a regex for 8 hex characters with format vaidation should i bother with the others like length or presence? or split the validation up ?
[09:55:58] elaptics: ShinySides: well you could display: none it in css
[09:56:10] elaptics: ShinySides: maybe try :label => ""
[09:56:16] ShinySides: if I do that tho, it removes the tick box as well
[09:56:28] elaptics: ShinySides: scope the display none to the label only
[09:56:29] ShinySides: ya did that as well but it shows the * cause it's a required field
[09:56:42] elaptics: ShinySides: then set :required => false
[09:56:56] workmad3: elaptics: ah, checkboxes in simple_form are nested inside the label fierd
[09:57:18] ShinySides: I could try and hide the label and then show the input inside the label
[09:57:19] elaptics: workmad3: as they should be imo
[09:57:32] workmad3: elaptics: yes :) but it means using 'display:none' will hide the whole lot
[09:57:34] elaptics: dunno how formtastic does it though
[09:58:04] elaptics: workmad3: yep. Was just making suggestions :)
[09:58:35] workmad3: ShinySides: basically, things like simple_form and formtastic are great for ensuring a consistent style for your forms
[09:58:45] workmad3: ShinySides: but they're a bit of a PITA to customise a single form with
[09:58:59] workmad3: ShinySides: your best bet would be to look at the formtastic docs, see if that sheds any light
[09:59:02] ShinySides: ya I know, I like them but had to use a stupid background image for ie8 so it's gone to shit html now
[09:59:07] ShinySides: so all rules are off :P
[09:59:41] workmad3: ShinySides: your other option would be to not use formtastic for that form
[09:59:48] ShinySides: required => false worked anyway :)
[09:59:52] elaptics: workmad3: that's why I really like simple_form because you can easily mix and match so if you have to do a non-consistent thing you can just do that one with standard rails helpers
[10:00:00] ShinySides: i have 10 min, cant afford to change it
[10:00:37] workmad3: elaptics: you can do the same with formtastic, iirc :)
[10:00:45] elaptics: workmad3: just looked at the formtastic readme, looks like it's a lot closer to simple_form now than it used to be
[10:01:22] Syrit: guys, i am trying to show an "ajax-spinner" , so i added the gif image to app/assets/images/ajax-loader.gif, and in the page, i am calling it this way "%img#img-spinner{alt: "Loading", src: "/assets/images/ajax-loader.gif"}" , it won't show ! , am i doing something wrong? and is assets the right place to put images ?
[10:01:26] workmad3: elaptics: ever written your own form builder to handle project forms? :)
[10:01:36] ShinySides: if formtastic a gem or is it built in rails?
[10:01:38] elaptics: workmad3: a couple of times
[10:01:47] workmad3: Syrit: you're linking completely wrong
[10:01:51] workmad3: Syrit: use image_tag
[10:02:11] Syrit: thank you workmad3
[10:02:23] Syrit: and about the place to save the image? is it the right place?
[10:02:26] elaptics: ShinySides: it's a gem
[10:02:36] elaptics: Syrit: yes, assets is the place
[10:02:40] tobago: is there a way to exclude some css.scss files from the asset pipeline for a specific view?
[10:02:48] Syrit: thanks elaptics
[10:03:07] elaptics: tobago: not easily. You just need to scope your selectors properly
[10:11:29] shambat: added a validate method to my model, but is there a way to send messages back to the controller without adding them to errors, so the model will still save properly?
[10:11:39] shambat: I want to give a warning, not an error.
[10:12:06] geoffw8__: Hi all. What process does the logging on prod?
[10:12:18] geoffw8__: anyone know?
[10:12:40] shambat: right now I doing a flash[:notice] = msg where msg has all the error messages in the errors object
[10:13:24] elaptics: shambat: not sure I follow what you want
[10:14:59] shambat: elaptics: I want to send a warning from the validate method, not an error
[10:15:18] elaptics: shambat: you'll need to write your own thing then and use that instead of what rails provides out of the box
[10:15:37] shambat: right now I'm using errors.add_to_base("Error message")
[10:15:50] shambat: however this prevents saving of the model
[10:16:01] shambat: since there is something in errors
[10:16:44] elaptics: shambat: yep, you'd have to create your own "warnings" collection and add stuff to that - it would mean you'll have to write all your own validations - you can't use any of the rails ones since they all add to errors
[10:17:07] elaptics: shambat: the main question is, why are you doing this
[10:19:08] shambat: elaptics: I want to send a message to the user in a flash, that informs of a special condition
[10:19:21] shambat: I'm thinking it could be done in the controller too maybe
[10:19:44] elaptics: shambat: special condition like what?
[10:19:51] shambat: but then I need to be able to test for that condition in the controller
[10:22:57] shambat: elaptics: if the model is of a specific type and a specific field is empty, then I need to perform a certain action, and inform the user
[10:23:19] shambat: maybe this can be done in the controller directly, I'll test it out
[10:23:52] elaptics: shambat: well the controller should query the model for the state of it to set the appropriate flash or whatever
[10:24:09] clocKwize: anyone had this problem? In tests: uninitialized constant RAILS_CACHE
[10:24:15] elaptics: shambat: if you're using a custom validation to trigger it, that's ok
[10:24:15] clocKwize: when something does Rails.cache.fetch
[10:25:04] shambat: elaptics: ok thanks I'll try it
[11:01:53] clocKwize: ohhh, whoops
[11:02:18] clocKwize: fire bell went off, as usually once every few days, so I carried on sitting in a comfy bean bag reading a haskell book while drinking my coke
[11:02:32] clocKwize: until I was ushered out the building by fire marshals
[11:02:35] clocKwize: fire in basement
[11:11:53] jan1337z: I get an unexpected "," while @page = Page.includes({sections: {:person, :person_sections}}).find_by(slug: params[:slug]) … whats the correct way of doing it?
[11:13:13] jan1337z: Pages have sections and sections have one person and many person_sections
[11:13:56] clocKwize: you are using {} braces, so it thinks you are passing a hash
[11:14:01] clocKwize: but you are only giving values, no keys
[11:14:06] clocKwize: so it should be [:person, :person_sections]
[11:14:10] clocKwize: like an array
[11:14:53] jan1337z: clocKwize, thanks that makes sense and is working
[11:18:33] BrazenBraden: workmad3: is it alright to name a model 'system' ?
[11:24:43] elaptics: BrazenBraden: that should be ok in itself, but it doesn't seem massively descriptive
[11:25:29] BrazenBraden: elaptics: yea but not sure what else to call it.. our app comprises multiple "modules" which each belong in its own engine.. in my mind, "module" would be the best word... but alas
[11:25:38] cek: how do I mix haml_tag and link_to together in helper ?
[11:26:03] cek: with = heleprfunc(), it says i should use -, but link_to isnt rendered...
[11:26:55] cek: how do i render into current template?
[11:26:56] elaptics: BrazenBraden: what do you call in internally?
[11:27:01] elaptics: BrazenBraden: it*
[11:27:14] helpa: cek: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[11:27:18] BrazenBraden: elaptics: modules? lol
[11:27:28] cek: yes, it's done with haml_concat. piceo f crap
[11:28:05] elaptics: BrazenBraden: what are these modules?
[11:28:59] BrazenBraden: well, for example, we working on a basic accounting module, a contacts module, an admin module etc etc
[11:29:13] BrazenBraden: (we have 12 in total.. all various aspects the organisation
[11:31:40] Carsekyx: If I've got a user model and gym model and they connect via has_many each way where would I put views/methods to create relationships?
[11:31:56] DaniG2k: guys I have a validation for a nested attribute. I noticed that it's adding the error message to error[:nested_attrib_name]....I'm wondering how to make validation fail in the controller and display this on the page
[11:31:59] Carsekyx: (there's a user_gym_relationships model)
[11:32:01] DaniG2k: here's my code
[11:33:15] DaniG2k: https://gist.github.com/DaniG2k/6593130
[11:34:15] DaniG2k: i want to trigger the limit_educational_experiences validator
[11:34:17] BrazenBraden: elaptics: I have altered my models and relationships a tad.. keen to have a look?
[11:35:06] DaniG2k: it seems to be working properly except the edit page is not being re-rendered with the error
[11:35:20] DaniG2k: (the validation code gets hit and evals to true, so the error gets added)
[11:35:52] clocKwize: haha, someone just sent this old one round: http://compuccino.com/sites/default/files/redaktion/bilder/fault-tolerance.png
[11:36:04] workmad3: DaniG2k: I can't see where or how that code gets hit
[11:36:25] DaniG2k: ah sorry i forgot to post the form
[11:36:58] elaptics: BrazenBraden: sure
[11:37:02] BrazenBraden: elaptics: http://hastebin.com/tuyividaji.py
[11:37:24] DaniG2k: workmad3: https://gist.github.com/DaniG2k/6593130
[11:37:42] DaniG2k: workmad3: there's a form containing a partial
[11:37:49] DaniG2k: with add/remove fields
[11:38:38] workmad3: DaniG2k: that still doesn't show how the validation code you've got there gets hit
[11:38:58] workmad3: DaniG2k: and it definitely doesn't show where you've hooked it into the validation cycle to function as a validator
[11:39:24] DaniG2k: youre right
[11:39:34] DaniG2k: I removed it for readability by acceident
[11:39:37] DaniG2k: its there now
[11:39:47] DaniG2k: workmad3: https://gist.github.com/DaniG2k/6593130#file-tutor-rb
[11:39:54] DaniG2k: validate :limit_educational_experiences, on: :update
[11:41:19] DaniG2k: workmad3: could it be that I need to add the error to base?
[11:41:52] elaptics: BrazenBraden: not sure how you're plugging roles in there exactly and you have a spelling mistake on line 7
[11:42:19] elaptics: BrazenBraden: also you've got a variety of system_users and user_systems....
[11:42:41] BrazenBraden: elaptics: oh my bad.. eish.. lemme fix that quick!
[11:43:17] DaniG2k: workmad3: ok its working now -_-
[11:43:33] DaniG2k: I must have spelled something wrong or something my bad
[11:43:37] DaniG2k: wormwood: thnks
[11:47:24] BrazenBraden: elaptics: fixed http://hastebin.com/bavuvilasi.py -- what might help make this clearer is a database diagram..
[11:47:58] BrazenBraden: need to update the old one first though
[11:48:57] jan1337z: question: isn't there a way to just eager load everything referenced=
[11:49:21] helpa: jan1337z: Instead of simply saying 'something is broken' please elaborate on this by showing us the code and the error that you are getting by making a Gist (http://gist.github.com) about it.
[11:49:21] universa1: jan1337z: !elaborate
[11:49:33] universa1: ohh doesn't fit really...
[11:49:45] ljarvis: jan1337z: yes but thankfully it's not built in
[11:53:05] freesteph: I'd like to validate a belongs_to association
[11:53:15] freesteph: that is, if I create another record with the same user_id, it should not be valid
[11:53:24] freesteph: but my spec still think it's valid
[11:53:29] jan1337z: I am just wondering.. what if I have a section and it is referencing the same model (like section => section) … does it load it recursively?
[11:53:37] freesteph: I've used validates_assocation :user, but that doesn't seem to do it
[11:53:43] helpa: freesteph: 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.
[11:53:43] elaptics: freesteph: !code
[11:54:25] olivier_bK: i have a file like that 20130411195520_add_champs_to_users.rb and i would want oget only add_champs_to_users. do you know how i can do that
[11:55:12] kaspergrubbe: olivier_bK: why do you want to rename a migration?
[11:55:17] jan1337z: olivier_bK, why should you want that?
[11:55:23] olivier_bK: i dont want to rename
[11:55:58] freesteph: elaptics: here it is: https://gist.github.com/freesteph/6593348
[11:56:00] skroon: I would like to check if 2 XML documents are the same, now I have two objects: doc1 = Nokogiri.XML("<foo/>"); doc2 = Nokogiri.XML("<foo/>"); are the same
[11:56:24] BrazenBraden: olivier_bK: you need the timestamp there otherwise rake doesnt know in which order to run the migrations
[11:56:27] skroon: during the comparision however, nokogiri also compares memory locations, is there a way to really check just if hte strcuture is the same?
[11:56:37] ljarvis: skroon: .to_s
[11:57:05] skroon: ljarvis: I tried that as well, but it remember the formatting in terms of spacing , if you know what I mean
[11:57:06] kaspergrubbe: skroon: Perhaps this: https://github.com/postmodern/nokogiri-diff ?
[11:57:06] jan1337z: ljarvis, I don't thing thats the best approach
[11:57:21] ljarvis: skroon: ah right you want to check the nodes
[11:57:38] skroon: yeah I would like to use it in my RSPec example actually
[11:57:39] skroon: so I can do
[11:57:51] skroon: response.should == expected
[11:57:58] skroon: where response and expected or XML objects
[11:59:02] jan1337z: skroon, am I understanding you correctly that it is compared by its pointer?
[11:59:17] skroon: jan1337z: yeah at this moment it seems to be doing that for me indeed
[11:59:30] elaptics: freesteph: hmm something feels off about this. What's the actual use case here?
[11:59:46] jan1337z: skroon, have you been looking for a cooperator or an equals method?
[11:59:54] skroon: jan1337z: http://pastie.org/private/lykatbwanmvhpoi52rr9dq
[12:00:16] skroon: jan1337z: ah right like: response.should equals(expected) ?
[12:00:22] freesteph: elaptics: actually
[12:00:24] freesteph: reading the docs
[12:00:40] freesteph: validates_associated just makes sure the associated object is valid
[12:00:43] jan1337z: skroon, maybe
[12:00:49] freesteph: whereas I thought it would make sure the associated model is unique
[12:00:56] ljarvis: skroon: that wont work either :) you should walk the nodes and check equality
[12:00:58] freesteph: since it's a belongs_to <-> has_one association
[12:00:59] skroon: jan1337z: good one, doesn't work though, but nice one indeed to have tried
[12:01:15] jan1337z: skroon, I am not familiar with your Class but that would be my approach
[12:01:17] elaptics: freesteph: yep, that's part of what seems off
[12:01:19] ljarvis: skroon: there's also a lib called nokogiri-diff which could help
[12:02:12] BrazenBraden: elaptics: i hope that helped understand the db structure
[12:04:10] elaptics: BrazenBraden: yep a bit
[12:04:53] skroon: ljarvis: i'm looking into nokogiri-diff now indeed, see how I can use it with rspec matchers
[12:10:20] elaptics: freesteph: fwiw I would manage the creation of vouchers for users through a specific class, e.g. CreatesVouchers which would control whether or not a voucher can be created for a user or not rather than trying to shoehorn it into one of the User or Voucher models
[12:11:21] elaptics: BrazenBraden: you need to make sure you have your columns named correctly for rails, i.e. user_id not users_id, etc
[12:11:49] BrazenBraden: elaptics: alright.. fixing that
[12:12:15] BrazenBraden: elaptics: hmm.. i think it is like that.. just my diagram is wrong..
[12:12:54] BrazenBraden: elaptics: for instance, this is the migration file for the system_users table http://hastebin.com/jidigutumu.rb
[12:15:14] elaptics: BrazenBraden: ah fine then
[12:16:29] Carsekyx: If I've got a user model and gym model and they connect via has_many each way where would I put views/methods to create relationships?
[12:17:56] jan1337z: Questin: As I eager load quite much references … is there a way to cache this loaded model (as it is 90% always the same)
[12:18:37] elaptics: Carsekyx: ??
[12:19:06] Carsekyx: elaptics, ?
[12:19:27] elaptics: Carsekyx: I don't understand what you're asking
[12:19:49] elaptics: Carsekyx: you're mixing terms so I don't know what you want help with
[12:19:51] Carsekyx: I'm not really sure where to put my methods for creating relationships between users and gyms
[12:19:58] omarqureshi: Carsekyx: gym.users.create(..)
[12:20:06] omarqureshi: lives in controller, most likely
[12:20:09] elaptics: Carsekyx: you don't know where to put the has_many, belongs_to?
[12:20:13] Carsekyx: which controller though
[12:20:28] Carsekyx: elaptics, nah I've got that sorted and can create the relationships
[12:20:31] omarqureshi: depends on how you write your app
[12:20:40] omarqureshi: is it a user who is adding gyms?
[12:20:44] omarqureshi: or is it a gym who is adding users
[12:20:48] Carsekyx: elaptics, does the code go in user controller, gym controller or a third controller?
[12:20:59] omarqureshi: can a user have multiple gyms?
[12:21:05] Carsekyx: It's adding roles to users that attend gyms, they can be a sponsor, instructor or student
[12:21:06] elaptics: Carsekyx: omarqureshi is asking you the right questions
[12:21:06] omarqureshi: in which case its a memberships controller
[12:21:47] elaptics: Carsekyx: what's your join model called?
[12:21:59] Carsekyx: elaptics, at the moment user_gym_relationships
[12:22:44] elaptics: Carsekyx: right, I agree with omarqureshi. I'd probably rename that table to memberships and have a controller for that
[12:22:44] omarqureshi: please use a less shit name
[12:23:00] Carsekyx: I thought the name was pretty explanatory
[12:23:29] omarqureshi: so is AbstractWidgetFactoryEnterpriseBean
[12:23:30] Carsekyx: but alright, I'll make a memberships controller
[12:24:07] elaptics: don't you think membership is a better term? I mean if you're talking to you client about it, how would they describe it because your code ought to reflect it
[12:24:53] Carsekyx: Next question then. I want to have a form in a gym admin panel that you add students from, how would I go about grabbing the gym id from the previous page? A hint for search terms is a good enough answer
[12:25:11] omarqureshi: Carsekyx: nested rotes
[12:26:04] helpa: Carsekyx: http://guides.rubyonrails.org/routing.html - Rails Routing From the Outside In - Rails Guide - by Mike Gunderloy
[12:26:04] elaptics: Carsekyx: !routing
[12:26:46] Carsekyx: something like url/gym/id/membership/new ?
[12:27:13] elaptics: yep, that's exactly what nested routes make easy
[12:27:38] clocKwize: is it possible to force an update of all models? (I have an after_save that normalises some stuff, I want to do that now..)
[12:29:01] omarqureshi: clocKwize: i would ... do that in a migration ;<
[12:29:07] elaptics: clocKwize: Model.scoped.each(&:save) ;)
[12:29:35] clocKwize: elaptics: that'll not do anything because changes will be empty
[12:29:46] clocKwize: omarqureshi: maybe.. I don't have any migrations, I'm using mongoid :p
[12:29:47] elaptics: omarqureshi: I'd do it in a rake task
[12:29:50] omarqureshi: doesnt touch do that?
[12:29:58] omarqureshi: i.e. fire callbacks?
[12:30:00] elaptics: no, touch doesn't run callbacks
[12:30:11] defswork: clocKwize, it will if there are updated_at and lock_version
[12:30:17] elaptics: it just updates the timestamps
[12:30:27] clocKwize: touch doesn't call validations or callbacks
[12:30:29] krz: mongodb, such a PITA
[12:30:46] clocKwize: not my choice kHz :P
[12:30:50] defswork: (personally I don't think it should update timestamps etc.. if no other attributes are dirty)
[12:31:01] clocKwize: nor do I defswork
[12:31:08] krz: clocKwize: what is your choice? couchdb?
[12:31:16] clocKwize: for this project anyawy
[12:31:29] omarqureshi: why not call the callback using send?
[12:31:31] clocKwize: when I started it was already half (badly) built
[12:31:45] omarqureshi: unless its in an after_save block
[12:31:48] clocKwize: omarqureshi: I was thinking that.. it just loops through a relation and updates something on each of them, so that'd work
[12:32:00] clocKwize: omarqureshi: it is after_save..whats the difference?
[12:32:02] omarqureshi: in which case, just make it a method
[12:32:11] omarqureshi: the difference is block vs symbol
[12:32:23] clocKwize: oh, its after_save :blah
[12:32:30] clocKwize: I'll just send(:blah)
[12:33:05] elaptics: except don't call save after if you still have the callback in place :)
[12:34:42] clocKwize: elaptics: it doesn't update anything on itself anyway
[12:35:39] elaptics: clocKwize: I just said it cos omarqureshi had said do send and then "and save"
[12:35:49] clocKwize: thanks guys
[12:38:38] clocKwize: its annoying, i need to order products by if their brand is an own brand (like, a brand owned by the supermarket they are sold in).. which means product needs to be indexed with own_brand attribute, so every time you save a brand, it updates all its products.. which feels wrong when saving a Brand, it updates 500 other documents, and their elastic search index
[12:38:42] clocKwize: but can't think of another way..
[12:39:23] defswork: join product with brands on your selects
[12:39:36] clocKwize: defswork: the search is done by elastic search
[12:39:48] clocKwize: and its not a relational database
[12:40:10] clocKwize: and when you have 300,000 products, relations aren't always the right solution :P
[12:40:20] clocKwize: s/relations/joins
[12:40:40] defswork: 300,000 isnt a lot of anything
[12:40:47] clocKwize: infrequent expensive writes must be better than frequent less expensive reads
[12:40:57] BrazenBraden: hey elaptics, after doing the through: :model things, my helper has gone changed drastically lol. her is after and before.. but.. you said I should have this code in my model instead of a helper? http://hastebin.com/nuhasokire.rb
[12:41:13] clocKwize: I know defswork, but its enough to not be very fast to search on many different fields, with relevance considerations etc
[12:41:55] clocKwize: BrazenBraden: if user.roles.where(name: "admin").exists? is a boolean expression
[12:41:59] clocKwize: therefore, you can just return it
[12:42:05] BrazenBraden: elaptics: But I still think there is a way to shorten that if true then true end type thing
[12:42:16] elaptics: BrazenBraden: basically you can move lines 8-10 into your model and then it can be shortened like clocKwize just said
[12:42:20] BrazenBraden: clocKwize: lol. just what i was thinking
[12:42:36] BrazenBraden: so return user.roles.blah blah?
[12:42:42] clocKwize: on several occasions I've written x == true ? true : false
[12:42:44] clocKwize: so no worries :D
[12:42:45] BrazenBraden: I thought you didnt need a "return" in ruby
[12:42:54] elaptics: BrazenBraden: yep don't need the return though
[12:43:09] honestly: is there a different between "if params[:password]" and "if params[:password.present?"?
[12:43:17] elaptics: BrazenBraden: def is_admin?; self.roles.where(name: "admin").exists?; end
[12:43:43] defswork: honestly, params[:password] could have a value of nil
[12:43:43] elaptics: honestly: apart from the spelling error, not really :)
[12:43:43] BrazenBraden: elaptics: and that goes into the model?
[12:44:04] honestly: defswork: okay
[12:44:11] elaptics: defswork: nil is falsy though so in an if it's the same result
[12:44:17] defswork: honestly, but in the context of params - no
[12:44:21] clocKwize: BrazenBraden: http://hastebin.com/bufuvuliwi.rb
[12:44:38] elaptics: BrazenBraden: yes
[12:44:45] BrazenBraden: elaptics: the reason i had it in a helper is because this helper is sitting in the "admin module" while the user tables are sitting in the "user module" so wanted to seperate the admin from user stuff..
[12:45:08] elaptics: BrazenBraden: then you can use it any time
[12:45:57] elaptics: BrazenBraden: well it depends on exactly what you're doing, but usually there are other places in the code when you want to check the users status in some way so you don't want to duplicate the code checking for that
[12:47:11] clocKwize: I think that functionality should be encapsulated in the Model
[12:47:13] clocKwize: user.admin?
[12:47:23] BrazenBraden: elaptics: well, everything admin related will be contained soley in the admin module. I can understand the use of the other role checks in the user model however as all the models will do check for the roles...
[12:48:26] elaptics: BrazenBraden: it makes sense to keep all the role checks together so if you're happy to put all the others in the model then the admin one should go there too
[12:48:44] elaptics: BrazenBraden: personally I'd make it a more generic method, e.g. has_role?(role)
[12:48:56] clocKwize: then the fact that a user has roles etc is totally encapsulated and nobody but the user model will ever have to know about it, so if anything changes, you'll have 1 place to update
[12:48:58] elaptics: then you can use it whereever
[12:49:10] defswork: elaptics, and cache it
[12:49:16] elaptics: defswork: yep that too
[12:49:38] clocKwize: ACTION thinks helpers are evil
[12:49:50] defswork: def has_right?(*r)
[12:49:50] defswork: @rights_hash ||= Set.new( rights.pluck(:code) )
[12:50:08] maloik: Is anyone aware of something like a "warning" state for rspec? I'd like to add something to warn me of things like class length, method length etc but I don't want tests to fail if they go over the threshold as it may be on design that they go over
[12:50:45] maloik: Warnings when running the tests make most sense in terms of workflow to me, but perhaps it's just not the right place to implement this
[12:51:01] defswork: http://hastebin.com/xexicewiyo.rb < thats my rights checking method on User
[12:51:24] clocKwize: maloik: something like code climate?
[12:51:37] clocKwize: but that runs with tests?
[12:53:05] maloik: clocKwize: there's a gem, sandi_meter that someone wrote during baruco
[12:53:11] maloik: I'd like to add an rspec plugin for it
[12:53:27] unimatri_: https://github.com/makaroni4/sandi_meter
[12:53:28] maloik: but generally you don't want tests to fail if a method is 101 lines long ;)
[12:53:40] maloik: hence why I'm asking if there's a "warning" state
[12:54:48] BrazenBraden: clocKwize and elaptics, good points. I shall follow thy suggestions :)
[12:58:28] jacobat: I saw someone with a gem that would report on the time each gem in a gemfile takes to load. I just can't recall the name. Ring any bells?
[12:58:53] shredding: Is this a correct way to add default values to a model? https://gist.github.com/shredding/6593970
[12:59:08] shredding: Because, if it's active, the checkbox is not updating in activeadmin
[13:00:41] jacobat: shredding: usually you set the default in the database
[13:00:49] shredding: jacobat: ok
[13:01:11] shredding: jacobat: Is there a migration shortcut for that?
[13:02:21] universa1: shredding: change_column :foos, :bar, :boolean, default: false iirc -- check the docs ;)
[13:02:26] adac: Anyone experience with the "yell" logger? is there a way to put the name of the logger in front of each log message by default?
[13:03:16] shredding: universa1: I know how to write that, i meant cli shortcut like "rails generate ChangeBarDefault bar: false"
[13:03:40] BrazenBraden: def self.has_role(role); self.roles.where(name: role).exists?; end
[13:03:42] BrazenBraden: elaptics: something like this?
[13:03:43] universa1: shredding: not that i know of, but then i'm not overly familiar with all the shortcut possibilites
[13:04:34] BrazenBraden: elaptics: it seems to think that self.roles is an "undefined method" even though I have the associations set up now
[13:07:50] defswork: BrazenBraden, no need for self.roles - just roles
[13:08:53] BrazenBraden: defswork: that gives me undefined local variable or method `roles'
[13:09:49] defswork: BrazenBraden, definitely got a has_many :roles ?
[13:09:49] clocKwize: ACTION adds some weird boosting rules to elastic search query
[13:10:31] BrazenBraden: defswork: indeed. the whole "self.roles.blah" was working a moment ago when i had the code in a helper somewhere else
[13:11:00] defswork: well self.roles wouldnt work in a helper
[13:11:09] defswork: will only work in the model
[13:11:34] BrazenBraden: defswork: this is what I got in the user model for the roles:
[13:11:40] BrazenBraden: has_many :system_users
[13:11:40] BrazenBraden: has_many :roles, through: :system_users
[13:11:44] defswork: and self is the local context so it's not strictly necessary
[13:11:59] defswork: your method is self.has_role ?
[13:12:40] dwahyudi: greetings to all railsmania.... a confused rails user here.... simple_form or formtastic, which one should i choose?
[13:12:46] BrazenBraden: cos I see that is how active record wants you to define methods in a model
[13:12:56] defswork: self.method is a class method - called as Class.method
[13:13:03] clocKwize: I like formtastic, but I think simple_form is more accepted these days
[13:13:12] dwahyudi: oh i see.. many thanks clockwize
[13:13:17] defswork: def method is an instance method
[13:13:19] clocKwize: could be wrong though!
[13:13:21] horrror: trying to deploy with capistrano and I don't want assets-pipeline. how do i config it that way?
[13:13:29] clocKwize: see how many stars each github project has :D
[13:13:36] clocKwize: and which was was last committed
[13:13:49] defswork: BrazenBraden, class methods can only be called on the class itself and not an instance of the class
[13:14:00] njero: clocKwize: I agree, simple_form is the right answer
[13:14:02] defswork: there is no self in a class method
[13:14:24] BrazenBraden: defswork: but the docs say that doing def self.method is the same as using scopes?
[13:14:35] defswork: class scopes
[13:16:05] defswork: BrazenBraden, your method is just a method
[13:17:11] BrazenBraden: defswork: This is sorta what I have.. struggling to understand what you mean.. http://hastebin.com/qeqiyemere.rb
[13:17:41] clocKwize: BrazenBraden: doing that adds it to the class, not the instance of the class
[13:17:42] defswork: BrazenBraden, I've no ideal why you are doing this in a module
[13:17:51] clocKwize: oh, its a module O.o
[13:17:59] BrazenBraden: defswork: This is an engine
[13:18:02] horrror: i disabled all assets precompile and pipeline stuff on application.rb but still when I'm trying to load a page it includes a digested stylesheet/javascript file that doesn't exist (when I enter URL on browser it errors 404). What can I do?
[13:18:26] BrazenBraden: our app consists of about 12 different engines all responsible for different things
[13:19:10] defswork: anyway def self.has_role should be def has_role
[13:19:17] njero: horrror: are you just looking o skip that step in Cap?
[13:19:45] horrror: njero: no, i want to deploy the system but not using the assets pipeline.
[13:20:55] njero: horrror: I might be misunderstanding, you just want to not use asset pipeline period right? Are you sure you disabled it in the right config/environment?
[13:21:55] njero: horrror: it is hard to guess from the description of the error, can you gist the error?
[13:22:08] horrror: njero: this is exactly what I want to do.
[13:23:13] horrror: There's no error, deployment is successful and it loads the website. but without assets. When I view the HTML source code on browser it appears that it includes "/assets/style-4e56069ba297f90e20a5541684785e10.css"
[13:24:48] njero: horrror: okay, you have a couple of options, the easiest is to move your assets/* to public/* and make your links specific. If you have a lot of code this is a pain...
[13:25:48] horrror: i do have a lot of code, so I'd rather not be doing this
[13:27:11] BrazenBraden: defswork: Looking through the documentation and they all include the "self" in the method..
[13:27:57] defswork: BrazenBraden, your method isn't a scope
[13:28:06] njero: horrror: if you link to the file on your production server /assets/style.css is it there?
[13:28:08] BrazenBraden: defswork: do I not want it to be a scope?
[13:28:10] defswork: BrazenBraden, it can't be added to the arel chain
[13:29:30] BrazenBraden: defswork: ok.. so plain old "def has_role".. but how do I now access that from outside the engine because what I had before (which was calling the method) now doesnt work and complains about an "undefined method 'has_role'"
[13:32:04] skroon: I for some reason always get this api response error of a validation locally: "birthday" => ["can't be blank", "can't be blank"], twhice the "can't be blank" anyone have an Idea how this could be ?
[13:32:27] tagrudev: any gem for picking users ( facebook invite windows like ) ?
[13:32:35] tagrudev: or a js lib hmm
[13:33:29] horrror: njero: any idea?
[13:33:45] dcope_: if i'm querying my records via .select.. ie Books.select() is it possible to make AR auto join in any relationship tables so i dont have to joine them myself?
[13:33:54] defswork: BrazenBraden, auser = User.find(123) ; auser.has_role?
[13:33:56] njero: horrror: not so much, let me ask why you are tyring to remove it?
[13:34:28] BrazenBraden: defswork: let me pastebin you the context in which I am calling this method..
[13:34:35] njero: horrror: also, do you have a "style.css" at all? Is it just something being required in your layout that you can kill (sorry if I am asking the obvious questions here)
[13:34:48] horrror: njero: i do have style.css
[13:34:57] BrazenBraden: defswork: http://hastebin.com/hohosohoqi.mel
[13:34:59] njero: horrror: where is it located in your app
[13:35:07] horrror: app/assets/stylesheets/style.css
[13:35:31] defswork: BrazenBraden, you are trying to call a class method - you need a user
[13:35:39] njero: horrror: okay, turn the asset pipeline back on in application and turn digest off
[13:35:48] BrazenBraden: defswork: this is why I initially had it in a helper function
[13:35:50] defswork: BrazenBraden, something like User::User.curent_user.has_role(....)
[13:36:21] njero: horrror: config.assets.digest = false
[13:36:50] jan1337z: Imagine you have an model with many different has_many relations. Each of this references models has the attr position. Now you take all those references model instances and pass them into an array (ActiveRecord::Associations::CollectionProxy) (array << instance). How can I get the type of the class?
[13:37:00] BrazenBraden: defswork: I dont want to have to query the database every time the I refresh the page though..
[13:37:12] defswork: welcome to http
[13:37:31] defswork: thats how we roll round here
[13:37:45] defswork: unless you start stacking up sessions
[13:38:55] jan1337z: Any thoughts on my topic?
[13:39:21] defswork: BrazenBraden, the one thing that I would always expect you to do - even if you are sticking stuff in session - is to always load the current user for each request
[13:42:01] BrazenBraden: defswork: but that can get quite heavy... once a person logs in once, shouldnt a variable be set indicating the user and that is what is used for everything while that session is active to prevent constantly polling the db
[13:42:16] defswork: a variable set where ?
[13:42:20] defswork: http is stateless
[13:42:33] defswork: the only place you have for persistence is cookie, session and database
[13:42:49] BrazenBraden: well, im just thinking about the rails tutorial book / videos when creating a custom authentication system
[13:42:57] defswork: (and url parameters or posted parameters)
[13:43:07] BrazenBraden: and like with devise... if you call "current_user" it doesnt run off to the database
[13:43:13] defswork: yes it does
[13:43:48] defswork: it extends application controller
[13:44:23] defswork: BrazenBraden, you could load user into session when the session is created but typically you wouldnt do that
[13:44:33] horrror: njero: now javascript works good but stylesheet isn't
[13:44:46] defswork: as of all the things that you ought to be re-instantiating per request user is the tops
[13:44:50] BrazenBraden: defswork: okie.. well, anyway, for now I am not too worried about performance. just wanna get things working
[13:45:03] defswork: else once a user is logged in how do you get them out ?
[13:45:16] defswork: if you change their permissions they'd have to log out to get a new session
[13:45:22] defswork: it all gets cludgey
[13:45:52] njero: horrror: hmm, you need to be more speific... the link in the source is wrong, it is right but it 404s, the link looks like X but should be Y, if I change it to Y it doesn't 404
[13:46:04] BrazenBraden: defswork: I hear yioy
[13:47:33] BrazenBraden: defswork: so basically, to fix my little problem, I should have the has_roles method in the model, then a method in a helper class which does the user call so in my view, I only have to say "has_role"?
[13:48:39] jan1337z: Maybe it all comes down to: How do I check (like instance of) what object i have in an CollectionProxy /rails 4
[13:50:49] defswork: BrazenBraden, I personally have a current class method on User and I simply reference User.current.has_right? 'ADMIN', 'SUPERUSER' etc..
[13:50:52] kamiyuki: any1 knows how shopify.com do their sessions ?
[13:51:25] kamiyuki: let's say i have store.myshopify.com, this store can have users on their own while the owner can login into the backend as well
[13:51:31] BrazenBraden: defswork: so def current; and def has_right?; ??
[13:51:43] jan1337z: when I do .class on an array element (which is of type NewSection) I get ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy_NewsSection
[13:51:46] defswork: def self.current does some magic
[13:52:08] defswork: and application controller sets it up
[13:52:47] BrazenBraden: I notice you can do "def has_role?" but not "def has_role(role)?"
[13:53:05] defswork: you can do either
[13:53:09] defswork: ? means nothing
[13:53:13] BrazenBraden: do i have it the wrong way around?
[13:53:22] BrazenBraden: def has_role?(role)
[13:53:30] defswork: you can do either
[13:53:36] BrazenBraden: I like the ? cos a bool will be returned
[13:53:37] defswork: on takes an arg, one doesnt
[13:53:44] defswork: it means nothing though
[13:53:54] defswork: its an indication only
[13:53:58] defswork: doesnt presume anything
[13:54:17] defswork: convention says methods that end in ? return true/false
[13:54:28] defswork: but it's purely a convention
[13:54:33] defswork: ? is no different to a-z
[13:54:44] BrazenBraden: ok. but i like the convention :)
[13:55:41] skroon: when rails is in Development mode, it logs error messages twice: "birthday" => ["can't be blank", "can't be blank"] I noticed that in Staging mode, it doesn't anyone that has a clue?
[13:56:13] horrror: njero: it works man! thanks. I have one more issue. I have html image tags (<img src="/assets/nameof.png"> ) which aren't showing probably because of the assets pipeline . What can I do?
[14:13:04] Syrit: Guys, i know that it's illegal to nest html forms, but in my page, i have 3 forms, the main page form , and 2 ajax forms, i am able to solve the nesting issue with the first ajax form, because i am using a modal for it, and no matter where i place the "render" , so i simply placed it after the </form> ! but for the second ajax form i want it to be place in a specific place, not as modal, but as inline fileds that are added dynamically via jQuery, any way
[14:13:04] Syrit: to get around this ? any keywords to use in my search ?
[14:18:57] scyllinice: Syrit: You can do dynamic form fields without making them their own form
[14:19:52] Syrit: hmm, i thought that it's more simple to have the fields that i want in a partial/ form and give it a "hide" class, scyllinice
[14:20:18] Syrit: because i want to submit with ajax evantually
[14:20:35] scyllinice: Why are they in their own form tag though?
[14:21:04] Syrit: because i want to submit via ajax, to a specific controller scyllinice
[14:22:36] scyllinice: I would strongly consider not trying to do what you're doing. As you said, Nesting forms inside of forms is illegal HTML
[14:22:39] Syrit: hmm, may be i sohuld keep them in a partial, and then with jQuery take the entered value, and submit it instead of doing so with form ?
[14:23:26] Syrit: is that considered a good practice ?
[14:23:55] alexparker: Rails 4 in production mode still displays routing error stack traces and all available routes. i'm using nginx + unicorn. I can't seem to google the right words to get a resolve for this. Does anyone here know the proper way I can display a 404 error page instead of the routes stack trace?
[14:23:56] Syrit: i mean, what do you guys do, when you need to submit via ajax, to a specific controller ? do you write jQuery/Js methods to handle this ?
[14:24:29] scyllinice: alexparker: How did you start unicorn?
[14:24:45] alexparker: service unicorn start
[14:25:08] scyllinice: gist the upstart config then
[14:25:18] scyllinice: Sounds like it's starting in a mode other than production
[14:26:21] scyllinice: Syrit: Does accepts_nested_attributes_for make sense for what you're trying to do?
[14:26:41] Syrit: no scyllinice
[14:27:28] alexparker: scyllinice: https://gist.github.com/alexparker/6595050
[14:28:59] scyllinice: alexparker: Ok, that's the config. If you do ps -ef | grep unicorn on your server, do you see -E production?
[14:29:49] scyllinice: How does your config/environments/production.rb look?
[14:29:57] pothibo: If I have a route like this one → https://gist.github.com/pothibo/e3be4b19b57348e26e0f Is there a way to figure out the context (inside a managements resources) from the users_controller?
[14:30:45] defswork: pothibo, it will be in management_id
[14:31:04] pothibo: defswork: collection do … end: There's no management_id
[14:31:21] defswork: it's inside managements
[14:31:22] ner0x: Morning all. :)
[14:31:32] alexparker: scyllinice: almost entirely default http://cl.ly/RR2R
[14:32:02] defswork: pothibo, managements/n/users - n will be in management_id
[14:32:47] scyllinice: His route is /managements/users
[14:32:58] scyllinice: It's on the collection of managements
[14:33:07] pothibo: scyllinice: Thank you.
[14:33:36] defswork: then what context ?
[14:33:43] coolmatt: struggling with this controller test
[14:33:49] coolmatt: anyone wanna check out a gist and tell me whats wrong
[14:33:54] pothibo: coolmatt: share your gist
[14:33:59] defswork: you just want to know that users controller was accessed via the managements url ?
[14:34:12] scyllinice: alexparker: Ok. Nginx config? Nothing looks wrong to me so far
[14:34:57] pothibo: defswork: don't bother. I'll open up ActionDispatch and figure it out.
[14:35:51] EminenceHC: I want to have multiple user types tied to the User model. For example Student. But I cant seem to get a list of all the Students and their information side by side with the information stored in their user table. Will someone please look at my code and tell me what I am doing wrong? https://gist.github.com/charlesnutter/6588229#file-students_controller-rb-L22
[14:35:53] alexparker: scyllinice: the sites-availailable config?
[14:36:56] pothibo: EminenceHC: ^^
[14:37:03] scyllinice: EminenceHC: Must be hard having a name that's the same as a more famous developer in this community
[14:37:26] EminenceHC: scyllince: I had no idea haha, makes me want to change it.
[14:37:58] scyllinice: I mean your actual name, not your IRC nick, just to be clear
[14:38:35] EminenceHC: pothibo: How would I use rolify for this?
[14:38:45] EminenceHC: pothibo: It is already installed actually.
[14:39:16] pothibo: EminenceHC: I'm not sure I understand… To me Student would be a STI of User ?
[14:39:46] pothibo: EminenceHC: Either way, which line is problematic in your controller and what is the expected behavior?
[14:40:17] EminenceHC: pothibo: The reason I havnt used STI is because Student will have like 50 fields and Counselor will only have like 5. I wanted to avoid having a bunch of blank fields for users that dont need them. Am I crazy for thinking this way?
[14:40:23] alexparker: scyllinice: just pmed you the config
[14:41:01] alexparker: not sure why: paranoia i suppose haha
[14:41:43] EminenceHC: pothibo: In the student controller the index function and I am trying to show the results in students/index.html.erb using @user.each do..
[14:42:10] pothibo: EminenceHC: Ok, so @students in line #26 means nothing right?
[14:43:06] EminenceHC: pothibo: Ya in this case. I have been experimenting with different ways but I cant seem to be able to get the information from the student and user tables in one .each statement
[14:43:14] pothibo: EminenceHC: ok
[14:43:24] pothibo: s.loginable is nil?
[14:43:40] EminenceHC: Yeah that is the error i recieve.
[14:43:53] pothibo: The problem is in your create field
[14:43:56] pothibo: create action I mean
[14:44:32] EminenceHC: pothibo: Oh really? I thought it was fine because I have a nested form that will create a user with a student relation all from one form.
[14:44:32] pothibo: EminenceHC: you should save your student before assigning it to @user.loginable. I would save the @student at line 7
[14:44:57] pothibo: EminenceHC: form is not bound to a controller… they are independant
[14:45:12] MickeySoFine: just got a wierd message after installing latest rails:
[14:45:13] EminenceHC: pothibo: Ah I see, let me change that.
[14:45:15] MickeySoFine: The program 'rails' can be found in the following packages:
[14:45:15] MickeySoFine: * ruby-railties-3.2
[14:45:24] MickeySoFine: anyone know what this means?
[14:45:42] MickeySoFine: i used gem install rails to install it
[14:46:01] pothibo: MickeySoFine: gem uninstall ruby-reailties-3.2 ?
[14:46:47] pothibo: gem uninstall ruby-railties-3.2 I meant. This looks like a third party railtie that might conflict. Unless you have a reason for having it, I would try touninstall this first
[14:47:34] MickeySoFine: ok I'll give that a go pothibo
[14:50:44] EminenceHC: pothibo: I moved the save user method. I changed @users to @students in my .each statement but it still doesn't like @students = @users.loginable in my students controller.
[14:51:06] pothibo: EminenceHC: Why would you change @users to @students?
[14:51:37] jesuis: I get an error in my simple contact form in rails 4 "First argument in form cannot contain nil or be empty" My view: " <%= form_for @contact do |f| %>" and my controller defines it: " def new
[14:51:38] jesuis: @contact = Contact.new
[14:51:39] jesuis: end" - Any ideas what might be causing this? I've searched all over the place.. any clues?
[14:52:05] faramir: hi, i need some help with a simple (i think) rspec task. i'm writing a class that will parse spreadsheets. i have a sample spreadsheet that i'd like to use for testing. is there a "right" way to do that with rspec and rails?
[14:52:45] EminenceHC: pothibo: I tried using @users and @students in the .each function but neither like @students = @users.loginable in the students controller.
[14:53:08] EminenceHC: pothibo: Undefined method 'loginable'
[14:54:39] soahccc: Is there something in rails 4 to negate where(hash) calls? I still hate the "IS NOT NULL" way of doing it because rails won't add the database table in front of the column name which brakes some joins unless I do it manually
[14:56:17] faramir: soahccc: where.not(col: 'value') works in rails 4. is that what you're looking for?
[14:56:45] soahccc: faramir: that would be perfect :)
[14:59:44] jesuis: scratch that i guess
[15:00:35] timhansen: morning, all
[15:01:03] scyllinice: faramir: There's nothing incorrect about using fixture files
[15:04:01] coolmatt: pothibo sorry just figured it out
[15:04:15] timhansen: i'm having an issue with a custom form url. i keep getting routing error, no route matches, with the following: https://gist.github.com/willc0de4food/7ca88618c245dd3925f5
[15:04:29] timhansen: any hints as to what i'm doing wrong?
[15:06:02] EminenceHC: I have a polymorphic relationship between User and Student. Is it possible to get a list of all the values of the user fields and the values of the student fields in one .each statement on the index page? Code is here: https://gist.github.com/charlesnutter/6588229
[15:07:01] mikecmpbll: timhansen: rake routes
[15:07:14] mikecmpbll: is there a location_start_recording named path?
[15:07:42] timhansen: mikecmpbll: yes
[15:07:54] timhansen: mikecmpbll: location_start_recording POST /locations/:location_id/start_recording(.:format) locations#start_recording
[15:09:58] mikecmpbll: timhansen: so where's it gunna get the :location_id from? :)
[15:10:57] ivanskie: how do I do this: <button class="btn btn-danger" data-dismiss="modal">Delete</button> with button_to ?
[15:12:01] mikecmpbll: ivanskie: what have you tried?
[15:12:19] ivanskie: im only up to here, <%= button_to("Delete", { action: :delete }, class: "btn btn-danger") %>
[15:12:33] ivanskie: modified the code for the bootstrapped button_to..
[15:12:51] ivanskie: but how do i get it to close the modal? im not even sure if the modal works yet, one sec
[15:13:14] mikecmpbll: ivanskie: presumably you'll want to add the data-dismiss data item.
[15:13:45] mikecmpbll: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to
[15:13:46] ivanskie: but does button_to accept it somewhere?
[15:13:50] mikecmpbll: ivanskie: look under options
[15:13:53] elaptics: ivanskie: if the button is just for javascript then use button_tag instead
[15:13:54] mikecmpbll: there's one called :data
[15:13:57] eddrain: I have a button and it has a url and when I click on the button I see the URL on browser change to it. I want controller to grab extra parameter but when I inspect params it is not there what am I doing wrong?
[15:14:03] ivanskie: got it.. thanks
[15:14:12] elaptics: ivanskie: button_to creates a whole form which I guess you don't actually want
[15:14:23] mikecmpbll: data: { dismiss: :modal }
[15:15:00] mikecmpbll: and yeah, what elaptics said^
[15:16:24] mupkoo: is there a way to set default url options only for some routes
[15:16:44] mikecmpbll: mupkoo: what sort of defaults
[15:16:49] mupkoo: for example
[15:17:17] mupkoo: I have a module with scope '/:slug_one/:slug_two/'
[15:17:52] mupkoo: and in the base controller I set them with the current ones
[15:18:07] mupkoo: slug_one: Model.slug, slug_two: ModelTwo.slug
[15:18:25] mupkoo: but they are added as a query string to the root_path for example
[15:18:45] mupkoo: and this is something that I don't want :)
[15:20:49] helpa: Please do not use fake values, as they can be confusing or misleading. Sometimes both.
[15:21:01] pipework: Describe something meaningful. :)
[15:21:28] makerbreaker: hey, Im having a bit of troubel upgrading to rails 4
[15:21:38] makerbreaker: im getting a core dump on any rake command
[15:21:41] makerbreaker: or just "rake"
[15:21:47] makerbreaker: is there something I forgot to do?
[15:22:00] mupkoo: I have the following scope : '/:client_slug/:product_slug'
[15:22:04] mikecmpbll: mupkoo: what is Model.slug, ModelTwo.slug? are they constants
[15:22:27] EminenceHC: I have a polymorphic relationship between User and Student. Is it possible to get a list of all the values of the user fields and the values of the student fields in one .each statement on the index page? Code is here: https://gist.github.com/charlesnutter/6588229
[15:22:38] mikecmpbll: mupkoo: the typical way to implement slugged URLs is to have your model return the slug instead of it's ID
[15:22:42] mikecmpbll: then you can keep resourceful routing.
[15:24:36] mupkoo: http://bin.fuelphp.com/snippet/view/pK
[15:27:43] mupkoo: http://bin.fuelphp.com/snippet/view/pL
[15:27:47] mupkoo: One with the result
[15:28:05] naftilos76: hi everyone, is there a simple way to reverse a binary value from say 0b00100 to 0b11011 in ror?
[15:28:09] mupkoo: Maybe I can stop the additional params to be included as query string
[15:28:47] mikecmpbll: mupkoo: https://gist.github.com/mikecmpbll/6595920
[15:28:49] dagobah: Anyone know how/if one can prefix something to the start of the path helper, even in a namespace?
[15:29:36] mikecmpbll: dagobah: what do you mean?
[15:30:18] mupkoo: mikecmpbll: this is something that I didn't know :) Thx
[15:30:23] mikecmpbll: mupkoo: no problem.
[15:30:44] dagobah: I want `namespace :foo { get '/something' => 'bar#new' }` to be new_foo_bar_path and NOT foo_new_foo_bar_path.
[15:31:04] dagobah: as: :new_foo_bar results in a helper named foo_new_foo_bar_path. Which does not interest me.
[15:31:30] jessen: I am having a hard time trying to override a devise controller. I change the route and either it doesn't find the controller. devise_for :users, :controllers => { :invitations => "user/invitations" }
[15:32:27] mupkoo: jessen I am not sure, but have you tried 'user#invitations' if the User is module?
[15:33:17] EminenceHC: Why doesn't this work?: Student has a polymorphic relationship to user. In the console I can call u = User.last, then u.loginable the "polymorphic relationship" and u.loginable.case_no will get me a value of the student. Why does this not work in a .each statement? For example @users = User.all, <% @users.each do |s| %><%= s.loginable.case_no %><% end %>
[15:33:17] mikecmpbll: dagobah: the verb automatically goes at the start, according to the rails guides.
[15:33:22] jessen: mupkoo I'll give it a shot. Do I have to put the controller in the same path that it is in the gem?
[15:33:29] mikecmpbll: dagobah: http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing
[15:33:33] mikecmpbll: new_admin_post_path
[15:34:02] mikecmpbll: oh, yours isn't a resource that'll be different
[15:34:30] mupkoo: no, I usually overwrite the sessions controller just by adding a file controllers/sessions_controller.rb
[15:34:36] jessen: wrong constant name User#invitationsController is what I got
[15:34:38] dagobah: I want the helper to have the same name it would have if it were made from a `resources` route.
[15:34:42] mupkoo: and devise_for :users, path: 'auth', controllers: { sessions: 'sessions' }
[15:35:12] jessen: I am attempting to override this url: http://localhost:3000/users/invitation/accept?invitation_token=KwWs1p8sjTA41jRb4ANw
[15:36:45] pipework: I don't use devise. It hurts a lot when you outgrow it.
[15:36:46] jessen: This is the response : No route matches "/users/invitation/accept"
[15:36:53] omarqureshi: right, people who are smarter than i
[15:36:53] omarqureshi: https://gist.github.com/omarqureshi/1137201af0ad62833228
[15:37:03] omarqureshi: how do i make the join in query 3 less shit?
[15:37:31] mikecmpbll: dagobah: you could probably fudge it by setting the :as for the namespace to ''
[15:37:40] mikecmpbll: and then describe the names of the routes fully
[15:37:42] dagobah: I'll try...
[15:37:44] jessen: So I should roll my own authentication?
[15:37:58] pipework: omarqureshi: If you used a database that doesn't use joins, probably.
[15:38:12] pipework: jessen: Or use sorcery as a base, since it's a generator rather than a tucked away engine.
[15:38:36] omarqureshi: porting my database to a single file pipework
[15:38:47] pipework: omarqureshi: Should graph that shit.
[15:39:27] mikecmpbll: dagobah: alternatively, perhaps try scope 'foo', module: 'foo', path: '/foo' and see if that behaves differently.
[15:39:34] jessen: I need to be able to send email invitations to the site, if sorcery can do then that's awesome. Technically the site has a pos authentication system
[15:40:27] pipework: Sorcery allows you to create such things, yes.
[15:40:44] pipework: https://github.com/NoamB/sorcery#philosophy
[15:40:53] mikecmpbll: dagobah: pardon me: scope '/foo', module: 'foo'
[15:41:41] momomomomo: pipework: Growing pains with devise?
[15:41:53] jessen: but will sorcery work with rails 3.0.9. I'm working on getting the server upgraded, but I'm fairly stuck with this version
[15:42:36] dagobah: Thanks mikecmpbll.
[15:44:00] EminenceHC: In the console I can call u = User.last, then u.loginable the "polymorphic relationship" and u.loginable.case_no will get me a value of the student. Why does this not work in a .each statement? For example @users = User.all, <% @users.each do |u| %><%= u.loginable.case_no %><% end %>
[15:44:40] mikecmpbll: EminenceHC: i dunno, you tell us, you have the error, we don't!
[15:45:17] EminenceHC: mikecmpbll: Hehe the error is "undefined method `case_no' for nil:NilClass" I am not sure why it is undefined though..
[15:45:22] mikecmpbll: but I assume one of your users hasn't got a "loginable" therefore the error will be undefined case_no for nilclass
[15:45:28] mikecmpbll: wow i'm a genius :)
[15:45:54] EminenceHC: mikecmpbll: Omg that is probably it. Let me delete all my users and try again!
[15:47:49] Syrit: guys, is it "Mandatory" , that the field used to create a record via ajax/jQuery , should be placed inside a form tag ?
[15:48:30] mikecmpbll: Syrit: "the field used to create a record"?
[15:49:00] Syrit: mikecmpbll, i want to create a new record
[15:49:04] Syrit: using ajax
[15:49:38] mikecmpbll: Syrit: and the problem is?
[15:49:57] mikecmpbll: Syrit: you can submit whatever data you want using ajax.
[15:50:02] EminenceHC: mikecmpbll: That was it! Wow I feel so foolish. Thanks a bunch!
[15:50:07] mikecmpbll: EminenceHC: heh, np.
[15:50:11] Syrit: the problem is, that i want those "fields" or this record to be created from within a page that is a _form, so i can't nest forms
[15:50:49] mikecmpbll: Syrit: right. that doesn't sound like a problem to me.
[15:50:56] mikecmpbll: pass the form object to the partial as a local.
[15:51:18] Syrit: no no , not this.
[15:51:47] Syrit: in my meeting/new form, i would like to allow the user to create a new "client" on the fly
[15:52:36] mikecmpbll: there's a railscast about doing that, you should probably watch/read it
[15:52:49] Syrit: jquery ajax ?
[15:52:57] mikecmpbll: and a bunch of blogs
[15:53:13] Syrit: actually, i did that using a modal
[15:53:20] s2013: anyone knows why i have to type in . ~/.bash_profile on ubuntu terminal everytime i wanna get rails working
[15:53:41] Syrit: hence i can place "render" any place, i avoided the form nesting, but now, i want the fields placed in a specific place..
[15:55:16] bastilian: s2013: what shell are you using?
[15:55:57] s2013: just the reg terminal?
[15:56:16] mikecmpbll: Syrit: so i still don't really know what the problem is, exactly.
[15:57:19] Syrit: the problem is , i placed the fields i want inside a form partial, and give it a hidden class, so, when i wanted to render this partial inside the meeting/new, i coudln't because i got form nesting mikecmpbll
[15:57:56] mikecmpbll: why couldn't you render it?
[15:58:25] bastilian: s2013: what does "echo $SHELL" tell you?
[15:59:15] Syrit: mikecmpbll, i can, but if i submit, the meeting/new will be submited, instead of the inner form
[15:59:42] mikecmpbll: Syrit: why are you creating multiple forms, don't you want to add inputs to your existing form?
[16:01:02] Syrit: yes, but i thought that the best way to do so, is to put the fields inside a form and set it's remote to true mikecmpbll
[16:01:02] s2013: /bin/bash
[16:01:49] mikecmpbll: Syrit: it depends on exactly what you want, but a common solution would be to add fields_for to your form, and have the parent model accepts_nested_attributes_for :child_model
[16:02:57] bastilian: s2013: http://askubuntu.com/questions/121073/why-bash-profile-is-not-getting-sourced-when-opening-a-terminal
[16:03:38] Syrit: i see, its a bit complicated mikecmpbll , do you have time to bare with me ? :D
[16:03:52] s2013: thanks bastilian
[16:04:22] bastilian: s2013: thank google. :)
[16:05:26] robertjpayne: is it possible for a model to reference itself in an association? I have friendship.user_id, friendship.contact_id and want to make an "inverse" relationship
[16:05:28] mikecmpbll: Syrit: not a great deal. but it would be useful to know if this is what you're trying to achieve: http://railscasts.com/episodes/197-nested-model-form-part-2
[16:06:15] Syrit: hmm i still need advice to decide if this is the way to go mikecmpbll
[16:06:39] mikecmpbll: the "nested form" is that creating objects that are associated to the main form?
[16:06:46] elaptics: robertjpayne: yes, you can
[16:07:02] Syrit: not thise mikecmpbll
[16:07:34] fp-: ever since upgrading to Rails 4, I'm getting this error: Mysql2::Error: Data too long for column 'body'
[16:07:43] momomomomo: robertjpayne: http://stackoverflow.com/questions/96003/multiple-relations-to-the-same-model-in-rails
[16:08:05] Syrit: i have a meeting, meeting has many clients, (now i can crate clients using a modal/ajax) , and each client has many contacts, (i want to allow the user to add contacts for the selected client using ajax ) mikecmpbll
[16:08:28] robertjpayne: momomomomo: that is multiple associations but a model associating itself
[16:08:39] mikecmpbll: so have Client accepts_nested_attributes_for :contacts
[16:08:52] mikecmpbll: and add fields_for :contacts to your client form.
[16:08:53] robertjpayne: I think it needs to be a custom method anyways.. the inverse is based on two columns
[16:09:22] momomomomo: robertjpayne: What are you trying to achieve, exactly
[16:09:50] Syrit: right, but , the client form is a Modal, and i don't want to add the contacts from within the modal mikecmpbll , i want to have fields in the meeting form ..
[16:10:16] robertjpayne: momomomomo: I have a "friendship" that has "user_id", "friend_id". I create two rows for each "friendship" to track the status from the user's perspective. Basically just want "friendship.inverse"
[16:10:22] mikecmpbll: Syrit: why? if contacts are for clients why would you put contacts in the meeting form
[16:11:49] momomomomo: robertjpayne: Why do you want to create the inverse row in the first place? Just to make sure that both users have entries in the friend_id column? That seems redundant to me
[16:12:02] Syrit: because i want to add them as inline fields mikecmpbll , not as a modal, hence, i might not be needing to add contacts at all, it might be so rare case, that's why i wanted to keep the contacts modal "unclutterd", and this way, if the user wanted to add contacts, no need to press "New cilent! " to be ablet to add contacts
[16:12:25] Syrit: and i am already adding clients using modals
[16:12:36] mikecmpbll: so when they're adding a contact they choose a client from a list?
[16:12:50] Syrit: exactly !
[16:13:05] Syrit: and then i have the client's contact listed dynamically
[16:13:15] Syrit: if no any contacts, add new
[16:13:15] robertjpayne: momomomomo: Assume you are id "1" and I am id "2" and you add me as a friend... your row "1,2,requested" and my row "2,1,requested-by"
[16:13:25] mikecmpbll: so when your modal is submitted you'll need to refresh the clients in the main form
[16:13:41] Syrit: hmmmm... right..
[16:13:53] Syrit: i can do that with onchange...
[16:14:10] mikecmpbll: presumably when the modal form is submitted ajaxically, it renders a .js.erb?
[16:14:19] mikecmpbll: your app renders a *
[16:15:01] Syrit: well, i am doing nothing in it mikecmpbll
[16:15:09] mikecmpbll: closing the modal?
[16:15:10] Syrit: only closing the modal
[16:15:23] mikecmpbll: yeah, so add some jquery to update the values of the select's
[16:15:35] mikecmpbll: with Client.all, or whatever.
[16:16:11] Syrit: oh, mikecmpbll i forgot, no i chosed other way, i am closing the modal with ajax:success binding
[16:16:14] momomomomo: robertjpayne: By virtue of the way the friendship is created, isn't user_id always going to be one of 'requestor' or 'request' and vice versa for the friend_id ?
[16:16:31] mikecmpbll: Syrit: i see, well you can add the extra code to ajax:success binding then
[16:16:41] Syrit: yes sure,
[16:16:48] Syrit: and now, back to the main question mikecmpbll :D
[16:17:03] terrellt: Anyone know which module defines delegate?
[16:17:17] robertjpayne: momomomomo: yes user_id is always the initiator but again it creates a second "inverse" row so the other user can lookup their pending requests from other users.
[16:17:22] momomomomo: robertjpayne: Check out http://railscasts.com/episodes/163-self-referential-association
[16:17:37] mikecmpbll: terrellt: looks like it's defined on Module
[16:18:09] robertjpayne: momomomomo: I've seen that, really was just curious if it's possible to have a has_one on a model that uses some properties of that model itself to lookup the association. I don't think it is possible though.
[16:18:15] mikecmpbll: terrellt: as a core extension for rails
[16:18:58] mikecmpbll: Syrit: your Meeting model will need to accepts_nested_attributes_for :contacts
[16:19:07] mikecmpbll: and has_many :contacts, through: :clients
[16:19:25] mikecmpbll: (and has_many :clients, obviously)
[16:19:31] momomomomo: robertjpayne: You might be able to - I haven't done it before, though: http://guides.rubyonrails.org/association_basics.html#self-joins
[16:20:00] mrpoundsign: Hello everyone. :) I have been fighting a problem for a few days now with extremely slow (30m+) rails loading on Ubuntu. I don't have this problem on my mac (same repo, both using RVM, same ruby version, etc)
[16:20:10] Syrit: this way, i can use fields_for contacts mikecmpbll ?
[16:20:15] mikecmpbll: Syrit: correct.
[16:20:55] whitsan: I'm trying to create an alias route for a single record.
[16:21:31] whitsan: Basically I want an alias for a the current route: /tags/interviews
[16:21:39] whitsan: to just be /interviews
[16:22:08] whitsan: How do I build a match statement?
[16:22:09] Syrit: so, what do you recommend, this way? or adding fields dyncamically with jQuery, then getting the .val() of each fields, and submiting an ajax request to contacts ! along with the selectec client id ?
[16:22:29] whitsan: match 'interviews' => 'tags#show/interviews' ?
[16:22:55] whitsan: That's erroring out. I need to figure out how to add a parameter to the route
[16:23:02] Syrit: mikecmpbll, ^^^
[16:23:12] Syrit: so, what do you recommend, this way? or adding fields dyncamically with jQuery, then getting the .val() of each fields, and submiting an ajax request to contacts ! along with the selectec client id ?
[16:23:27] mrpoundsign: I've searched but haven't found anything that matches what I am seeing. Is anyone familiar with this type of issue on Ubuntu? I went as far as to completely remove ~/.rvm, completely reinstall 1.9.3-p448 and 2.0.0-p247. Tried under both rubies, running bumbler to check load times (it's slow at the first gem, with rails gem alone taking 118 seconds to load
[16:23:54] momomomomo: whitsan: http://guides.rubyonrails.org/routing.html#naming-routes
[16:27:18] mikecmpbll: Syrit: not sure really, it's a design choice.
[16:28:07] whitsan: momomomomo: Here is my existing routing file: https://gist.github.com/whitnelson/6596786
[16:28:16] Syrit: so, there is nothing wrong/ better pracitce in that mikecmpbll ?
[16:28:51] whitsan: The url needs to be /channel/interviews
[16:29:02] mikecmpbll: Syrit: with complex forms you can look into form objects if you like
[16:29:16] whitsan: I just tried adding this: get 'tags/interviews', as: 'interviews'
[16:29:25] whitsan: to the /channel scope
[16:29:33] Syrit: thank you so much for your help mikecmpbll
[16:29:46] mikecmpbll: Syrit: no probe, good luck.
[16:29:56] Syrit: :D thanks
[16:30:18] gita: i am reading the documentation for the asset pipeline in rails 4, and i'm seeing that sprockets is enabled by default, such that when i generate a controller, a controller.js.coffee script is created and then added to every page view. i diabled this by removing the require directive from application.js, but i'm wondering if there is a way to make rails not generate that file?
[16:30:31] gita: i don't want to have all my controller names on display
[16:31:14] ivanskie: i think im doing this wrong: <%= link_to '<i class="icon-pencil"></i>', edit_item_path(item) %>
[16:31:19] ivanskie: throws an error
[16:31:32] gita: okay, never mind. --assets=false
[16:34:36] ivanskie: tells me syntax error, unexpected tSTRING_DEND, expecting ')'
[16:35:35] ivanskie: <%= link_to '<i class="icon-remove"></i>', item, method: :delete, confirm: 'Are you sure?' } %>
[16:35:39] ivanskie: thats what throwing the error..
[16:36:04] ivanskie: and '<i class="icon-remove"></i>' doesn't work either, just shows it as text in html
[16:36:36] foucist: ivanskie: try <%=h perhaps
[16:36:39] foucist: or something like that
[16:36:52] foucist: but there's a way to tell it to not escape it
[16:37:59] ivanskie: <%= link_to '<i class="icon-remove"></i>', item, method: :delete, confirm: 'Are you sure?' } %> and this is throwing me the error where its expecting a ')' for some reason
[16:38:10] gchaturvedi: Hey guys..had a quick question, so each session has it's own ID and data store in Rails right? So if I store something like 'my_key' in a rails session…each session would have it's own set of 'my_key' or would they collide?
[16:40:02] whitsan: Can anyone tell me what a match statement does in a route?
[16:40:56] ivanskie: alright there was a roug } but now its telling me could not obtain a database connection within 5.000 seconds (waited 5.001 seconds)
[16:41:10] gita: try <% link_to "#{"<i class =\"icon-remove\"></i>"}",...
[16:41:33] gita: ugly, but it might work
[16:41:48] gchaturvedi: whitsan: match let's you match a certain URL path to a controller method
[16:42:16] gchaturvedi: aka match 'sign out', to: 'sessions#destroy', via: ['delete'], :as => :signout
[16:42:23] gchaturvedi: match '/signout' rather
[16:42:40] gita: ghr: where does 'my_key' come from?
[16:42:51] gita: er, gchaturvedi (tab complete fail)
[16:42:52] whitsan: Let's say you have route: /controller/action/item, and you want to add an alias /controller/somestring
[16:43:11] gchaturvedi: gita: that is some user data
[16:43:24] gita: gchaturvedi: pulled from the database when the user logs in?
[16:43:38] gchaturvedi: For my purposes no..i'm using an external API to get user information
[16:43:45] gita: gchaturvedi: or generated on the fly when the session is established
[16:43:47] gchaturvedi: so i will authenticate a user with a given username/password and get an access token
[16:44:00] gchaturvedi: from an external JSON api
[16:44:11] gita: for each session?
[16:44:17] whitsan: would that be a match? like: match 'somestring' => 'controller#action#item' or something?
[16:44:56] gita: well, unless there's some timing issue (eg, if the access token is cached), i'd expect the api to be generating a new token for each request
[16:44:58] gchaturvedi: whitsan: it's match '/myurl', => 'controllername#methodname', via: 'post or get or delta', :as => :the pathname
[16:45:19] whitsan: what's the pathname?
[16:45:26] gita: the API docs don't specify?
[16:45:26] gchaturvedi: that let's you name your path
[16:45:38] gchaturvedi: so if i picked :signout
[16:45:43] gchaturvedi: i could do redirect_to signout_path
[16:45:51] gchaturvedi: gita: its a private oath provider
[16:45:58] whitsan: how about the item?
[16:46:04] gita: gchaturvedi: but your question is taking that token and putting it into the session data that rack returns?
[16:46:25] gita: gchaturvedi: i thought oauth tokens were supposed to go in header directives?
[16:46:25] gchaturvedi: yes..so the way i check if a user is signed in..they input their username/passwd into the form
[16:46:38] gchaturvedi: i send that to my external API
[16:46:41] whitsan: gchaturvedi: How do I send the item to them method?
[16:46:42] gchaturvedi: if its authenticated..they give me a set of access tokens
[16:46:44] gita: (so that they're not cached by browsers?
[16:46:55] ivanskie: that breaks it gita
[16:46:58] gchaturvedi: now i need to store that somehow in the session
[16:47:07] gchaturvedi: there really is no user_id
[16:47:17] gchaturvedi: so i'm storing it in session['my_user'] = {all the tokens}
[16:47:23] gita: ivanskie: breaks which?
[16:47:29] gchaturvedi: i'm just wondering if this is ok..and session['my_user'] won't be overwriting each other
[16:47:31] gchaturvedi: if 2 users are signed in at same time
[16:47:33] gchaturvedi: with 2 diff sesssions
[16:48:01] gita: 2 users should have 2 diff sessions, yes
[16:48:23] gchaturvedi: whitsan: What do you mean..how do i send the item to them method?
[16:48:33] whitsan: gchaturvedi
[16:48:46] gita: it's been a while since i've looked at rack and session store in rails. the last thing i remember was noticing that the sessions weren't destroyed properly when the user logged out
[16:48:54] whitsan: gchaturvedi: I want the alias to go to controller/method/item
[16:49:20] gchaturvedi: Um..what's item?
[16:49:25] gchaturvedi: usually you match a path to just a controller and method
[16:49:30] whitsan: A specific item
[16:49:35] whitsan: in a collection
[16:49:48] gita: gchaturvedi: generally speaking, state data stored in the session doesn't work if one user has the ability to corrupt the other user's session data
[16:49:54] whitsan: employees/view/bob
[16:50:09] whitsan: I want to alias employees/bob
[16:50:37] gchaturvedi: gita: yes :) i understand
[16:50:40] gita: anyhow, i seem to have fixed my original problem. back to lurking.
[16:50:43] nofxx: gita: actually you don't destroy the session on log out, even w/o an user logged there's a session
[16:50:54] gchaturvedi: yeah with a session_id and _csrf_token
[16:51:01] gchaturvedi: whitsan: not sure..i'm not an expert at routes yet
[16:51:02] dangerousdave: I have an odd error. My application is unable to connect to the development database because it is trying to use deatails under the "production" heading in database.yml, yet the rails error confirms that the environment is "development"
[16:51:04] foucist: whitsan: site.com/employees/bob does access the view method
[16:51:09] gita: nofxx: session data should be deleted when a user logs out, though
[16:51:18] gchaturvedi: whitsan: i would not break the REST convention..and have new pahts
[16:51:24] gchaturvedi: whitsan: rails doesn't lend itself nicely to it
[16:51:32] gita: or, at the very least, marked as expired
[16:51:43] gita: i shouldn't be able to mine an old session out of your browser cache and re-use it
[16:51:49] gchaturvedi: gita: no..session data shouldn't be deleted..all u have to do is remove the key:val thats related to the user data
[16:51:58] gchaturvedi: a session obj still should exist
[16:52:08] ivanskie: even though rails4 says it automatically does .html_safe
[16:52:18] gita: gchaturvedi: that qualifies as session expiration, then
[16:52:29] ivanskie: '<i ...>,/i>'.html_safe fixed it
[16:52:31] whitsan: gchaturvedi: have a look at my existing routing https://gist.github.com/whitnelson/6596786
[16:52:41] gita: ivanskie: thanks. good to know.
[16:52:49] whitsan: I want to create a path to a specific tag
[16:53:24] nofxx: Wondering if there's some best practice/nice way for children CRUDs... I mean, class Car < Auto , class Bike < Auto. I want to edit/create everything on /autos/new .. any tips for _type ? Old, ugly dropdown?
[16:53:26] ivanskie: so.. <%= link_to '<i class="icon-remove"></i>'.html_safe, item, method: :delete, data: { confirm: 'Are you sure?' } %> without .html_safe it doesnt parse the html in the ''
[16:53:34] whitsan: like this: /channel/interviews => /channel/tags/interviews
[16:53:54] gchaturvedi: whitsan: sorry…that's a bit more advanced than I can think up the answer to
[16:53:58] gchaturvedi: whitsan: i'm still a beginner heh
[16:54:32] ivanskie: interesting... bootsy doesn't show up on first render.. i have to refresh the page for it to showup
[16:54:46] whitsan: gchaturvedi: you and me both. :0
[16:54:48] nofxx: whitsan: nested routes... resources :channel { resources :tags { resources :interviews
[16:54:57] nofxx: whitsan: 3 lvls are the max you can go iirc
[16:55:09] bklane: Anyone have recommendations on how to do product browsing for a webstore so a person and choose different attributes via a sidebar?
[16:55:15] gchaturvedi: i wish we had a better chatroom than IRC lol
[16:55:25] gchaturvedi: someone should go build an chat app where cut / paste code works well
[16:55:51] gita: you mean like campfire?
[16:56:09] gchaturvedi: that isn't public tho
[16:56:17] gchaturvedi: its for teams
[16:56:24] nofxx: irc is as good as your client... get a better client ;)
[16:56:35] gchaturvedi: using colloquy
[16:57:07] nofxx: there's a ruby one in cocoa... forgot the name. i was using it on osx
[16:57:10] gchaturvedi: lunch ttul later.
[16:57:17] gchaturvedi: lemme know if u remember
[16:57:44] horrror: hi guys, i have deployed my app and everything works well, besides images that are called from css files. I've tried image-url('file.png') and it directs to ('/assets/file.png') as it should, but from some reason it's not visible on html page. and yes, the image files exist.
[16:58:16] nofxx: horrror: webserver? did you configured the static assets path?
[16:58:55] horrror: I'm using unicorn and capistrano on digitalocean
[16:59:05] horrror: what's assets path? isn't it public/assets/*?
[16:59:14] foucist: apps/assets
[16:59:14] nofxx: horrror: only unicorn ??
[16:59:31] nofxx: yup.. configure nginx to serve public/assets/*
[16:59:52] nofxx: somewhere after you reverse proxy / to unicorn
[17:00:12] horrror: but i meant the files in app/assets/image
[17:00:30] cek: what's the helper name for joining `Model.table_name`.`#{colname}` ?
[17:00:31] nofxx: horrror: I know, they'll be compiled to public/assets
[17:00:52] cek: rails doing that somewhere in sql code - want to know what code they use
[17:00:56] nofxx: horrror: btw, check if they are being compiled... heh
[17:01:08] horrror: but the files in public/assets are shown
[17:01:11] horrror: how to check that?
[17:01:17] Zander: anyone know how to configure rails on a debian server using apache2 ? it has a DTC panel installed
[17:01:25] nofxx: horrror: ah, you can access`em directly? works?
[17:01:26] Zander: im having trouble
[17:01:40] nofxx: horrror: ls
[17:02:14] horrror: oh, then they are not compiled into public/assets
[17:02:33] nofxx: horrror: make sure there's an rake precompile somewher on the deploy
[17:02:42] nofxx: or precompile in dev and commit to repo... bad
[17:03:49] horrror: nofxx: there's precompile on deploy, and when I do precompile on dev it still doesn't create files
[17:06:06] dangerousdave: I have an odd error. My application is unable to connect to the development database because it is trying to use deatails under the "production" heading in database.yml, yet the rails error confirms that the environment is "development". Any ideas what the cause may be?
[17:06:51] ShinySides: guys would anyone know of any reasons as to why internet explorer 8 would on a form submit would delete the selected file for upload and then not submit the form?
[17:07:05] jammanbo: dangerousdave: gah … I saw exactly that recently … can't remember the solution … bah
[17:07:11] nofxx: horrror: it wont create folders on assets/ all files are cp there with md5
[17:07:22] dangerousdave: jammanbo: hah, it's very odd
[17:07:37] jammanbo: dangerousdave: pow?
[17:07:54] dangerousdave: apache, passanger
[17:07:59] horrror: nofxx: then what to do?
[17:08:19] jammanbo: dangerousdave: you've thoroughly restarted them right?
[17:08:21] nofxx: horrror: there's nothing on public/assets ?
[17:08:33] dangerousdave: jammanbo: I have
[17:08:36] nofxx: should be some error on the precompile than
[17:09:48] jammanbo: dangerousdave: what does your database.yml look like? What happens if you delete the development section?
[17:10:16] dangerousdave: jammanbo: will try now
[17:10:52] jammanbo: dangerousdave: sorry, I should say delete the production settings.
[17:11:26] dangerousdave: jammanbo: makes more sense :-)
[17:13:31] jammanbo: dangerousdave: Are you sure you are running in developement mode? The passenger default is production right? What happens when using rails server?
[17:13:50] ivanskie: question regarding acts_as_taggable_on.... in my show view, i'd like to display the associated tags each wrapped in nice bootstrap.... @item.tag_list just prints out the comma separated list... now uhm.. how do I split it up?
[17:13:59] ivanskie: <% @item.tag_list.each do 'tag' %> not working for me
[17:14:03] horrror: nofxx: from some reason it skips images folder :o
[17:14:08] dangerousdave: jammanbo: sure, it says so right in the rails error
[17:14:42] jammanbo: ivanskie: You can iterate over the @item.tags or if you prefer you could @item.tag_list.split.
[17:14:44] dangerousdave: jammanbo: "Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV and PASSENGER_ENV)
[17:15:31] ivanskie: jammanbo: that works, thank you
[17:15:39] jammanbo: dangerousdave: and when you run under webrick/rails server?
[17:16:46] dangerousdave: jammanbo: error after deleting "production" in database.yml - database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
[17:17:18] dangerousdave: jammanbo: not in position to try as this is on a shared host
[17:17:29] dangerousdave: jammanbo: works fine locally
[17:18:00] jammanbo: you must be running in production … it's the only explanation, esp. if it works with webrick. Are you explicitly setting the environment to development in your passenger/apache config?
[17:18:24] dangerousdave: jammanbo: i am
[17:19:16] jammanbo: and your yml is correct? You're not using inheritance or something?
[17:20:41] jammanbo: Is it RackEnv or RailsEnv you're setting?
[17:20:51] horrror: nofxx: clue?
[17:26:32] pwz2000: Hey guys I need to know if I am on the right path. I am trying to setup so that it will show the unread message count in the header. So I made a scope on the message model so that is gives me back unread messages. https://gist.github.com/pwz2k/6597573 . So with what I have done so far shouldn't I be able to call user.received_messages.unread.county to get the number of unread mail in the header?
[17:27:20] dangerousdave: jammanbo: RailsEnv i believe
[17:27:31] jammanbo: try RackEnv for passenger
[17:27:40] johnjohnson: pwz2000 gem install paperclip
[17:28:53] pwz2000: johnjohnson: how does paperclip fit in with displaying unread messages count in my header view?
[17:29:11] jammanbo: pwz2000: No. You'd either need to unread.map(&:county).uniq (which is obviously awful), or create a more sophisticated scope to give you the counties of the unread posts.
[17:29:18] johnjohnson: everything….
[17:29:25] horrror: nofxx: RAILS_ENV=production rake assets:precompile !!!!
[17:29:40] johnjohnson: user.paperclip.unread.county
[17:30:15] jammanbo: is this an epic trolling??
[17:30:18] kidstark: yeah i usually use paperclip to attach message counts to things
[17:32:55] kidstark: scope :unread, -> {where('read_at IS NOT NULL')} is returning messages that were read right?
[17:33:16] Velkitor: if read is a boolean false is not null
[17:33:41] pwz2000: jammanbo: ok thanks for input.
[17:34:01] kidstark: rails convention, x_at is supposed to be a date time. so it needs to be IS NULL
[17:34:07] pwz2000: johnjohnson: I will check paperclip out for that, though I am trying to limit the use of gems for app
[17:34:08] kidstark: then .size for the number of them
[17:35:13] jammanbo: Oh he wants the number of them … that makes much more sense than getting their COUNTY assoications …
[17:35:28] pwz2000: kidstark: I wrote that scope so it can return unread messages
[17:35:30] kidstark: i'm assuming county was a typo for count
[17:35:39] pwz2000: Yes, I wanted the number only.
[17:35:55] pwz2000: so in my header it will '5 unread"
[17:35:56] jammanbo: yeah, clearly it is, but didn't pick up on it rendering my answer nonsense
[17:35:59] kidstark: so leave it is nto null and do .size
[17:36:20] jammanbo: kidstark, pwz2000 do not do size. Do a count.
[17:36:44] pwz2000: user.received_messages.unread.count is what I was leaning with
[17:36:55] jammanbo: That is the correct approach.
[17:37:09] jammanbo: Size will unnecessarily retrieve all the records kidstark.
[17:37:19] pwz2000: thank you for the verification. I second guess myself on this stuff a lot lol.
[17:37:39] terrellt: Quite the opposite, no? Size should call .length if possible, otherwise it'll .count.
[17:37:43] jammanbo: If its not working it must be because of the logic error kidstark noticed. I.e. you are counting the read messages,
[17:37:51] kidstark: yeah size adapts to the situation
[17:37:57] kidstark: go look at ruby docs jam
[17:38:13] terrellt: Size'll use the counter cache if possible, too.
[17:38:29] jammanbo: terrellt: If so I apologies kidstark. Did not know it behaved differently on scopes.
[17:38:49] kidstark: it behaves the same on any aor collection
[17:38:51] terrellt: It doesn't. It behaves the same.
[17:39:05] kidstark: a scope is just another type of method really
[17:39:37] kidstark: you could do a class method too instead of a scope if you wanted
[17:41:09] fuzzyhorns: any opinions on enums vs state machines?
[17:41:11] superscott[8]: if i remove the pool from my database yaml, should there be any horrible side effects?
[17:41:19] fuzzyhorns: ie classy_enum vs state_machine gems?
[17:41:20] jammanbo: Last time I looked size would execute after the query which was a noob error, but I guess that must have changed when we got lazy execution eh? Good to know.
[17:41:39] tonz: hows everyone doing today?
[17:42:16] tonz: Does anyone know if actionmailer sends data securely?
[17:47:00] elaptics: tonz: email's not exactly a secure medium :)
[17:47:10] ravster: hey all, Is there a way for me to state, in an active_model_serializer, to show all attributes except for a few.
[17:47:19] ravster: so, a blacklist instead of a whitelist?
[17:47:55] lethjakman: tonz: define securely
[17:48:53] lethjakman: it doesn't post it to a BBS online if that's what you mean...it's as secure as any other email library.
[17:49:03] lethjakman: however it's not encrypted or anything likethat.
[17:49:21] whitsan: This is my routing document: https://gist.github.com/whitnelson/6596786
[17:49:32] whitsan: It works great for /channel/tags/interviews
[17:49:57] whitsan: I want to alias /channel/interviews to go to /channel/tags/interviews.
[17:50:04] whitsan: How would I do that?
[17:51:41] whitsan: (Interviews is a tag)
[17:53:01] tonz: Thanks lethjakman
[17:54:33] tonz: how necessary is encryption?
[17:54:58] tonz: the form submit is sensitive data
[17:55:50] lethjakman: tonz: I've never seen a major website use it. by encryption I mean encrypting the content in order to be decrypted later.
[17:55:52] tonz: :enable_starttls_auto => true into config.action_mailer.smtp_settings.
[17:55:57] whitsan: I'm thinking that in the scope 'channel', I could add a get 'interviews/'
[17:56:03] lethjakman: you're basically sending an email the same way it would be sent from gmail.
[17:56:20] whitsan: send it to tags#show
[17:56:50] tonz: thanks lethjakman
[17:56:51] lethjakman: ahh if you're using SMPT that's not a bad idea.
[17:56:52] whitsan: but I can't figure out how to add the parameter, so it goes to tags#show/interviews
[17:56:57] lethjakman: I'd leave that enabled
[17:57:13] tonz: Its a little over my head truthfully
[17:57:25] terrellt: lethjakman: I...don't know. Maybe something like attributes *self.attributes, def self.attributes; something_to_get_all_attributes_maybe_protected_attributes - blacklisted_attributes; end; ?
[17:57:56] lethjakman: terrellt: what?
[17:58:01] terrellt: That was for ravster!
[17:58:03] jokar: zzak: Hello
[17:58:05] terrellt: My apologies, clearly out of this morning.
[17:58:12] gchaturvedi: what is the common method of exception handling in rails code?
[17:58:17] gchaturvedi: in python..we use exceptions as code paths
[17:58:24] gchaturvedi: i rarely wee exception handling in rails controllers in code online
[17:58:41] lethjakman: whitsan: I don't remember off the top of my head, I'm pretty sure that's in the routing chapeter in guides.rubyonrails.org though.
[17:58:50] mrpoundsign: join #bundler
[17:58:51] EminenceHC: When I push to Git or use FTP I can transfer everything BUT the database.yml file. It says access denied when I try and transfer.. Anyone know why?
[17:59:01] whitsan: lethjakman: I just read it top to bottom
[17:59:21] whitsan: Here is the closest I've gotten
[17:59:44] elaptics: tonz: depends where you're sending mail to. If your app sends all mail via someone like sendgrid then you can set it up such that your app servers communicate securely with sendgrid but after that there's no guarantees
[17:59:50] DylanJ: gchaturvedi: depends. you can rescue code like you would normally in ruby and you can also rescue_from in rails
[17:59:50] whitsan: match '/channel/interviews' => 'tags#show', :defaults => { :id => 1 }
[17:59:58] lethjakman: whitsan: what I would do is this: http://guides.rubyonrails.org/routing.html#redirection
[18:00:00] whitsan: However, I don't want to look it up by ID
[18:00:16] DylanJ: i use rescue_from for catching cancan access denieds and rendering a 403
[18:00:23] gchaturvedi: DylanJ: Ok..so let's say I have to communicate with twitter's api for getting a list of tweets for my user..and twitter servers are down..
[18:00:24] DylanJ: (custom 403)
[18:00:28] whitsan: lethjakman: Good thought, but I can't redirect. Client wants to change the URL itself
[18:00:34] gchaturvedi: You would catch this in a StandardError or some specific error correct
[18:00:51] terrellt: gchaturvedi: Ideally there'd be a specific exception class it'd throw, yes.
[18:01:02] lethjakman: and change the show action to match within that controller.
[18:01:02] lethjakman: elaptics: I'm guessing that the permissions on that file aren't right.
[18:01:02] lethjakman: either on the server you're trying to override on, or the local.
[18:01:03] DylanJ: i would just begin; call twitter; rescue WhateverExceptionIsRaised; render :twitter_is_down_son; end
[18:01:06] gchaturvedi: so anything related to active record..do you catch exceptions?
[18:01:14] gchaturvedi: or do you just do if user then do this..else blah
[18:01:44] DylanJ: i dont catch AR exceptions unless i have to for whatever eason
[18:01:45] terrellt: gchaturvedi: Rails has a bit of magic with ActiveRecord::RecordNotFound - it'll display a 404.
[18:01:52] ravster: terrellt: thanks, I'll try that.
[18:01:59] elaptics: lethjakman: file?
[18:02:00] lethjakman: I mean you can just route that specific action?
[18:02:32] lethjakman: elaptics: the database.yml file.
[18:02:38] axl_: Does adding such a line precompile all files with that extension in app/assets ?: `config.assets.precompile += %w( .svg .eot .woff .ttf )`
[18:03:11] elaptics: lethjakman: do you mean EminenceHC?
[18:04:15] whitsan: lethjakman: Yup, that does seem to route to the right action. I just need to figure out how to pass in a parameter to the action (that isn't the :id)
[18:05:06] lethjakman: elaptics: yes, sorry.
[18:05:11] lethjakman: too many people I can't keep up.
[18:06:09] lethjakman: whitsan: it's in the link I sent you. the :name part
[18:06:24] lethjakman: g2g, cya guys later. good luck.
[18:06:39] whitsan: lethjakman: how did you send?
[18:07:09] lethjakman: whitsan: http://guides.rubyonrails.org/routing.html#redirection
[18:07:10] jan1337z: How can I get the real class of an ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy Object ? I want to compare
[18:07:34] terrellt: Two points to anybody who knows that off the top of their head.
[18:07:35] whitsan: lethjakman: Aha! Thanks!
[18:10:02] rhizome: axl_: what are you trying to do? fonts?
[18:10:05] EminenceHC: lethjakman: It appears it was a folder permissions problem. I never had this problem before I used git to push though. Does git set folder permissions? I thought that had to be handled on the server?
[18:10:15] axl_: rhizome: yeah
[18:11:15] rhizome: axl_: all i've needed is config.assets.paths << "#{Rails.root}/app/assets/fonts"
[18:15:17] axl_: rhizome: interesting
[18:19:20] freedrull: anyone use resque-meta? i don't really understand how you are supposed to get the meta id later when you need it? store it in a db or something?... https://github.com/lmarlow/resque-meta
[18:21:22] terrellt: freedrull: Looks that way.
[18:34:01] jessen: ok I was directed to sorcery but really I would like to override the controller in the gem devise_invitable and I cannot connect the route to the controller. Can someone give me some advice please https://gist.github.com/jessenaiman/6598664
[18:36:57] rehat: hi I'm new to Rails, is there a good tutorial for debugging rails
[18:37:22] rehat: like can I doing something like break points and stepping
[18:37:23] bricker`work: http://guides.rubyonrails.org/debugging_rails_applications.html
[18:37:34] tonz: thanks elaptics
[18:37:41] rehat: bricker`work: thanks
[18:37:43] bricker`work: rehat: also, use Pry for breakpoints
[18:37:54] bricker`work: and stepping and everything else
[18:37:59] jessen: rehat use the gem pry-rails
[18:38:44] jessen: then type binding.pry at the line you want to debug, the console will give access to all active variables, methods, etc.
[18:40:41] obelich: how are all i have a problem in autocomplete i have a field <%= f.text_field :contact_name, data: {autocomplete_source: contactos_autocompletes_path} %> in create work good but at time to edit it dont work :(
[18:41:34] jessen: I really need some help understanding why I can't override the devise controller?
[18:44:02] Trudko: guys I am trying to save speci char in db and it cant be saved (it saves as nil) not sure why I am pretty sure this worked before. http://pastie.org/8333837
[18:44:06] Trudko: c-66-31-17-134.hsd1.ma.comcast.net
[18:47:42] ivanpolchenko: testing colloquy
[18:49:56] jokar: zzak: Take care and have a nice day
[18:50:02] maloik: How would you guys store app-wide settings, such as a shop's opening hours, whether or not they're currently closed (holiday) and so on ?
[18:51:10] maloik: to be clear the settings need to be edited by the 'admins'
[18:51:54] jessen: someone on here advised me to change my devise route to this: devise_for :users, path: 'auth', controllers: { sessions: 'sessions' }
[18:52:35] AntelopeSalad: am i doing something wrong if i have half a dozen (or potentially more) helper function calls on top of each view which get yielded to the layout? most of these pages are static and i have no plans to put their contents in a db
[18:52:36] jessen: That was supposed to somehow send it to my custom controller. What and where should my custom controller be? I have it under user/devise_invitable
[18:53:16] maloik: jessen: that doesnt sound like a controller? in your case it should be called sessions controller, and probably under the root of the controller folder
[18:54:33] zzak: johnjohnson: \o/
[18:54:42] zzak: johnjohnson: mt
[18:54:51] jessen: the documentation has this as the controller declaration: class Users::InvitationsController < Devise::InvitationsController
[18:55:17] zzak: maloik: in the db?
[18:55:28] maloik: that's a controller in the Users namespace... you route shows 'sessions' is being used, not invitations
[18:55:54] maloik: zzak: but how? it wouldn't be a regular model would it ?
[18:55:54] fuzzyhorns: backfilling data in a db column, what's the best way to handle it?
[18:56:06] rehat: when I use rails generate controller should the name I provide be the singular or plural name
[18:56:39] zzak: maloik: in a settings model maybe, or on the company object if you dont want to make a new resource
[18:56:53] jessen: maloik that's because someone else told me to try that
[18:57:07] maloik: well it'd be like a web shop, so the 'company' wouldnt even have a model
[18:57:16] jessen: it used to be devise_for :users, :controllers => { :invitations => "user/invitations" }
[18:57:22] maloik: and a settings model is what I had in mind but it sounds like overkill as there'd only be one row
[18:57:46] maloik: like... there's only one shop, so only one opening hour is defined (per day but still)
[18:57:47] Woodsman: is there a way to make sure that an external link will open in a new tab instead of just changing the page you're currently on?
[18:58:39] maloik: jessen: why would you define sessions if you mean invitations :-) what you had looked good except it should probably be 'users', unless the namespace is singular
[18:58:40] terrellt: Woodsman: In the link it's target="_blank"
[18:58:41] jessen: I need to mess with the return route when a user accepts an email invitation and the edit action on the controller should allow that, but I am new to rails and have not overridden many objects in ruby. I come from (shamefully) .NET and C#
[18:58:52] terrellt: Woodsman: If you're using the link_to helper in rails just add :target => "_blank"
[18:58:58] Woodsman: thanks, terrellt. figured it'd be something simple
[19:00:13] terrellt: Fuzzyhorns: I usually like to make an importer class and a rake task that calls it.
[19:00:55] ivanpolchenko: man.. I'm trying to use acts_as_taggable_on with some sort of bootstrap tag input field… and i just can't get it to work whatssoever
[19:01:11] ivanpolchenko: i've googled all over
[19:01:16] ivanpolchenko: http://francoisdeschenes.com/2013/01/17/twitter-bootstrap-tags-made-easy isn't helping..
[19:01:22] ivanpolchenko: tag-it not working
[19:02:03] cobrama: How do I hide ids of my resources on my routes. I want to use unique name as identifiers on my routes without changing much code?
[19:02:33] terrellt: Cobrama: https://github.com/norman/friendly_id
[19:04:33] cobrama: terrellt, thanks
[19:04:38] jessen: This is what I get uninitialized constant Users::InvitationsController
[19:05:13] cobrama: I can create two path helpers with the same name and url but only that differ in the http verb they use
[19:05:24] jessen: controller is class Users::InvitationsController < Devise::InvitationsController as described in the docs
[19:05:34] jessen: route is devise_for :users, :controllers => { :invitations => "users/invitations" }
[19:06:03] jessen: oh and the controller is in controllers/users/invitation_controller.rb
[19:06:19] ivanpolchenko: this is what I want to do: http://fdeschenes.github.io/bootstrap-tag/
[19:06:25] ivanpolchenko: but i can't figure out how to get it to work
[19:06:44] ivanpolchenko: reference blog post: http://francoisdeschenes.com/2013/01/17/twitter-bootstrap-tags-made-easy
[19:07:08] cobrama: How do I create two routes with the same helper names (NAME_path) but only differ in http verb( Post vs Get)?
[19:07:17] rhizome: AntelopeSalad: might be overoptimization, depending on what they are, but generally not a problem IMO
[19:07:19] maloik: zzak: suppose something like this is the way to go still... http://pivotallabs.com/creating-strongly-typed-app-wide-user-editable-settings/
[19:07:20] cobrama: e.g. users_path
[19:07:35] foucist: jessen: shouldn't it be Users < Devise::..
[19:07:37] terrellt: cobrama: In your routes define "get" and "post"?
[19:07:55] AntelopeSalad: rhizome: they are things that would change for each page , title/meta title+description/heading text , etc.
[19:08:27] ivanpolchenko: oh i did get it to work..
[19:08:45] zzak: maloik: must be, its on a the internet :)
[19:08:57] jessen: foucist: the docs for devise_invitable are here: https://github.com/scambra/devise_invitable, and they use this exact code as an example
[19:09:04] n_blownapart: hello if I have a duplicate db migration, do I manually delete one from the project or does it involve rollback?
[19:10:31] cobrama: terrellt, I did but I get an error saying ".... You may have defined two routes with the same name using the `;as` option...."
[19:11:30] terrellt: maloik: First comment in that thread points to https://github.com/ledermann/rails-settings, which looks pretty darn slick if it works.
[19:12:18] ivanpolchenko: its giving me ActionController::UnknownFormat when I click Update.. if I edit the tags in the field
[19:12:38] maloik: terrellt: sure, although I'd need it for app-wide settings... so that wouldn't work for me
[19:13:19] terrellt: maloik: Why not? You can make an Application model.
[19:14:00] maloik: terrellt: why would I want to do that? I can just make a settings model and be done with it :)
[19:14:13] platzhirsch: Where should I write inflection updates into my Rails app? Somewhere at config/initializers?
[19:14:18] platzhirsch: or config/application.rb
[19:14:35] ryanf: new rails projects come with a file in config/initializers for you to put inflections in
[19:14:38] terrellt: maloik: I dunno. You get application profiles almost for free? *Shrug*
[19:14:42] platzhirsch: nvm, found config/initializers/inflections.rb
[19:14:52] platzhirsch: ryanf: thanks
[19:15:00] maloik: terrellt: app profiles? what do you mean by that
[19:15:45] terrellt: It's feature creep, but with something like that you're just a step away from being able to define multiple application profiles and switching between settings on the fly.
[19:17:08] maloik: terrellt: well this is a french frie place... highly doubt that'll ever happen
[19:17:18] maloik: if it does we can change it but for now thats overkill
[19:18:37] pwz2000: In my console I am getting undefined method `area_for' when trying to do a search for users with x amount of miles from a specified user. I have area_for defined in my zip model. https://gist.github.com/pwz2k/6599310 . It may be getting block from the user.rb with the within_miles
[19:18:49] n_blownapart: hi can I not use this command and include the timestamp like so?: rails d migration 20130824041034_create_tickets.rb
[19:20:29] bricker`work: If I wanted to run tests or deploy from one branch, but then switch to another branch to continue working in the meantime... is `screen` a good way to do that?
[19:20:57] Voker57: no. clone your repo instead
[19:21:06] terrellt: bricker`work: Screen/tmux just gives you side-by-side terminal sessions, it can't have two branches running at the same time in the same folder.
[19:21:11] terrellt: bricker`work: That would be intense voodoo.
[19:26:00] terrellt: Nooo github, stop being broken
[19:26:30] agent_white: Second worse thing to happen next to a 2min Google outage
[19:27:28] slash_nick: sorry guys i broke it
[19:27:35] amortimer: I see that.
[19:27:35] terrellt: I bet their error log is just getting -smashed- right now.
[19:28:15] slash_nick: ACTION holds down Ctrl+R and agrees with terrellt 
[19:29:28] amortimer: Maybe we should email github to let them know.
[19:32:52] bricker`work: 300,000 times
[19:33:35] terrellt: Come on github, cap server:restart
[19:34:13] slash_nick: Coming up on 10 minutes, this is a good one
[19:34:15] Donovan: I'm refreshing status.github.com and watching the stats plummet
[19:34:27] bricker`work: This has been the year of github outages
[19:36:35] jstew: That's why all of my repos are also on bitbucket :)
[19:36:54] jstew: Git has this wonderful feature called distributed source control :)
[19:37:31] terrellt: All my repos are on all our developer machines.
[19:37:49] terrellt: And gitlab for non-public stuff, so meh.
[19:38:01] jstew: So it doesn't really affect you either.
[19:38:12] slash_nick: yeah, i'm unaffected as well
[19:38:13] terrellt: It does, I was exploring another repo. =(
[19:38:39] Donovan: bitbucket is a good alternative. I use it for private repos.
[19:38:48] Donovan: github is, of course, the place for open-source stuff
[19:39:11] jstew: Life would suck if github and stack overflow went down simultaneously.
[19:41:00] DaniG2k: hey guys does anyone here have experience with currencies/money and rails?
[19:41:13] DaniG2k: I would like users to input a price (select currency with dropdown)
[19:41:27] DaniG2k: and have the ability to convert that to any desired currency
[19:42:34] jessen: This is infuriating. I followed the instructions for devise_invitable and I keep getting a routing error. Where would the controller be expected in this declaration devise_for :users, :controllers => { :invitations => 'users/invitations' }
[19:42:36] bricker`work: DaniG2k: https://rubygems.org/gems/money
[19:42:42] jessen: Stack overflow has also failed me
[19:43:02] bricker`work: DaniG2k: Money.new(1000, "USD").exchange_to("EUR")
[19:43:21] DaniG2k: bricker`work: can i exchange, for instance, to KRW or CNY
[19:44:49] bricker`work: DaniG2k: https://github.com/RubyMoney/money/blob/master/config/currency_iso.json
[19:44:57] bricker`work: plus https://github.com/RubyMoney/money/blob/master/config/currency_non_iso.json
[19:45:21] bricker`work: DaniG2k: KRW and CNY are both in that list
[19:45:43] DaniG2k: bricker`work: sweet
[19:45:54] jessen: also when I run rake routes I don't see the route that I changed
[19:46:22] bricker`work: DaniG2k: there's also https://github.com/RubyMoney/money-rails
[19:47:20] DaniG2k: bricker`work: yeah i was wondering which of the two i need for a rails app...probably money-rails
[19:47:36] Donovan: jessen: restart the rails server?
[19:47:39] vimetus: bricker`work: Is this gem like a just container for currencies?
[19:48:31] jessen: Donovan: no dice. But the url messes up like I rewrote the route
[19:48:31] DaniG2k: vimetus: yeah
[19:49:45] jessen: uninitialized constant Users::InvitationsController....why???
[19:50:24] jstew: Money is an awesome gem.
[19:50:47] bricker`work: DaniG2k: money-rails is just a wrapper around the money lib
[19:50:48] vimetus: Money is awesome too
[19:51:08] DaniG2k: bricker`work: sorry for my ignorance but what does the wrapper do that the money gem doens't?
[19:51:18] DaniG2k: bricker`work: is it easier to work with or something?
[19:51:34] jstew: DaniG2k: I believe that it sets up a composed_of method on your model.
[19:51:36] bricker`work: DaniG2k: https://github.com/RubyMoney/money-rails/tree/master/lib/money-rails
[19:51:41] bricker`work: lots of stuff
[19:52:04] bricker`work: adds a "monetizable" macro to your AR models
[19:53:30] pontiki: and the cash just rolls in?
[19:53:39] bricker`work: that's the idea
[19:53:44] DaniG2k: hmm if i dont see what it does i dont really understand its benefit tbh
[19:54:14] bricker`work: DaniG2k: then don't use it, just use the money lib
[19:54:32] Trudko: guys I am trying to save speci char in db and it cant be saved (it saves as nil) not sure why I am pretty sure this worked before. http://pastie.org/8333837
[19:54:35] Trudko: c-66-31-17-134.hsd1.ma.comcast.net
[19:55:38] DaniG2k: bricker`work: ok thanks
[19:55:46] DaniG2k: bricker`work: im exhausted...going to sleep now
[19:55:51] DaniG2k: take care guys
[19:56:22] jstew: Trudko: Encoding issue? What's your datbase encoding?
[19:57:38] ravster: Is there a way for a "link_to" to add additional parameters to the request? I'm trying to add a top-level param of {city: "toronto"} to my post request.
[19:57:43] thoraxe: hmm... is there a good "display flashes" snippet for rails 3?
[19:57:52] thoraxe: what i was using in rails 2 seems to throw activerecord errors
[19:58:58] thoraxe: http://pastie.org/8334044
[19:59:02] jstew: ravster: What are you posting from? A link or a form?
[19:59:15] ravster: adding ", data: {city: "toronto"}" to the end of the "link_to" line doesn't seem to be doing the trick. I don't see it in the server logs.
[19:59:44] ravster: jstew: right now I want to get it working with a link, but Ideally I'll have this working with the submit button of a form.
[20:00:37] jstew: ravster: if it's a form, a hidden field will do.
[20:01:22] boxfactory: Hey guys. Trying to figure out the asset pipeline. I believe scaffolding gave me controller1.css.scss and controller2.css.scss
[20:01:37] boxfactory: Yet, when i set some style rules in controller1.css.scss, it affects controller2.css.scss views
[20:01:42] boxfactory: what's up with that?
[20:02:02] jstew: ravster: To add additional params to the link_to, like this: link_to("Link", some_route_path(:city => "Toronto")) should work (off the top of my memory)
[20:02:15] slash_nick: boxfactory: are you including both stylesheets on the page?
[20:02:21] thoraxe: i guess in this particular instance there's not actually an error on an object
[20:02:26] thoraxe: so i've just added stuff to flash[:error]
[20:02:30] ravster: jstew: ohhh, fancy. I'll try that. Thank you.
[20:02:44] jstew: ravster: yw
[20:03:01] boxfactory: slash_nick, hm let me check
[20:03:34] boxfactory: I have <%= stylesheet_link_tag "application", :media => "all" %> in application.html.erb (base layout)
[20:03:44] boxfactory: slash_nick, so is that a yes?
[20:04:12] boxfactory: slash_nick, im not sure if that pulls in all css or just application.css, but application.css is just a compilation of all stylesheets, no?
[20:05:34] thoraxe: ahh it's ActiveModel now
[20:06:10] slash_nick: application.css has a manifest that tells rails which stylesheets to load (and they're loaded on every page)
[20:06:22] slash_nick: boxfactory: you could also use firebug to look at all the scripts on the page
[20:08:30] ravster: jstew: that works with the link, I just had to "some_route_path(@place, {city: "Toronto"})", and it started putting city=Toronto in the URLs. Thanks again. I'm going to try to get that in the submit button now.
[20:08:58] boxfactory: slash_nick, ah yeah, so its pulling in all stylesheets for every view
[20:09:43] slash_nick: boxfactory: well there ya go :) don't do that if you don't want to.
[20:19:13] kedric: Hey All, does anyone know a tool for displaying server errors/404s via a web based admin console?
[20:19:25] digital-ghost: Anyone here develop with RefineryCMS? Have a question about how to access model data through the console.
[20:19:42] V8Energy: is there a decent rails 4 book for non beginner?
[20:19:57] jstew: ravster: should be really, really easy with hidden_field_tag
[20:20:15] pontiki: V8Energy: what do you want from such a book?
[20:21:59] V8Energy: i read agile development with rails, i guess i just want to continue reading and learning while i am coding
[20:22:19] V8Energy: i just need a more advanced reading now
[20:22:24] pontiki: go for the source
[20:32:45] ivanpolchenko: i keep getting No route matches [post] "/items/new" when i click the new item button...
[20:32:51] ivanpolchenko: <%= button_to("New Item", new_item_path, class: "btn btn-primary") %>
[20:33:08] ivanpolchenko: i had it like <%= button_to("New Item", { action: "new" }, class: "btn btn-primary") %> earlier
[20:33:10] ivanpolchenko: with same result
[20:33:18] jstew: ivanpolchenko: you want link_to
[20:33:32] jstew: ivanpolchenko: button_to makes a form button
[20:33:34] ivanpolchenko: well, I'm trying to use the bootstrap button
[20:33:43] ivanpolchenko: and for that i need button_to
[20:33:49] jstew: ivanpolchenko: Yes, which is just a link with teh btn class
[20:34:16] ivanpolchenko: i don't want the link to gray out as visited.. and don't want to bother changing the style to change that..
[20:34:23] ivanpolchenko: there's gotta be an easier wa
[20:34:25] jstew: ivanpolchenko: Nope. You don't need button_to for a bootstrap button. It's just a plain old a tag with the btn class.
[20:35:24] ivanpolchenko: alright i'll try link_to … just read that scaffold.css makes it bad
[20:36:24] tubbo: ivanpolchenko: if you're using bootstrap, you shouldn't need scaffold.css. in fact, i'd remove it if i were you.
[20:36:36] tubbo: just to make sure you don't have weird conflicting CSS rules
[20:36:41] ivanpolchenko: about to do that
[20:37:23] jessen: ok so I got devise_invitable working with a custom controller in rails 3.2, but I could really use it to work in 3.0.9. Does anyone know what might have changed that would break a route between these versions?
[20:38:13] ivanpolchenko: oh much better
[20:39:40] eddrain: say I add a variable, filtered, in a questions controller
[20:40:29] eddrain: inside a method in that controller, how would I see it?
[20:41:38] ravster: I have an active_model_serializer for a "Place" model that outputs a nested association called "feature". Is there any way I can customize this so that instead of "feature" it outputs "features" (Pluralized)? I don't see anything about renaming keys in the code for active_model_serializer.
[20:45:08] jstew: ivanpolchenko: np, glad it works!
[20:46:06] ivanpolchenko: heh.. just noticed my nick here is my name..
[20:46:17] jstew: eddrain: See it where, exactly?
[20:50:30] ivanskie: thats better
[20:50:44] ivanskie: my website is empty so no need to have ppl goggle my name for no reason lol
[20:51:50] jxriddle: http://etodd.com/graphics/goggles2.jpg
[20:52:59] faramir: ravster: have you tried something like this: https://gist.github.com/anonymous/6600470?
[20:53:00] AntelopeSalad: how can i output 2 things adject to each other with content_tag? ex. http://pastie.org/8334155 , in this snippet's case the label is being ignored completely
[20:54:34] ravster: faramir: I'll try that, thanks
[20:54:38] diggitydane2: AntelopeSalad: you'll need to concat them together, like label + content_tag ....
[20:54:53] AntelopeSalad: diggitydane2: i thought so too but then it throws an error
[20:55:06] oVeRRiDe_Me: Any way to see more info about a migration that i only have the ID for? i.e. ** NO FILE **
[20:55:20] faramir: ravster: no problem! i haven't tested it, so i'd be interested in the result if you don't mind sharing :)
[20:55:27] diggitydane2: AntelopeSalad: what's the error? is label just a string?
[20:55:37] tubbo: AntelopeSalad: use a templating language like haml.
[20:55:44] AntelopeSalad: it is a string yes -- error is: syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '('
[20:55:51] tubbo: AntelopeSalad: or a partial
[20:56:48] Trudko: guys I am trying to save speci char in db and it cant be saved (it saves as nil) not sure why I am pretty sure this worked before. http://pastie.org/8333837
[20:56:51] Trudko: c-66-31-17-134.hsd1.ma.comcast.net
[20:57:41] tubbo: AntelopeSalad: https://gist.github.com/tubbo/99929c0ec1699b81241e
[20:58:24] AntelopeSalad: tubbo: you don't think a partial is overkill for that little snippet?
[20:58:58] tubbo: AntelopeSalad: i think it's overkill that you need that snippet at all. but that is how you reliably get helper methods to output multiple lines of HTML.
[20:59:30] tubbo: AntelopeSalad: the takeaway here is use partials instead of helpers. helpers are for like, 1 line pieces of markup or some other kind of cosmetic one-liner you need.
[20:59:37] AntelopeSalad: tubbo: what baffles my mind is this worked no problem: http://pastie.org/8334171
[21:00:03] AntelopeSalad: the only difference there is i have 2 content_tag calls being called after each other, rather than just outputting a string + content_tag
[21:00:06] tubbo: AntelopeSalad: it's because you group it in the content_tag :div.
[21:00:47] tubbo: AntelopeSalad: try wrapping label like `content_tag :span, label`
[21:01:06] ravster: faramir: nop, that didn't work.
[21:01:15] tubbo: AntelopeSalad: remember that rails has some extra shit here WRT html_safe
[21:01:35] tubbo: tag helper methods effectively mark their return values as html_safe, so you don't have to think about it
[21:01:36] AntelopeSalad: i was just doing that as you typed out tubbo , oddly enough it didn't work
[21:01:39] ravster: faramir: I also tried a "has_one :feature, as: :features", and while it didn't break, it did make the output super-weird.
[21:02:00] AntelopeSalad: i thought for sure it would have worked
[21:02:24] faramir: ravster: oh, there was a mistake in the gist
[21:02:32] workmad3: tubbo: you reliably get helpers to output multiple lines of HTML by using capture and concat
[21:02:44] faramir: ravster: :features should be be in the attributes
[21:02:51] tubbo: AntelopeSalad: i remember wrestling with this when i started with rails, too. the whole experience taught me that partials are just better for describing HTML
[21:02:56] tubbo: workmad3: hmm, what's capture?
[21:03:05] faramir: ravster: you may have already tried that, but if not, give it a shot
[21:03:31] workmad3: AntelopeSalad: try this: http://pastie.org/8334179
[21:03:37] AntelopeSalad: tubbo: so you would move both examples over as a partial?
[21:03:41] ravster: faramir: undefined local variable or method `feature' for #<PlaceSerializer:0x1d7398ee>
[21:03:46] boxfactory: Question about css/asset pipeline: I have a {color:#dd4814;} written in application.css.scss and controller1.css.scss . This successfully turns the color of links orange. However, if i take it out of controller1.css.scss, it seems to be overwritten with something
[21:03:52] tubbo: AntelopeSalad: i would do what workmad3 says :D
[21:04:03] boxfactory: how can i figure out whats overwriting it?
[21:04:06] workmad3: tubbo: it creates a new safe buffer for the block and returns it after executing the block
[21:04:13] workmad3: tubbo: and concat appends to the current buffer
[21:04:14] tubbo: ah, very good
[21:04:18] AntelopeSalad: workmad3: the second example was working as intended/described, it was the first one that was a prob
[21:04:18] boxfactory: when i use chrome devtools, i get linked to a minified css script...
[21:04:23] AntelopeSalad: it must be something with :div specifically?
[21:04:29] tubbo: that's a great way of notating that, totally beats ("" + "").html_safe :D
[21:05:11] workmad3: AntelopeSalad: I missed the first pase
[21:05:23] workmad3: AntelopeSalad: any chance of a relink, avoid me looking up chan logs? :)
[21:05:42] workmad3: tubbo: yup ;)
[21:05:45] ravster: faramir: if I do that, and put in a "has_one :feature", then it has a :features hash, but also a :feature hash, and the JSON is declared as invalid. Weird. I'll fiddle with this a bit more and let you know if I make progress. Thanks.
[21:06:00] AntelopeSalad: workmad3: http://pastie.org/8334155
[21:06:17] workmad3: tubbo: what really gets me is that capture & concat have been around since at least rails 2, if not before (I learned about them from the original rails way book, which was for rails 2)
[21:06:25] workmad3: tubbo: and yet almost no one ever remembers to use them :)
[21:06:45] tubbo: workmad3: i never read any of the books, but yeah it's not really talked about too much
[21:07:03] tubbo: workmad3: i think rails 2 was the start of "".html_safe and raw()
[21:07:17] tubbo: so it would make sense that capture/concat was also introduced around that time as a time-saver
[21:07:23] workmad3: tubbo: nope, that was rails 3
[21:07:32] faramir: ravster: one more suggestion. it looks like 'object' is the actual model, so try this: http://pastie.org/8334188#6
[21:07:42] tubbo: blast from the paaaaaaaaaaaaaaaast :D
[21:08:24] AntelopeSalad: i tried applying what he did to my 1st example but it still ignores the label hmm
[21:08:57] workmad3: d'oh, accidentally closed the wrong window
[21:09:02] workmad3: AntelopeSalad: try this: http://pastie.org/8334192
[21:09:53] AntelopeSalad: workmad3: that's why i tried a few min ago, but now it ignores the description
[21:10:44] AntelopeSalad: check this out too, for the inner most li i accidently spelled concat wrong and it didn't throw an error or output anything different
[21:11:40] workmad3: AntelopeSalad: ah damn, the block is going to the concat, not to the content_tag
[21:13:01] AntelopeSalad: i could always not use a helper here but there's about 40 of those lis scattered around the site
[21:13:05] workmad3: AntelopeSalad: http://pastie.org/8334209
[21:13:42] workmad3: AntelopeSalad: other option is to remember that you can do 'd = content_tag ...; concat d' ;)
[21:14:01] AntelopeSalad: workmad3: ah nice, that works
[21:14:37] AntelopeSalad: i would have never thought to put it on 1 line
[21:15:54] workmad3: AntelopeSalad: tbh, my general principle is that if my content_tag helpers look too ugly on one line, they're worthy of a partial instead :)
[21:16:12] workmad3: AntelopeSalad: I don't tend to go much for the block forms of content_tag because of that
[21:16:38] ravster: faramir: Got it. I needed to do a "has_one :feature, key: :features"
[21:16:41] AntelopeSalad: ok thanks, that seems like a reasonable rule of thumb
[21:16:42] ravster: And thats it.
[21:17:02] AntelopeSalad: i might be getting a bit helper happy, i probably use helpers 10x more than using partials
[21:17:15] pipework: Sometimes I use helpers that use partials.
[21:17:21] pipework: And partials that use helpers.
[21:17:26] workmad3: pipework: me too :)
[21:17:33] faramir: ravster: great! thanks for reporting back
[21:17:36] pipework: Sometimes, I even use helpers that use partials that use helpers. It goes deeper.
[21:17:37] AntelopeSalad: i have a helper that is using a partial atm
[21:17:48] workmad3: pipework: I tend to use helpers that use partials when I have to wrap a bit of logic around which partial to use
[21:18:19] pipework: workmad3: I use helpers whenever I need to use partials from inside another view of some kind, in addition to other situations.
[21:18:37] ravster: faramir: thanks for the suggestions. it set me on the right track.
[21:18:55] AntelopeSalad: since we're on the topic of helpers tho, mind taking a quick peek at this? it feels ugly but i'm not sure how else to do it http://pastie.org/8334219
[21:19:08] terrellt: workmad3: I've been loving putting my content_tags in decorator functions that yield.
[21:19:35] pipework: terrellt: So you write your markup wholly in ruby, rather than html?
[21:19:49] pipework: Or whatever markup language you enjoy.
[21:20:22] terrellt: pipework: For things like div tags that need a lot of binding for javascript, yes. So my view will have something like <%= @object.span do %> HTML <% end %>
[21:20:43] pipework: terrellt: Hm.
[21:20:50] workmad3: AntelopeSalad: your icon_tag can be replaced with 'icon_tag = tag(:i, :class => "icon-#{icon_name} icon-large")' rather than that ugly inline html
[21:21:07] tubbo: pipework: markaby! #throwbacktuesday
[21:21:14] pipework: tubbo: lul.
[21:21:49] tubbo: AntelopeSalad: dude. just use partials.
[21:21:57] workmad3: ^^ that too
[21:22:00] tubbo: AntelopeSalad: you're seriously wasting time solving problems that don't matter right now. :P
[21:22:06] tubbo: sorry to be so blunt but there you go.
[21:22:28] workmad3: AntelopeSalad: and there's a block form of link_to that lets you avoid the uglyness of 'link_to "#{html}#{text}".html_safe'
[21:22:55] terrellt: pipework: https://gist.github.com/terrellt/5a0a702ebc414ff1de42 This has some work to do, but the decorators look like that.
[21:23:10] pipework: Ah that draper.
[21:23:48] AntelopeSalad: i thought the whole 'set something to a value or ""' could have been avoided, that was the ugly part to me
[21:24:54] Woodsman: I've been developing a rails app using a virtual machine. For some reason, using 'target: '_blank" ' in my link_to statements allows links to open as new tabs on the virtual machine, but that same code doesn't work when viewing it in windows at the URL where it's hosted. Anyone have any ideas as to why that might be?
[21:25:28] pipework: Woodsman: Does the rendered html on your windows host appear to be what you'd expect it to?
[21:25:58] Woodsman: pipework: yes, it does
[21:26:12] pipework: Woodsman: Does your browser suck?
[21:26:36] Woodsman: pipework: haha, it's chrome, so... i don't think so?
[21:26:55] terrellt: That's a bad example, since it's just outputting a tag. https://gist.github.com/terrellt/df669baa88481a350090 That's a little better - div_tag is the piece that makes my life easier.
[21:27:13] Woodsman: pipework: and i guess it's worth noting the one on my virtual machine is firefox. however, firefox messes it up on my windows machine too
[21:27:41] pipework: Woodsman: What does it do when you click the link?
[21:28:08] foucist: do you guys ever store values & ranges in string in the database like "1,8-11,15" or would you go ahead and separate that out into a separate model with has_many etc ?
[21:28:13] Woodsman: pipework: i'd just like it to open in a new tab, and right now it redirects the current tab to the new site.
[21:28:30] olivier_bK: i have a path like that /home/zyriuse/Document/scripts and in script i would want to execute one script who need to go to /home/zyriuse/Document/toto
[21:28:34] pipework: foucist: It'd probably be simplest to just store it in the database in the same table.
[21:28:43] olivier_bK: do you know how i can do that ?
[21:28:50] workmad3: AntelopeSalad: you could try using this as the helper, I guess: http://pastie.org/8334241
[21:28:55] foucist: pipework: the string/ranges thing would be in the same table
[21:29:30] pipework: I don't understand.
[21:30:29] foucist: i.e. a given product has a bunch of occasions it's meant for, so store as "1,6-9,11" in db, or actually make occasion model/table
[21:30:37] pontiki: foucist: it depends entirely on how and where that information will be used
[21:30:52] foucist: it'll be fairly static, just imported from another source
[21:30:54] AntelopeSalad: workmad3: you prefer setting nil as a default and using .present?
[21:31:03] pontiki: if those are ids of something else, i'd probably not store them in a string
[21:31:08] workmad3: AntelopeSalad: I prefer 'if' to 'unless'
[21:31:20] toretore: i prefer when, not if
[21:31:25] pontiki: as that means extra mapping is required to make sure the string changes if the id's ever change
[21:31:29] workmad3: AntelopeSalad: and '.present?' will be false for nil, empty strings, empty arrays, etc
[21:31:32] terrellt: foucist: If a product has many occasions, then make a table (unless you can get that info from an API). It'll save you time.
[21:32:03] workmad3: AntelopeSalad: and yes, I prefer to use 'nil' for a default when the behaviour for not passing it is 'don't use this'
[21:32:16] toretore: foucist: it depends on how much of a "thing" the occasion is, whether it's a domain object
[21:32:17] foucist: pontiki: nah, i'll have a constant for Occasions = ["Birthday", "Anniversary", ..]
[21:32:27] foucist: toretore: yeah it'll just be a constant
[21:32:36] pontiki: then a string is fine
[21:32:47] foucist: so the values would be the index values for the constant
[21:32:54] workmad3: AntelopeSalad: it also means you don't create a nice new, empty string for every invocation ;)
[21:33:13] jrobeson: so.. i need to guarantee that only 8 valid hex numbers are submitted and thus need to use a regex, should i keep them both in the same validation? or split them up?
[21:33:18] foucist: toretore: not sure if it's overkill to make the table/model
[21:33:24] foucist: toretore: there's 5 of these things
[21:33:27] AntelopeSalad: workmad3: your implementation is quite a bit different, i will need a bit to figure out what's happening
[21:33:35] AntelopeSalad: but the output is broken atm
[21:33:51] workmad3: AntelopeSalad: I don't promise perfect translations :P
[21:34:15] faramir: olivier_bK: File.expand_path("../../toto", __FILE__)
[21:34:59] AntelopeSalad: workmad3: seems like the self closing <i> tag might be the problem, since it might need to be closed as </i> to work
[21:35:23] workmad3: AntelopeSalad: ah, couldn't remember if 'tag' always created a self-closing tag or not
[21:35:38] workmad3: AntelopeSalad: use content_tag(:i, "", class: ...) instead then
[21:35:50] AntelopeSalad: yeah i just confirmed that is the problem, i tried a self closing tag in my first example and the same thing broke
[21:36:56] olivier_bK: faramir, thanks
[21:36:58] AntelopeSalad: workmad3: yep that worked, cool thanks
[21:47:54] rhizome: nil also works
[21:48:25] terrellt: Nil's multiple purposes give me the heebie jeebies.
[21:49:52] brownies: there is only one nil
[21:49:55] faramir: jrobeson: i'd separate them so you get more informative errors. like so: validates :foo, length: { is: 8 }, format { with: /\A[0-9a-fA-F]*\z/ }
[21:52:37] agent_white: brownies: There is 'no' nil? :)
[21:53:25] Spami: in rails is there a way such a thing like a before_commit but only for on attribute like: before_commit_attribute
[21:54:01] rhizome: what do you mean?
[21:54:43] rhizome: terrellt: maybe, but for content_tag it satisfies Demeter :)
[21:55:51] rhizome: it also uses nil as the default arg: def content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
[22:00:54] olivier_bK: i have a stupide question
[22:01:02] olivier_bK: def initialize(path)
[22:01:06] crunch-choco: anybody coding in arch here?
[22:01:19] olivier_bK: how i can get (path) in variable ?
[22:01:27] pipework: 'coding in arch' doesn't make sense to me. Do you mean using the Archlinux distro for development?
[22:01:37] terrellt: olivier_bK: It's in a variable. Path.
[22:01:51] pipework: olivier_bK: You should probably brush up on your ruby basics while you're at it.
[22:01:55] crunch-choco: pipework: oops, yes it's what i meant
[22:02:17] terrellt: crunch-choco: What's the question?
[22:03:59] crunch-choco: i'm beginning in rails, and i tried the scaffold thing that shows me "Show" "Edit" and "Destroy", but with arch when i click on "Destroy" the javascript does not pop up
[22:04:31] crunch-choco: i have disable noscript, but i still don't know where the problem comes from
[22:06:21] tubbo: crunch-choco: check your browser's JS console
[22:06:23] tubbo: for errors
[22:06:38] tubbo: crunch-choco: also check your log for any errors.
[22:07:03] crunch-choco: i'm using firefox, how do i check the browser console?
[22:07:15] Spami: rhizome, I mean something like a an after_save and after_commit, and checks only one attribute to update another table based on the value of this attribute
[22:08:29] faramir: crunch-choco: ctrl+shift+k
[22:08:51] crunch-choco: faramir: thank you :d
[22:10:03] terrellt: What do you guys usually do about Capistrano stuff in your open sourced projects? There's no private information in there except deploy paths, but it seems kind of extraneous and more information than I -have- to give out I guess.
[22:11:26] crunch-choco: tubbo: hm i don't have errors, everything is "Not Modified"
[22:12:14] crunch-choco: tubbo: it's as if @xxx.destroy did not work
[22:12:39] crunch-choco: i'm automatically redirected to the show page
[22:12:41] tubbo: crunch-choco: but the DELETE action should have been called, at least. did you get a DELETE call?
[22:13:28] crunch-choco: tubbo: i think so, it worked well when i was on debian
[22:13:42] freedrull: in mongoid, do you still need to create foreign keys for has_many relationships? :\
[22:15:55] thoraxe: hmm... when I "bundle exec rspec" it doesn't seem to run view specs by default?
[22:17:00] crunch-choco: i just tried it on chromium, same issue
[22:17:10] pipework: freedrull: Not you.
[22:19:25] thoraxe: pipework: so what is run by deafult when specifying no options?
[22:19:28] thoraxe: pipework: just models?
[22:20:19] pipework: thoraxe: specifically, view specs aren't run by default, I believe.
[22:20:54] thoraxe: i guess 2 questions : is there a way to run all specs and is there a way to print successes?
[22:26:53] crunch-choco: it's strange idk why it does not work sprockets%2Ff7cbd26ba1d28d48de824f0e94586655
[22:29:04] superscott[8]: is there a way from rails console to look at all of the currently open active record connections?
[22:32:14] rehat: how do I use the rails g controller so that the controller is created inside a folder?
[22:32:33] Salve: superscott[8]: ls with Pry works really well
[22:33:28] pipework: rehat: what have you tried?
[22:34:30] Radar: Good morning everybody.
[22:34:41] rehat: pipework: nothing yet lol just not sure how I would define that. So if I have an Admin folder inside my controllers would I do rails g controller Admin/ControllerName?
[22:35:00] thoraxe: if you have a really basic model, is there really much to do in the way of testing?
[22:35:16] superscott[8]: Salve: ls just shows me method names?
[22:35:25] pipework: rehat: I'd give it the good ol' college try.
[22:35:32] pipework: thoraxe: What's 'really basic' entail?
[22:36:32] rehat: pipework: lol thanks that works
[22:36:35] pipework: You wouldn't want to only test things in seclusion. Often enough they're just collaborators in a system, so yes.
[22:36:43] pipework: rehat: Cheers.
[22:36:51] thoraxe: pipework: http://pastie.org/8334405
[22:38:17] pipework: thoraxe: I'd probably not unit test that class, but I'd test the collaboration and that it works iin the system.
[22:39:00] thoraxe: pipework: when you say test the collaboration you mean test the relationships? and what do you mean by "works int he system"
[22:39:06] thoraxe: i'm porting an old app that had 0 tests
[22:39:19] linusoleander: I'm trying to do something like this: https://gist.github.com/oleander/9c9ded8544ef344c2292
[22:39:20] linusoleander: But I*m getting this error: undefined method `before_save' for A::AA:Module
[22:39:20] pipework: thoraxe: I don't test relationships from activerecord.
[22:39:31] rehat: pipework: ok I have seen different controller headers 'module Admin class User < ApplicationController' and 'class Admin::User < ApplicationController' is there a difference
[22:39:36] linusoleander: How would I add a before_save call to B from A?
[22:39:38] thoraxe: pipework: so i guess i'm not sure what to test here? nothing?
[22:39:46] pipework: rehat: admin/user
[22:39:57] pipework: thoraxe: I don't know what your system does with links.
[22:40:09] thoraxe: pipework: basically there's just a page that displays links oprganized by category
[22:40:49] pipework: thoraxe: So I'd probably write a request spec.
[22:41:07] thoraxe: pipework: ummm
[22:41:38] pipework: Umm isn't a meaningful expression.
[22:41:48] pipework: Just like "?" isn't a meaningful expression.
[22:42:02] rehat: terrellt: ok thanks
[22:42:12] thoraxe: ok i'm seeing the doc on request specs (https://www.relishapp.com/rspec/rspec-rails/docs/request-specs/request-spec) but i'm not really sure what to do with it
[22:42:21] pipework: rehat: You can, however, make it generate a namespaced controller.
[22:42:30] pipework: thoraxe: think for a while. Let it sink in. Give it a try.
[22:42:32] thoraxe: so i am guessing i should create a category and a couple of links and then make sure it's displayed correctly?
[22:42:36] pipework: Make some drinks.
[22:42:39] pipework: Drink those drinks.
[22:42:44] pipework: I'm headed home.
[22:46:04] ner0x: https://gist.github.com/fswitalski/6601724 Error that I have no idea where it's coming from.
[22:46:35] ner0x: I think it has something to do with the naming convention in my routes.
[22:47:03] terrellt: https://gist.github.com/terrellt/82444693c22c2566564e Seem reasonable to put something like that in a public repo?
[22:47:06] ner0x: rake route added to gist.
[22:49:07] parndt: Good morning Radar
[22:52:45] rburton-: Is there a cleaner way to do this https://gist.github.com/rburton/6601783
[22:53:09] s2013_: i am having trouble getting fog to work with sitemap_generator
[22:53:39] s2013_: in environment.rb i added storage = Fog::storage.new({...})
[22:53:42] s2013_: is that the way to do it?
[22:56:13] Radar: rehat: yes
[22:56:16] Radar: rburton-: ^
[22:57:09] Radar: rburton-: yes
[22:57:10] Radar: https://gist.github.com/radar/6601817
[22:57:42] rburton-: Ah doh! ;) I forget that I could script stuff there
[22:58:28] rburton-: Thanks also
[22:58:30] Radar: It's just Ruby.
[22:58:45] rburton-: Totally, sometimes you treat certain files a certain way mentall
[22:59:03] elaptics: ner0x: add your routes.rb to the gist
[22:59:30] ner0x: elaptics: I figured it out. respond_with sends a url not an object.
[22:59:34] s2013_: how do i get the s3 url to my s3 bucket?
[22:59:46] ner0x: elaptics: Thought of new things to google and figured it out myself. How PROUD ARE YOU?!
[22:59:59] elaptics: ner0x: congrats! :)
[23:01:20] ner0x: elaptics: https://gist.github.com/6601875 See the create? Is there a way to not have to write all that every time?
[23:03:37] elaptics: ner0x: iirc this should do it https://gist.github.com/andyh/6601891
[23:04:34] elaptics: ner0x: in fact you should just be able to do respond_with Trade.create(safe_params)
[23:05:19] terrellt: You can indeed.
[23:05:50] elaptics: ner0x: create would return a trade object and the responder should return json if it was a json request with the appropriate status set, etc
[23:06:47] terrellt: Does create throw an exception? That might break stuff.
[23:07:06] elaptics: terrellt: create! does
[23:07:37] ner0x: elaptics: respond_with errors out looking for trades_url
[23:07:43] terrellt: I actually did that refactor today, wonder if I can replace .new then .save with this..
[23:07:59] elaptics: terrellt: should be able to
[23:08:09] elaptics: ner0x: gist your code again
[23:08:23] terrellt: ner0x: respond_with(Trade.create(safe_params), :location => some_other_path)
[23:08:34] ner0x: Give me a moment.
[23:09:01] terrellt: Ah, I can't, using a service object. I could probably implement create...
[23:10:18] ner0x: elaptics: https://gist.github.com/fswitalski/6601960
[23:10:46] terrellt: I actually learned about custom responders today so I could do this: https://gist.github.com/terrellt/86b7d147cd16b92ef038
[23:12:15] ner0x: terrellt: Can you gist the code you apply that Responder?
[23:12:33] ner0x: elaptics: I'm almost positive it's because I don't have a show action.
[23:12:53] terrellt: ner0x: https://gist.github.com/terrellt/86b7d147cd16b92ef038
[23:13:04] terrellt: ner0x: And yes, it is, but if you give a location to something other than a show action it should work fine.
[23:13:08] elaptics: ner0x: I'm assuming you don't have a show route defined in your routes
[23:13:22] ner0x: elaptics: Yeah, didn't need one.
[23:14:49] elaptics: ner0x: how are you doing that request that's being logged at the moment?
[23:15:52] ner0x: elaptics: angularjs
[23:16:07] ner0x: elaptics: using restangular
[23:16:12] |PiP|_: I'm porting over an old Rails 2.3 app that doesn't use RESTful routing (it uses the very old wildcard routing that matches :controller/:action/:id). It includes an '/admin/' controller namespace with a bunch of controllers for admin functionality. How can I get rails to route to the non-restful admin namespaced controllers?
[23:16:22] willbrad1ey: any ideas why sqlite would lock for hours with "cannot start a transaction within a transaction: begin transaction" -- gotta restart the server in order to clear the error?
[23:16:47] terrellt: |PiP|_: Check the Rails Routing guide - you're probably looking for namespaces.
[23:18:03] elaptics: ner0x: what do you want the location to be? the index action?
[23:18:24] |PiP|_: terrellt: this is my current code: http://pastie.org/8334478
[23:18:32] ner0x: elaptics: I want it to be nil... which worked.
[23:18:34] ner0x: elaptics: Odd. :)
[23:18:41] |PiP|_: but i don't get how to match wildcards in routes.rb
[23:18:47] |PiP|_: for namespaces
[23:18:50] elaptics: ner0x: you can either override the location as terrellt suggested or you could use https://github.com/plataformatec/responders and use the collection responder
[23:19:17] ner0x: elaptics: setting location: nil worked.
[23:19:31] elaptics: ner0x: well if you generally want it nil you could do your own custom responder. Look at the collection responder in that plataformatec gem to see how that changes it from show to index
[23:22:25] ner0x: elaptics: I do but how would I set that in a custom responder?
[23:23:26] terrellt: ner0x: Just define a subclass of ActionController::Responder that overrides navigation_location with nil.
[23:23:42] ner0x: terrellt: I guess I just needed to know the def to override. :)
[23:23:48] elaptics: ner0x: https://github.com/plataformatec/responders/blob/master/lib/responders/collection_responder.rb
[23:24:03] terrellt: elaptics: You stole that right out of my clipboard.
[23:24:11] ner0x: elaptics: That'll work.
[23:24:23] elaptics: terrellt: you typed what I was going to type after pasting that link :)
[23:24:36] terrellt: elaptics: Tied.
[23:27:22] ner0x: terrellt: elaptics: If there was a karma system you'd get a +1
[23:27:47] terrellt: I'd be much more helpful for karma.
[23:27:49] terrellt: Which is a little sad.
[23:28:39] brownies: we're fresh out of karma, but i can offer you imaginary, meaningless internet points.
[23:29:37] terrellt: Oh man, I need me some imaginary meaningless internet points.
[23:29:40] terrellt: Bonus if they're made of pixels.
[23:35:31] epochwolf: ACTION only trades in warm fuzzies
[23:38:29] boxfactory: if my class has an attribute declared by attr_accessible called, say, :attr, how can i call self.attr if i have the symbol?
[23:38:53] boxfactory: is there a method such as get_attribute(symbol) ?
[23:40:12] terrellt: boxfactory: object.send(:symbol), object.read_attribute(:symbol), object[:symbol] - last way's preferred I do believe.
[23:41:12] eph3meral: are there any potential XSS vectors or would it be particularly problematic to output the user's latitude and longitude (as reported by their browser and stored in a cookie) in hidden HTML on the page? could would this pose either a security or privacy concern?
[23:41:28] boxfactory: terrellt, thanks, ill give it a try :)
[23:42:34] Radar: eph3meral: That really depends on your code. Are you putting in XSS vectors?
[23:42:47] eph3meral: hah, well I sure hope not
[23:45:45] yekta: Hello, I've got a class named "Class" representing a class a student might take, but when I deploy I'm getting an error of `superclass mismatch for class Class`, is `Class` not a valid model name?
[23:46:16] elaptics: yekta: class is special you'll have to call it something else
[23:46:35] terrellt: Or namespace it.
[23:46:39] yekta: Here's the error: https://gist.github.com/dwickwire/fae7642390f9e26f1fa7
[23:46:49] yekta: elaptics: :( ok
[23:47:02] optobear: yekta: yeah, it's not special as such, it's just already a class in the root namespace
[23:47:18] terrellt: I'm surprised rails doesn't create a default namespace for everything to sit in.
[23:47:26] optobear: yekta: and using it as a class name is dangerous - try and avoid it
[23:47:42] yekta: it definitely felt awkward, typing it out
[23:50:06] elaptics: yekta: optobear is correct, to be more specific it's because you're effectively trying to redefine the existing class Class and make it inherit from the active record base class
[23:51:21] elaptics: safest is to always make sure you don't name your classes anything that already existing in core ruby or it's standard library
[23:54:57] melder: hey, one of my models is not being lazy-loaded in development mode. what may be the cause of this?
[23:55:09] Radar: yekta: Classroom
[23:55:14] dioms: Hey guys, I have redactor a wysiwyg, and I have it set up so that any attachments are uploaded to s3 and a link is placed in the content. However, I want to be able to associate that attachment to the model. I have access to the js callback that runs when the file is uploaded successfully. I was thinking I would add a hidden field with the s3 url and pass it in as a hidden param, is this the easiest way?
[23:55:23] Radar: ACTION adds this to rails-reserved-words repo
[23:56:55] Radar: Added: http://radar.github.io/rails-reserved-words/