opus

Activity Graph

Page 1 of 1

2017-03-29

[09:59:52] opus: has joined #ruby
[09:59:53] opus: has joined #RubyOnRails
[10:18:35] opus: Quit: Textual IRC Client: www.textualapp.com

2016-07-03

[02:03:51] opus: has joined #RubyOnRails
[02:03:51] opus: has joined #ruby

2014-07-28

[08:09:42] opus: With associations, if I have something like an account has_many reservations. I can call acct.reservations.build and it autopopulates the "account_id" in the reservation object. Is there a way I can tap into this functionality for custom methods I create?
[08:10:09] opus: Need clarification rvanlieshout?
[08:10:23] opus: Let me write a short gist then, giving a clear example.
[08:18:17] opus: rvanlieshout: https://gist.github.com/tmeusburger/5033dc19bd8888258931
[08:18:40] opus: I can get around it by just calling Reservation.new() -> then update methods aftewords. However I wanted to understand the magic that's occuring.
[08:20:08] opus: Sweet, I didn't know about the method to look up source location.
[08:20:14] opus: Very useful, and will save me lots of digging.
[08:20:20] opus: Thanks rvanlieshout
[08:23:09] opus: Well, at least to me it's not straight forward =p
[08:23:40] opus: The logic in the fuction is simple but it looks like the logic is in the calling class for it.
[08:23:46] opus: def build(attributes = {}, &block)
[08:23:46] opus: That's the code (3 lines so not gisting it)
[08:23:47] opus: @association.build(attributes, &block)
[08:26:17] opus: rvanlieshout: @association is nil, shouldn't it be though, since the function is a class level function (self.my_method)
[08:27:06] opus: Right, which I presume happens in the calling function. Not sure where that is so just debugging through the code to get an idea
[08:27:54] opus: If the code has the &block function passing, how can I view the contents of the block?
[08:28:04] opus: looks like that is where the magic is

2014-07-19

[01:53:24] opus: Quick ActiveRecord Query question! =)
[01:54:19] opus: If I have an Item, that has promotions. A promotion has a field of 'membership_level_id'. ... let me just gist this..
[02:00:08] opus: https://gist.github.com/tmeusburger/d4165958f42b62056d2b
[02:00:08] opus: If anyone is good with active record or SQL help would be appreciated
[02:18:42] opus: Oh, I agree.
[02:19:14] opus: The design is def not what I would call optimal.
[02:19:29] opus: Any help would be appreciated.
[02:23:27] opus: https://gist.github.com/tmeusburger/d4165958f42b62056d2b
[02:23:42] opus: andll: It's a system that was already designed and I'm trying to get this one case functioning.
[02:23:49] opus: Though granted I'd be open to info on how to alter it.
[02:29:12] opus: Fair enough... The problem is the original design has essentially a table with like 3-4 foreign keys.
[02:29:25] opus: So much data duplication.

2014-07-03

