User specified rich types do not reliably load when called with symbol
Reported by kevinpfromnm | July 30th, 2009 @ 10:55 PM | in Hobo 1.0 - Final
Say you have a new rich type...
class Url < String
COLUMN_TYPE = :string
HoboFields.register_type(:url, self)
...
end
And an field using your new type
fields do
...
homepage :url
end
On first load of the server, or if you go into script/console you'll find the homepage field returns class of String. Also, polymorphic dryml tags will not properly trigger (i.e. you have a particular view tag for Url).
If you change the fields call to be:
homepage Url
it will load properly.
This isn't as much an issue except two things, 1) the symbol is the way demonstrated in the manual and 2) symbols are more consistent with how the other fields are defined.
Comments and changes to this ticket
-
kevinpfromnm July 30th, 2009 @ 10:57 PM
- Tag set to bug, hobofields, rich-types
-
Matt Jones August 3rd, 2009 @ 03:58 AM
I've avoided this in production code by loading the types explicitly in an initializer - this also gets around some issues in production where the type never gets loaded.
-
kevinpfromnm August 3rd, 2009 @ 05:16 AM
That's fine but then the rich type docs should reflect what's necessary to get reliable results from rich types.
-
Tom Locke October 24th, 2009 @ 06:01 PM
- Milestone set to Hobo 1.0 - Final
The docs need updating on this one. I don't think we want to try and load the class automatically based on the symbol. A nice solution might be to suggest putting the
HoboFields.register_type(:url, Url)
in an initializer. -
Tom Locke October 24th, 2009 @ 06:08 PM
- State changed from new to open
-
Bryan Larsen October 29th, 2009 @ 11:10 PM
- Tag changed from bug, hobofields, rich-types to hobofields, rich-types
-
Bryan Larsen October 29th, 2009 @ 11:10 PM
- Tag changed from hobofields, rich-types to defect, hobofields, rich-types
-
Matt Jones November 22nd, 2009 @ 07:36 PM
- Assigned user set to Matt Jones
- State changed from open to investigating
-
Matt Jones November 26th, 2009 @ 04:07 PM
Autoloading seems like a messy proposition; it's not likely to have much of an impact either way, since we end up with all the models loaded before the first request anyways.
The simplest automatic option would be to define a standard storage place (the hobo-users consensus seemed to be app/rich_types) and just load every file in that directory as part of Hobofields startup. No fussing with autoloaders, and the types will then be defined every time.
Thoughts?
-
Tom Locke December 1st, 2009 @ 05:24 PM
- State changed from investigating to resolved
(from [572c7c14026b1dc4b6055bedad62f9cd09af8003]) [#475 state:resolved] load rich types from app/rich_types http://github.com/tablatom/hobo/commit/572c7c14026b1dc4b6055bedad62...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
People watching this ticket
Tags
Referenced by
- 475 User specified rich types do not reliably load when called with symbol (from [572c7c14026b1dc4b6055bedad62f9cd09af8003]) [#475 s...