title: Association belongs_to vs nested attributes in the form
body: <p>I have a situation like below:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    belongs_to :user_group
    accepts_nested_attributes_for :user_group
  end
  
  class UserGroup &lt; ActiveRecord::Base
    has_many :users
  end
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>UsersController &lt; ApplicationControler
    def new
      @user = User.new
      @user.build_user_group
    end
  
    def create
      @user = User.new(user_params)
  
      if @user.save
        # do something
      else
        # do something
      end
    end
  
    private
  
    def user_params
      params.require(:user).permit(:email, :username, user_group_attributes: [:name])
    end
  end
  </code></pre>
  
  <p>Form:</p>
  
  <pre><code>= simple_form_for @user do |f|
              = f.input :username
              = f.simple_fields_for :user_group do |builder|
                = builder.input :name, collection: UserGroup.all.map(&amp;:name), prompt: "Choose one"
              = f.input :email
              = f.button :submit, 'Create', class: 'btn btn-success'
  </code></pre>
  
  <p>But it doesn't create an user with the association between the user and the user_group. UserGroup table is just a list of user groups, e.g. moderator, user and so on. So I need to select a group in the form and create a new user with association. What am I doing wrong? Do I need to find a group in <code>create</code> action and pass it as <code>@user.user_group = the_chosen_group</code>?</p>
  
  <p>P.S. 
  Is it a proper name convention of UserGroup? Maybe should I call it as Group?</p>
  
  <p>Regards.</p>