[00:00:17] opus: eager_load is only true for production and not dev. Would this cause that problem?
[00:01:56] opus: I'll have to, that did resolve the issue.
[00:02:05] opus: now I have to see what negative effect it may bring =p
[00:02:37] opus: bricker`work: If you're still around setting config.eager_load = false in rails solved this problem. Looking into exactly what eager_load is doing that would cause this to occur now.
[00:07:32] opus: Just checked the documentation and the code, doesn't explain why it changes the namespace of Geokit from Geokit:: to just :: though.
[00:08:06] opus: Wonder if it's an error with the GeoKit gem or if that is some hidden 'functionality' of eager_load, mubi
[00:11:58] opus: Pretty sure it's the gem at this point, because other gem's are not having their namespace changed with eager_loading. Checking that now bricker`work
[00:14:45] opus: So, in that case, polygon is still set to the string something, however I don't get the superclass mismatch error because both objects in that case point to the same superclass "object"
[01:12:36] opus: Anyone here really understand rails eager loading and gem creation?
[01:12:47] opus: Got a hard problem I'm trying to debug and hit a wall.
[01:17:55] opus: febuiles: Asked in both places to make sure since I wasn't sure where to direct the Gem question itself. It appears to be more Gem related than rails. I've been unable to replicate it on any other Gem.
[01:18:18] opus: Basically, a Gem's namespaced modules are getting injected into the root namespace
[01:19:27] opus: Anyone here really understand rails eager loading and gem creation? If so I have a hard problem I'm trying to debug and have hit a wall. In short, a gem's namespaced modules are getting injected into the root namespace of the project when eager_loading is enabled.
[01:20:17] opus: Here is some irb code demonstrating the issue. https://github.com/geokit/geokit/issues/144
[01:20:21] opus: well, irb output...
[01:21:15] opus: Yeah... been a fun week for both of us then =p
[01:21:50] opus: Seriously though, this one has really been getting under my skin. I've already locally solved my initial problem by namespacing my own Polygon class (which I don't want to do...) because I was unable to track down exactly how this is happening.
[01:22:28] opus: I wasn't able to replicate this in other gems and I couldn't see anything wrong with the gemspec or geokit code that would cause this.
[01:22:35] opus: Yes, it's a result of eager_loading not dev/prod.
[01:22:41] opus: If you set eager_loading in dev mode to true it still occurs.
[01:24:15] opus: Also, it normally doesn't present itself. You have to have a project that has a class that conflicts with Geokit on application instantiation, via eager loading.
[01:24:44] opus: The resulting error in that case is: superclass mismatch for class Polygon (TypeError)
[01:25:14] opus: I'll create a local app that should replicate a simple scenario
[01:27:38] opus: what version of geokit are you using?
[01:29:00] opus: Do you have eager_loading enabled in dev?
[01:32:01] opus: 1.8.5, but I tried it on 1.8.4 and still had the problem
[01:34:22] opus: Oh well, this makes me both happy and sad at the same time.
[01:34:33] opus: Creating a new application doesn't demonstrate the eager loading problem.
[01:38:07] opus: febuiles: Right now I'm using geokit-rails and geokit. I added both to the project. I'll check for geokit's existence else where as well.
[01:43:49] opus: febuiles: that you for your help man. I just figured it out. There was an errant include Geokit randomly in the project added there by a non ruby dev. When I searched for it earlier I typed ack 'include geokit' instead of 'include Geokit' and as a result missed it.
[01:44:02] opus: So much time wasted on that today. Thank you so MUCH =)
[01:44:15] opus: I should have just tried to create a demo project earlier
[01:45:01] opus: Sometimes you just need to talk it through with someone!
[07:42:06] opus: waynr: are you using a syntax validator?
[07:43:17] opus: nvm... I see you posted your list of plugins.

2014-07-02

[23:35:53] opus: https://gist.github.com/tmeusburger/070df9fd81fed2793b8e
[23:35:53] opus: If someone could provide some simple ruby help for me related to modules and scoping =)
[23:36:42] opus: Basically there are two Polygon classes, one is placed under a Module the other is not. On runtime it throws a superclass mismatch error. Taking the second class and putting it under a module as well resolves the issue. I would love to be explained why this happens though.
[23:36:49] opus: love if it was explained*
[23:37:08] opus: As I understood it they shouldn't clash because one was placed under the module...
[23:38:28] opus: If anyone could assist me with a rails Module scoping issue when in production I would really appreciate it.
[23:38:29] opus: https://gist.github.com/tmeusburger/070df9fd81fed2793b8e
[23:38:59] opus: It throws a superclass mismatch error, but only in Production and not in local dev. I understand there are two classes named the same but thought the module would prevent any name collisions.
[23:40:21] opus: That gets more into the realm of rails. I reference the Polygon class in two other modules (Origin / Destination) as a has_one and belongs_to relationship.
[23:40:32] opus: also in the seeds.rb file
[23:40:50] opus: Those are the only references and when I call them it's always Polygon, or GeoKit::Polygon.
[23:41:16] opus: bricker`work: also, thanks for the help.
[23:41:39] opus: Also, it only clashes in production. When loaded in dev mode there are no issues.
[23:43:24] opus: here you go bricker`work: https://gist.github.com/tmeusburger/1b5c62e7ed12f306ed2e
[23:44:06] opus: When I run locally, irb: Polygon points to the right class and GeoKit::Polygon points to the correct class as well.
[23:44:32] opus: I'll remove that active record class and see if there is a Polygon, one sec.
[23:45:11] opus: irb(main):001:0> Polygon
[23:45:12] opus: irb(main):002:0>
[23:45:12] opus: from /Users/x/.rbenv/versions/2.1.2/bin/irb:11:in `<main>'
[23:45:12] opus: from (irb):1
[23:45:12] opus: NameError: uninitialized constant Polygon
[23:45:23] opus: When I remove my local "Polygon" file.
[23:47:08] opus: In production it references the GeoKit::Polygon class
[23:47:20] opus: Any idea why production would change that?
[23:47:30] opus: irb(main):002:0>
[23:47:30] opus: => Geokit::Polygon
[23:47:30] opus: irb(main):001:0> Polygon
[23:47:30] opus: Loading production environment (Rails 4.1.2)
[23:48:29] opus: mubi: Yeah I can place it in another module and that resolves the issue. I was just trying to understand why it was happening like that. The interesting thing is in the production environment GeoKit::Polygon is referenced by just Polygon.
[23:48:47] opus: However in dev or testing it is NOT, for example it spits out a class not found
[23:48:55] opus: same thing
[23:49:18] opus: What exactly does ::Polygon mean in contrast to Polygon?
[23:51:00] opus: Not normally, it never displayed itself via tests or in the local environment. However I found the issue when I first tried to deploy it to a production environment. I was only able to replicate the issue when running production locally
[23:52:58] opus: Basically if I remove my local "Polygon" class. and enter in rails console in non production and type Polygon I get Uninitialized Constant. However if I run that same command in Production it returns -> GeoKit::Polygon
[23:54:36] opus: Here is the output of me running ack "polygon" on my project.
[23:54:53] opus: https://gist.github.com/tmeusburger/706d341fabb891b47389
[23:55:19] opus: bricker`work: I never personally do that, what should I look for to indicate if the geokit gem is doing that?
[23:58:24] opus: Even without foreman the problem is that the rails_env is changing which class objects are getting injected into the root namespace
[23:58:48] opus: Thank you for the suggestion though AntelopeSalad. I just have no clue why rails changes that depending on if it's in dev or production mode
[23:59:50] opus: Oh, my bad!

2014-06-30

[07:53:50] opus: Quick question about rails naming conventions. I have a hard time thinking up adequate names for polymorphic associations. Some make sense like "imageable" etc. How do you guys handle this when you have a table that is named something like 'coordinates'. Coordinateable is just weird but I always have a hard time thinking up a proper name for that relationship.
[07:54:16] opus: locationable doesn't make sense as a location is not always exactly one coordinate and could denote other things
[07:58:49] opus: Is there any convention that should be followed when that type of naming convention isn't as fluid?
[08:02:30] opus: Hm... those make sense if not for the fact that I have multiple mappable or locatable objects. Let me provide some background. Also, thanks for helping!
[08:02:50] opus: In the system I'm building. There are polygons, radial objects, and specific coordinates.
[08:03:14] opus: so, a polygon could be mapped, a circle could be mapped, or just a specific location (lat/lng)
[08:03:36] opus: right now, polygon has many coordinates. Not sure how to name them when everything that is generic doesn't seem to cover it in my head.
[08:03:52] opus: xshivan: go for it! No idea if I'll be able to help but better to just ask =)
[08:08:28] opus: looking into the gist now xshivan
[08:12:02] opus: just to make sure, user -> project -> users
[08:15:39] opus: Yeah, but you'll have to add one piece on that belongs_to
[08:15:43] opus: if I understand correctly
[08:15:57] opus: belongs_to :owner, class_name: "User"
[08:17:00] opus: sevenseacat: any suggestions as it pertains to my naming convection for polymorphic associations?
[08:17:15] opus: If you wish to continue to spread joy
[08:17:43] opus: Basically, with polymorphic associations there is the naming convention of calling something -able, such as "imageable" etc.
[08:17:53] opus: when you have multiple objects that share a generic ... for example
[08:18:02] opus: I have polygons, circles and points that can be "mapped" onto something
[08:18:35] opus: agreed... I've been lazy and just put -able to whatever my object is but it reads horribly
[08:18:42] opus: all of them are though.
[08:18:54] opus: Whereas coordinate is the one that is polymorphic
[08:18:58] opus: but so is polygon
[08:19:47] opus: owner in that case is a singular object not an array
[08:34:47] opus: glad you got it figured out xshivan
[08:37:47] opus: Understandable, I came from the world of C and Java. Love Ruby, took me a while to -get- rails though.
[08:39:18] opus: Just depends on what you're doing. Right tool for the job and all that!
[10:22:39] opus: Is there a way to have multiple has_one polymorphic relationships on the same model by overriding what _type is saved for that relationship?
[10:22:53] opus: I can't see anything to indicate it in the documentation but wanted to make sure I'm not missing anything.