Page 1 of 1
[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: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:23:40] opus: The logic in the fuction is simple but it looks like the logic is in the calling class for it.
[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?
[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:23:42] opus: andll: It's a system that was already designed and I'm trying to get this one case functioning.
[02:29:12] opus: Fair enough... The problem is the original design has essentially a table with like 3-4 foreign keys.
[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: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: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: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: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: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.
[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:38:28] opus: If anyone could assist me with a rails Module scoping issue when in production I would really appreciate it.
[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:50] opus: Those are the only references and when I call them it's always Polygon, or GeoKit::Polygon.
[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: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: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: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
[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:17:00] opus: sevenseacat: any suggestions as it pertains to my naming convection for polymorphic associations?
[08:17:43] opus: Basically, with polymorphic associations there is the naming convention of calling something -able, such as "imageable" etc.
[08:18:35] opus: agreed... I've been lazy and just put -able to whatever my object is but it reads horribly
[08:37:47] opus: Understandable, I came from the world of C and Java. Love Ruby, took me a while to -get- rails though.
[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?