Topic: How to link associative items in view?

Hello, everyone!

I have run in to problem with associations. What I want to do, is link them together through views, but as far as I've googled - no success.

These are my 3 models I'd like to link together. I know how to do that through rails console:

role = Role.find(1)
   player = Player.find(1)
   player.role = role

   move = Moves.find(1)
   role = Role.find(1)
   role.moves << move

class Player < ActiveRecord::Base
   attr_accessible :username, :password
   has_many :chats
   has_one :role

class Role < ActiveRecord::Base
  attr_accessible :role_name
  belongs_to :player
  has_many :moves

class Move < ActiveRecord::Base
  attr_accessible :about_move, :move
  belongs_to :role

Can anybody suggest me how to do that? Thanks in advance!

Re: How to link associative items in view?

If you want to associate existing records:
For Player <=> Roles, you'll just have a select box that contains the Role names as the option content, and the ids of the roles as the related values.
For Role <=> Moves, you need a multiple select.

If you plan on collecting role or move data in addition to the player or role (respectively) data, then look at accepts_nested_attributes_for and the railscasts Complex Forms series.