我正在尝试进行此关联,其中:
小组has_one
用户through
队长
Captain.rb
class Captain < ActiveRecord::Base
belongs_to :user
belongs_to :team
Team.rb
class Team < ActiveRecord::Base
has_one :user, through: :captain
end
User.rb
class User < ActiveRecord::Base
has_one :captain
belongs_to :team
has_many :invites
has_and_belongs_to_many :games
has_one :captain
end
以及第27行的以下错误:
NoMethodError in TeamsController#create
26 def create
*27 @team = current_user.teams.create(team_params)*
28 @team.save
29 respond_with(@team)
30 current_user.update(team_id: @team.id)
...谢谢