Hi, I am a bit of a rails novice and trying to work this out. Been
tearing my hair out over this for a long time.
I have 2 models that I am working on at the moment. The idea is that
Teams have many players and Players have many teams. I want to be able
to assign a starting team to a player when they are created.
class Team < ActiveRecord::Base
has_and_belongs_to_many :players
class Player < ActiveRecord::Base
has_and_belongs_to_many :teams
*Note: I have set up the correct join table and can insert these
relationships from the ruby console. *
At the moment I have this in my view:
<%= select(:player_id, :teams, Team.all.collect{|s| [s.name, s.id]})
%>
It collects all the team names however when I hit submit nothing is
sent. Am I missing out something?
Thank you. I have spent ages trying to sort this out.
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment