Does hobo support polymorphic relationships?

5 views
Skip to first unread message

MartOn

unread,
Nov 4, 2008, 2:52:27 PM11/4/08
to Hobo Users
Does the built in taglib support the polymorphic => true feature of a
belongs_to ?

For instance if you make a
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end

/MartOn

Gert Thiel

unread,
Nov 21, 2008, 9:00:27 AM11/21/08
to Hobo Users
Tom,

I need to know that as well.

My hobo-based project evolved beyond the point that I need some
polymorphic associations.

So, does Hobo support them?

Regards,

Gert Thiel

Tom Locke

unread,
Nov 21, 2008, 9:05:12 AM11/21/08
to hobo...@googlegroups.com
> My hobo-based project evolved beyond the point that I need some
> polymorphic associations.
>
> So, does Hobo support them?

What do you mean by "support"?

Tom

Gert Thiel

unread,
Nov 21, 2008, 9:43:40 AM11/21/08
to Hobo Users
Hobos supporting plain assocs by offering an automagically generated
dropdown.

Having a polymorphic associations I get an input box for the type
field…

Tom Locke

unread,
Nov 21, 2008, 9:49:42 AM11/21/08
to hobo...@googlegroups.com
> Hobos supporting plain assocs by offering an automagically generated
> dropdown.

I can't think of a decent equivalent for polymorphic menus. I think it
might be a design mistake if your app needs this. Whenever I've needed
polymorphic associations I find I want to edit them from the other end.

For example, a couple of common use cases are a generic comment model,
and tagging. In both cases you add the comment or the tag to the thing
you want to comment/tag. You don't start with the comment or tag and
indicate what thing it should belong to.

Do you have a counter example? What kind of an input control would you
like to see.

> Having a polymorphic associations I get an input box for the type
> field…

You could declare never_show on the field

Tom

Gert Thiel

unread,
Nov 21, 2008, 10:24:18 AM11/21/08
to Hobo Users
> > Hobos supporting plain assocs by offering an automagically generated
> > dropdown.
>
> I can't think of a decent equivalent for polymorphic menus. I think it  
> might be a design mistake if your app needs this. Whenever I've needed  
> polymorphic associations I find I want to edit them from the other end.

I must consider this. Maybe it's just my fault ;-)

> For example, a couple of common use cases are a generic comment model,  
> and tagging. In both cases you add the comment or the tag to the thing  
> you want to comment/tag. You don't start with the comment or tag and  
> indicate what thing it should belong to.
>
> Do you have a counter example? What kind of an input control would you  
> like to see.

But if I'd have a list of comment I still would like a links to the
commented things.

> > Having a polymorphic associations I get an input box for the type
> > field…
>
> You could declare never_show on the field

You mean something inside fields do … end?

Thanks for your thoughts.

Regards,

Gert

Tom Locke

unread,
Nov 21, 2008, 1:50:18 PM11/21/08
to hobo...@googlegroups.com
> But if I'd have a list of comment I still would like a links to the
> commented things.

That should work OK.

> You mean something inside fields do … end?

Just inside the class

class Foo < AR:Base
fields do
...
end
never_show :abc
end

Tom

Reply all
Reply to author
Forward
0 new messages