Q:

Rails Associations - Strong Parameters Build

So I have to following models. 
class Team < ActiveRecord::Base
    belongs_to :user 
    has_and_belongs_to_many :players
    accepts_nested_attributes_for :players
end

class Player < ActiveRecord::Base
    has_many :statistics
    has_and_belongs_to_many :teams
end

I wish to build a team that has players, these will be selected by the user. I can do this perfectly in the console by doing to following. 
@user = User.find(10) 
@team = @user.build_team(name: "MyTeam", points: 0)
    #<Team team_id: nil, name: "MyTeam", points: 0, user_id: 10>
@team.players.build(name: "Messi") 
    #<Player player_id: nil, name: "Messi", role: nil>
@team.save 

However I am really struggling passing parameters due to strong params. Here is my view
<%= form_for :team do |f| %>

    <%= f.label :name %><br />
    <%= f.text_field :name %>

    <%= f.fields_for :players do |players| %>
        <%= players.label :player_name %>
        <%= players.text_field :name %>
    <% end %>

    <div><%= f.submit "Create Team" %></div>

<% end %>

I want to build the team using the team parameters and the players using the player parameters, however I cannot figure out how to get this working in the controller. 
class TeamController < ApplicationController

    before_action :authenticate_user!

    def new 
    end

    def create 
         @user = User.find(current_user.id)
         @team = @user.build_team(team_params) #Just the team paramaters 

         @team = @team.players.build(player_params)# I want just the player params 

         @team.save
    end

private

    # I can add the player param as nested i.e. .permit(:name, :players => [:name])
    # but then build_team complains about receiving an array. 

    def team_params
        params.require(:team).permit(:name) 
    end

end

Any solutions welcome, as are any improvements. 
EDIT - ADDED SCHEMA
create_table "players", primary_key: "player_id", force: true do |t|
    t.string "name", limit: 50, null: false
    t.string "role", limit: 30, null: false
end

create_table "players_teams", id: false, force: true do |t|
    t.integer "player_id", null: false
    t.integer "team_id",   null: false
end

# players_teams is a Composite Primary Key, as instructed in the guides;
# also essential for targeting. 

create_table "teams", primary_key: "team_id", force: true do |t|
    t.string  "name",    limit: 200,             null: false
    t.integer "points",              default: 0, null: false
    t.integer "user_id",                         null: false
end

EDIT 2
Since this has not yet been answered I'll add more explanation as to what I am attempting.
The user has one team, I can build the team and the relationship is also built thanks to ActiveRecord. The users team then has many players and players have many teams, when I try to build this relationship the players table never changes, no relationship is created.
I feel I should stress again that the following works perfectly in the rails console 
@user = User.find(10) 
@team = @user.build_team(name: "MyTeam", points: 0)
    #<Team team_id: nil, name: "MyTeam", points: 0, user_id: 10>
@team.players.build(name: "Messi") 
    #<Player player_id: nil, name: "Messi", role: nil>
@team.save 

Team is set to accept nested parameters so I thought this would work. 
@team = @user.build_team(team_params)

def team_params
    params.require(:team).permit(:name, players_attributes: [:name, :role]) 
end

I believe this should build the players model and create the relationship however no player is ever inserted and no relationship built. 

A:

First make a few changes in the TeamsController as below:
class TeamController < ApplicationController

    before_action :authenticate_user!

    def new 
      ## Set "@team" and build "players"
      @team = current_user.build_team
      @team.players.build
    end

    def create 
      @team = current_user.build_team(team_params)  
      if @team.save
        ## Redirect to teams show page 
        redirect_to @team, notice: 'Team was successfully created.' 
      else
        ## In case of any error while saving the record, renders the new page again 
        render action: 'new'
      end
    end

   private

    # I can add the player param as nested i.e. .permit(:name, :players => [:name])
    # but then build_team complains about receiving an array. 

    def team_params
      ## Permit players_attributes
      params.require(:team).permit(:name, players_attributes: [:id, :name]) 
    end

end

After this, update the view as below:
<%# Changed "form_for :team" to "form_for @team" %>
<%= form_for @team do |f| %> 

    <%= f.label :name %><br />
    <%= f.text_field :name %>

    <%= f.fields_for :players do |player| %> <%# Changed "|players|" to "|player|" %>
        <%= player.label :name %>  <%# Changed "player_name" to "name" and "players" to "player" %>
        <%= player.text_field :name %> <%# Changed "players" to "player" %>
    <% end %>

    <div><%= f.submit "Create Team" %></div>

<% end %> 

Set an instance variable @team in new action and build the players for that @team.
Use @team instance variable as an argument for form_for in your view code.
I have also suggested a few tweaks in the create action, so you know if the team is saved or not.
And fixed the team_params method to permit the nested attributes of players. 
UPDATE
Using @team as an argument to form_for method is resource-oriented style and much preferred way. 
Read this pretty good description about usage of form_for to get a better idea. 
You can still implement the required code while using :team but its not preferred way of doing it.
Example using :team: 
<%= form_for :team do |f| %> 

    <%# ... %>

    <%= f.fields_for :players, f.object.players.build do |player| %> <%# build the players for the team %>
        <%# ... %>
    <% end %>

    <%# ... f.submit "Create Team" %>

<% end %> 

fields_for in your case would iterate over players (@team.players) belonging to a particular team (@team). If there are no players then you won't see any fields for players in the form, which is why you build the players so you at least get some blank fields for players to input which is why when using accepts_nested_attributes_for you need to build the nested attributes. You can build them either at controller level(as shown in above suggested code) or within the form. 
Example for "within the form":
<%= form_for @team do |f| %> 

    <%# ... %>

    <%= f.fields_for :players, @team.players.build do |player| %> <%# build the players for @team %>
        <%# ... %>
    <% end %>

    <%# ... f.submit "Create Team" %>

<% end %> 

