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 = rolemove = Moves.find(1)
role = Role.find(1)
role.moves << move
class Player < ActiveRecord::Base
attr_accessible :username, :password
has_many :chats
has_one :role
end
class Role < ActiveRecord::Base
attr_accessible :role_name
belongs_to :player
has_many :moves
end
class Move < ActiveRecord::Base
attr_accessible :about_move, :move
belongs_to :role
end
Can anybody suggest me how to do that? Thanks in advance!