Has_one and forms

17 views
Skip to first unread message

JezC

unread,
Jan 10, 2012, 4:17:54 AM1/10/12
to Hobo Users
I think I've got a reason to use a has_one model - it's basically a
table that lists some standard values for things, and a description. I
don't want to go from that table back to any other table (so a
has_many_through isn't right). Hobo doesn't support has_one
relationships... does it?

What can I do to show up this field in forms - I want to have a
selection box that shows the (small) choice of items in the "has_one"
model?

Or must I re-interpret the model, and do something to block going from
the item-description table back to the model that uses it?

Bob Sleys

unread,
Jan 10, 2012, 10:01:43 AM1/10/12
to hobo...@googlegroups.com
Use a belongs_to relationship.  Sounds like a one-to-many to me.  Even though you aren't going from the direction of the many to one it still exists.

Bob

Ignacio Huerta

unread,
Jan 10, 2012, 11:37:35 AM1/10/12
to hobo...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Maybe if you post the real world examples it would be easier to
decide, but Bob is probably right: it looks like you need a belongs_to
/ has_many relationship.

Regards,
Ignacio

El 10/01/12 16:01, Bob Sleys escribi�:

- --
Ignacio Huerta Arteche
http://www.ihuerta.net
Tel�fono: 0034 645 70 77 35
Email realizado con software libre
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8MaU0ACgkQBPlUJ6RHaOR/QwCg7ma+KMFSl0FwIIDWk7d2JoEx
TzEAoNBsD9uBWQsOhstgtE06VidYzE2e
=7KxF
-----END PGP SIGNATURE-----

JezC

unread,
Jan 14, 2012, 6:48:53 PM1/14/12
to Hobo Users
OK, tried this. I see what you mean. There is a relationship; I just
didn't want to expose it.

It's taken some fiddling, but I think I've now removed the way to go
from the one to the many - which was what I was really after.

Thanks for the guidance, JeremyC
Reply all
Reply to author
Forward
0 new messages