> - - begin code - -
>
> class Band < ActiveRecord::Base
> belongs_to :tours
> end
>
> class Tour < ActiveRecord::Base
> has_one :bands
> end
>
First, this should be has_one :band, not :bands> - - begin code - -
>
> <p><label
for="band_id">Band</label><br>
> <%= select("band", "band_id",
Band.find_all.collect {|p| [ p.name,
> p.id ] }) %>
>
I don''t know how did you built your DB schema, but it should be
something like this
----
table bands:
id
name
tour_id
(other columns)
table tours:
id
location
(other columns)
----
in this case, when using belongs_to - has_one, the child element (aka
the one who belongs to other) need to have a column indicating it''s
association id (in my ex. it''s tour_id) that''s how you will
get your
relation.
as for the select it''s should be <%= select_tag "tour",
"band_id",
Band.find(:all).collect {|e| [e.name, e.id]} %>
if i missed your point, i''ll be happy to help you for free of course if
you refer to my by mail (elad-JJg+wbmsuWCakBO8gow8eQ@public.gmane.org) or by MSN
(eizesus-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org).
hope this helps
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---