google-code-export / cfwheels

Automatically exported from code.google.com/p/cfwheels
0 stars 0 forks source link

Polymorphic associations #110

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to have polymorphic associations the same way Rails has for 
its Model. The belongsTo would be needing a bit of chance but I am wondering if 
anyone is already trying to 
implement this? I would love to give it a go.

Original issue reported on code.google.com by rierar...@gmail.com on 13 Oct 2008 at 2:00

GoogleCodeExporter commented 9 years ago
Go ahead!

I don't think anyone is working on it.

Original comment by per.djurner@gmail.com on 14 Oct 2008 at 9:49

GoogleCodeExporter commented 9 years ago
Hmmm I am having problems reading through the code, mostly because is mostly 
not commented and looks 
like some places is kind of "minimized" (some1 removing spaves, tabs, and 
enters to make it more 
"lightweight")

I am also wondering what does this function do.

<cffunction name="$registerAssociation" returntype="void" access="private" 
output="false">
    <cfscript>
        var loc = {};
        variables.wheels.class.associations[arguments.name] = {};
        for (loc.key in arguments)
            if (loc.key IS NOT "name")
                variables.wheels.class.associations[arguments.name][loc.key] = arguments[loc.key];
    </cfscript>
</cffunction>

where is that variable (variables.wheels.class.associations) located? and why 
the fuctions access arguments 
that arent there?

Original comment by rierar...@gmail.com on 15 Oct 2008 at 11:46

GoogleCodeExporter commented 9 years ago

Original comment by per.djurner@gmail.com on 6 Mar 2009 at 11:11

GoogleCodeExporter commented 9 years ago
I want to write down here my "conceptual" idea for this implementation:

- Enable a new argument for each association, "isPolymorphic"
- Utilize some sort of convention for polymorphic associations (I don't like 
the word polymorphic is confusing) 
like "connectionType" and "connectionId" 
- Use those 2 columns in replacement of "[modelname]Id" when isPolymorphic is 
true (I know this is how 
hasMany handles "lookups" I will have to review the others) to find the desired 
record.

Sounds easier that it is really, I know :)

Original comment by rierar...@gmail.com on 6 Mar 2009 at 11:26

GoogleCodeExporter commented 9 years ago

Original comment by per.djurner@gmail.com on 7 Mar 2009 at 9:26

GoogleCodeExporter commented 9 years ago
Issue 237 has been merged into this issue.

Original comment by per.djurner@gmail.com on 18 Aug 2009 at 10:12

GoogleCodeExporter commented 9 years ago

Original comment by per.djurner@gmail.com on 6 Dec 2009 at 6:03

GoogleCodeExporter commented 9 years ago
I believe Rails is storing the "Class" name in the db "type" field for 
polymorphic data.  Not sure if this is helpful when you go to implement it.

I'd love to help in any way possible.

I've been trying to port several useful Rails 3 features into Wheels plugins 
lately.
I'll let you know my progress.

Original comment by jos...@remote-app.com on 27 Mar 2012 at 8:50