为什么我在尝试创建表单时遇到ActiveRecord :: AssociationTypeMismatch错误

时间:2016-03-18 00:50:47

标签: ruby ruby-on-rails-4

我正在构建一个壮观的申请表

这是必要的代码

新表格

<!--header--> 
<div class="header" >
  <div class="col-md-3 header-top cbp-spmenu-push">
    <nav class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-left" id="cbp-spmenu-s1">
      <li><%= link_to "Home", { controller: "welcome" } %></li>
      <li><%= link_to "About us", about_index_path %></li>
    </nav>
    <!-- /script-nav -->
      <div class="main">
        <section class="buttonset">
          <button id="showLeftPush"><i  class="glyphicon glyphicon-menu-hamburger"></i></button>
        </section>
      </div>
      <!-- Classie - class helper functions by @desandro https://github.com/desandro/classie -->
        <%= javascript_include_tag 'classie', 'data-turbolinks-track' => true %>
          <script>
            var menuLeft = document.getElementById( 'cbp-spmenu-s1' ),
            showLeftPush = document.getElementById( 'showLeftPush' ),
            body = document.body;

            showLeftPush.onclick = function() {
              classie.toggle( this, 'active' );
              classie.toggle( body, 'cbp-spmenu-push-toright' );
              classie.toggle( menuLeft, 'cbp-spmenu-open' );
              disableOther( 'showLeftPush' );
            };
          </script>
  </div>
  <div class="col-md-6 logo">
    <h1><a href="index.html"><span>MISS</span> CRYSTAL <span>NIGERIA</span></a></h1>
  </div>
  <div class="clearfix"> </div>
</div>
  <!---pop-up-box---->
    <%= stylesheet_link_tag  'popuo-box', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'jquery.magnific-popup', 'data-turbolinks-track' => true %>
  <!---//pop-up-box---->
  <div id="small-dialog" class="mfp-hide">
    <div class="search-top">
      <div class="login">
        <input type="submit" value="">
        <input type="text" value="Search.." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Search..';}">   
      </div>
      <p>Education</p>
    </div>        
  </div>
     <script>
      $(document).ready(function() {
      $('.popup-with-zoom-anim').magnificPopup({
      type: 'inline',
      fixedContentPos: false,
      fixedBgPos: true,
      overflowY: 'auto',
      closeBtnInside: true,
      preloader: false,
      midClick: true,
      removalDelay: 300,
      mainClass: 'my-mfp-zoom-in'
      });

      });
    </script>   
<!--//header--><!--banner-->
<div class="head">
  <div class="container">
    <h2 > <a href="/welcome/index">Miss Crystal Nigeria</a> / <span>Registration Form</span></h2>
  </div>
</div>
<!--content-->
  <div class="container">
  <div class="page">





  <%= form_for @form, html: { multipart: true } do |f| %>

  <% if @form and @form.errors and @form.errors.count > 0 %>
   <div class="alert alert-danger">
     <a class="close" data-dismiss="alert">&times;<a>
     <strong><%= pluralize(@form.errors.count,"error") %> found. Please fill the Important field denoted by the asteriks (*)</strong>

   </div>
   <% end %>

    <div class="grid_3 grid_4">
      <div class="page-header">
        <h3>Contact Information</h3>
      </div>
      <div class="bs-example" data-example-id="simple-horizontal-form">
           <div class="form-group">
            <label class="col-sm-2 control-label">First Name*</label>
            <div class="col-sm-6">
              <%= f.text_field :first_name, :class => "form-control", :placeholder => "First Name" %>
            </div>
          </div><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Last Name*</label>
            <div class="col-sm-6">
              <%= f.text_field :last_name, :class => "form-control", :placeholder => "Last Name" %>
            </div>
          </div><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Other Names</label>
            <div class="col-sm-6">
              <%= f.text_field :other_names, :class => "form-control", :placeholder => "Other Names" %>
            </div>
          </div><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Email*</label>
            <div class="col-sm-6">
              <%= f.text_field :email_address, :class => "form-control", :placeholder => "Email Address" %>
            </div>
          </div><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Backup Email*</label>
            <div class="col-sm-6">
              <%= f.text_field :backup_email_address, :class => "form-control", :placeholder => "Backup Email Address" %>
            </div>
          </div><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Address(1)*</label>
            <div class="col-sm-6">
              <%= f.text_area :first_street_address, :class => "form-control", :placeholder => "First Address" %>
            </div>
          </div><br /></br /><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Address(2)</label>
            <div class="col-sm-6">
              <%= f.text_area :second_street_address, :class => "form-control", :placeholder => "Second Address" %>
            </div>
          </div><br /><br /> <br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Address(3)</label>
            <div class="col-sm-6">
              <%= f.text_area :third_street_address, :class => "form-control", :placeholder => "Third Address" %>
            </div>
          </div><br /><br /><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">City/State/Island*</label>
            <div class="col-sm-6">
              <%= f.text_field :city, :class => "form-control", :placeholder => "City/State/Island of Residence" %>
            </div>
          </div><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Zip/Postal Code*</label>
            <div class="col-sm-6">
              <%= f.text_field :postal_code, :class => "form-control", :placeholder => "Zip Code / Postal Code" %>
            </div>
          </div><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Country*</label>
            <div class="col-sm-6">
              <%= f.country_select :country, priority_countries: ["NG"], :class => "form-control country" %>
            </div>
          </div><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Settlement Area</label>
            <div class="col-sm-6">
              <%= f.text_field :settlement, :class => "form-control", :placeholder => "Settlement Area of Residence" %>
            </div>
          </div><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Phone(Home)*</label>
            <div class="col-sm-6">
              <%= f.text_field :phone_home, :class => "form-control", :placeholder => "Home Line" %>
            </div>
          </div><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Phone(Mobile)*</label>
            <div class="col-sm-6">
              <%= f.text_field :phone_mobile, :class => "form-control", :placeholder => "Mobile Line" %>
            </div>
          </div><br />
          <div class="form-group">
            <label class="col-sm-2 control-label">Phone(Work)</label>
            <div class="col-sm-6">
              <%= f.text_field :phone_work, :class => "form-control", :placeholder => "Work Line" %>
            </div>
          </div><br />     
      </div>



<div class="grid_3 grid_4">
      <div class="page-header">
        <h3>Photos of You</h3>
      </div>
  <div class="bs-example" data-example-id="simple-horizontal-form">
       <div class="form-group">
        <label class="col-sm-2 control-label">Photo (1)</label>
        <div class="col-sm-4">
          <%= f.file_field :image, :class => "submit" %>
        </div>
      </div><br /><br /><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Photo (2)</label>
        <div class="col-sm-4">
          <%= f.file_field :imaget, :class => "submit" %>
        </div>
      </div><br />
  </div>  




  <div class="grid_3 grid_4">
      <div class="page-header">
        <h3>Personal Background and vital Statistics</h3>
      </div>
  <div class="bs-example" data-example-id="simple-horizontal-form">
       <div class="form-group">
        <label class="col-sm-2 control-label">How old are you?*</label>
        <div class="col-sm-6">
          <%= f.number_field :age, :class => "form-control", :placeholder => "Your Age" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Date of birth?*</label>
        <div class="col-sm-6">
          <%= f.date_select :dob, :class => "form-control", :placeholder => "" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Place of birth?*</label>
        <div class="col-sm-6">
          <%= f.text_field :place_of_birth, :class => "form-control", :placeholder => "Where were you born?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">State*</label>
        <div class="col-sm-6">
          <%= f.text_field :stateoo, :class => "form-control", :placeholder => "What's your state of origin?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">L. G. A.*</label>
        <div class="col-sm-6">
          <%= f.text_field :localgovt, :class => "form-control", :placeholder => "What's your Local Government Area" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Height(ft/")*</label>
        <div class="col-sm-6">
          <%= f.number_field :height, :class => "form-control", :placeholder => "to the nearest whole" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Weight(lbs)*</label>
        <div class="col-sm-6">
          <%= f.number_field :weight, :class => "form-control", :placeholder => "What do you weigh?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Swimsuit Size*</label>
        <div class="col-sm-6">
          <%= f.text_field :swimsuit_size, :class => "form-control", :placeholder => "What's your Swim suit size?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Dress size*</label>
        <div class="col-sm-6">
          <%= f.text_field :dress_size, :class => "form-control", :placeholder => "What's your Dress Size?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Shoe Size*</label>
        <div class="col-sm-6">
          <%= f.text_field :shoe_size, :class => "form-control", :placeholder => "What's your Shoe Size?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Employment/School*</label>
        <div class="col-sm-6">
          <%= f.text_field :employment_school, :class => "form-control", :placeholder => "What's Your Place of Employment or School You Attend?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Degrees*</label>
        <div class="col-sm-6">
          <%= f.text_field :degrees, :class => "form-control", :placeholder => "Please list Any Degrees Attained, Scholarships and or Achievements" %>
        </div>
      </div><br />   
      <div class="form-group">
        <label class="col-sm-2 control-label">Other Awards*</label>
        <div class="col-sm-6">
          <%= f.text_field :other_awards, :class => "form-control", :placeholder => "List Any Other Awards or Achievements(NON-SCHOLASTIC)" %>
        </div>
      </div><br /> 
      <div class="form-group">
        <label class="col-sm-2 control-label">Family Bio*</label>
        <div class="col-sm-6">
          <%= f.text_field :family_bio, :class => "form-control", :placeholder => "Tell Us of Any Interesting Fact About Your Family or Their Achievements" %>
        </div>
      </div><br />     
  </div>  


  <div class="grid_3 grid_4">
      <div class="page-header">
        <h3>More About You</h3>
      </div>
  <div class="bs-example" data-example-id="simple-horizontal-form">
       <div class="form-group">
        <label class="col-sm-2 control-label">Facebook Url*</label>
        <div class="col-sm-6">
          <%= f.text_field :facebook_url, :class => "form-control", :placeholder => "Are You On Facebook? If so, please provide the URL's(links)" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Twitter Url*</label>
        <div class="col-sm-6">
          <%= f.text_field :twitter_url, :class => "form-control", :placeholder => "Do You Have a Twitter Account? If so, please provide the URL's(links) to your page" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Favourite Color*</label>
        <div class="col-sm-6">
          <%= f.text_field :fav_color, :class => "form-control", :placeholder => "What's your Favourite Color?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Favourite Food*</label>
        <div class="col-sm-6">
          <%= f.text_field :fav_food, :class => "form-control", :placeholder => "What's your Favourite Food?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Favourite Sport*</label>
        <div class="col-sm-6">
          <%= f.text_field :fav_sport, :class => "form-control", :placeholder => "What's your Favourite Sport?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-4 control-label">Have you always lived in Nigeria*</label>
        <div class="col-sm-6">
          <%= f.check_box :always_naija %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">If No</label>
        <div class="col-sm-6">
          <%= f.text_field :nalways_naija, :class => "form-control", :placeholder => "Where else have you lived?" %>
        </div>
      </div><br />   
  </div>  



    <div class="grid_3 grid_4">
      <div class="page-header">
        <h3>Personal Outlook</h3>
      </div>
  <div class="bs-example" data-example-id="simple-horizontal-form">
       <div class="form-group">
        <label class="col-sm-2 control-label">Hobbies*</label>
        <div class="col-sm-6">
          <%= f.text_field :hoobies, :class => "form-control", :placeholder => "What are your Hobbies?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Sports*</label>
        <div class="col-sm-6">
          <%= f.text_field :sports, :class => "form-control", :placeholder => "What Sports or Activities Do you Participate in?" %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Life Ambition*</label>
        <div class="col-sm-6">
          <%= f.text_area :life_ambition, :class => "form-control", :placeholder => "What's your Life Ambition?" %>
        </div>
      </div><br /><br /> <br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Talent</label>
        <div class="col-sm-6">
          <%= f.text_field :performable_talent, :class => "form-control", :placeholder => "Do you Have any Performable Talent? If yes, List them" %>
        </div>
      </div><br /><br /> <br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Training</label>
        <div class="col-sm-6">
          <%= f.text_area :special_training, :class => "form-control", :placeholder => "Do you have any special training in Music, Dance, Arts, Etc?" %>
        </div>
      </div><br /><br /> <br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Languages*</label>
        <div class="col-sm-6">
          <%= f.text_area :languages, :class => "form-control", :placeholder => "Please list the languages you speak" %>
        </div>
      </div><br />   <br /> <br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Unusual Thing*</label>
        <div class="col-sm-6">
          <%= f.text_area :most_unusual_thing, :class => "form-control", :placeholder => "Whats's the most thing you have ever done?" %>
        </div>
      </div><br /><br /> <br />
      <div class="form-group">
        <label class="col-sm-2 control-label">Proud Moment*</label>
        <div class="col-sm-6">
          <%= f.text_field :most_proud_moment, :class => "form-control", :placeholder => "Briefly Describe the moment in your life you are most proud of" %>
        </div>
      </div><br /> 
      <div class="form-group">
        <label class="col-sm-2 control-label">Countries Visited</label>
        <div class="col-sm-6">
          <%= f.text_field :countries_visited, :class => "form-control", :placeholder => "List all the countries you have travelled to" %>
        </div>
      </div><br />   
  </div>  



<div class="grid_3 grid_4">
      <div class="page-header">
        <h3>Personal Statement</h3>
      </div>
  <div class="bs-example" data-example-id="simple-horizontal-form">
       <div class="form-group">
        <label class="col-sm-2 control-label">Self Bio*</label>
        <div class="col-sm-6">
          <%= f.text_area :intresting_selfbio, :class => "form-control", :placeholder => "Tell us something interesting About you." %>
        </div>
      </div>
  </div>  <br /><br /><br />


<div class="grid_3 grid_4">
      <div class="page-header">
        <h3>Verification</h3>
      </div>
  <div class="bs-example" data-example-id="simple-horizontal-form">
       <div class="form-group">
        <label class="col-sm-3 control-label">Verify True Information*</label>
        <div class="col-sm-6">
          <%= f.check_box :true_information %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-3 control-label">Verify True Age*</label>
        <div class="col-sm-6">
          <%= f.check_box :true_age %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-3 control-label">Terms and Condition*</label>
        <div class="col-sm-6">
          <%= f.check_box :true_tandc %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-3 control-label">Date*</label>
        <div class="col-sm-6">
          <%= f.date_select :date %>
        </div>
      </div><br />
      <div class="form-group">
        <label class="col-sm-3 control-label">Who referred you?*</label>
        <div class="col-sm-6">
          <%= f.collection_select :referee_id, @referee, :id, :name, :class => "form-control", :prompt => "Who referred you?" %><br />
          <%= f.text_field :referee, :class => "form-control", :placeholder => "Someone else? What's his/her name" %>
        </div>
      </div><br /> <br /><br />




      <div class="form-group">
        <label class="col-sm-3 control-label">Bank Teller Number*</label>
        <div class="col-sm-6">
          <%= f.text_field :bank_teller_number, :class => "form-control", :placeholder => "Please input Bank Teller Number or reference or leave blank if free" %>
        </div>
      </div><br />
    <div class="form-group">
        <label class="col-sm-3 control-label"></label>
        <div class="col-sm-6">
          <%= f.submit :class => "submit" %>
        </div>
      </div><br /> 
  </div>


  </div>  

</div></div></div></div></div></div></div></div>
<% end %>



</div>
<!--footter-->
<div class="footer">
  <div class="footer-mid">
      <div class="container">
        <div class="col-sm-4 ft-grid1">
          <h3>Location</h3>
          <p>Audition Venues are regional</p>
          <p>PH / LAGOS / ABUJA / CALABAR / ENUGU</p>
          <p>+234 803 229 7343</p>
        </div>
        <div class="col-sm-4 ft-grid2">
        <h3>Follow Us</h3>
          <ul class="social-in">
            <li><a href="http://facebook.com/misscrystalnigeria"><i> </i></a></li>            
            <li><a href="http://twitter.com/misscrystalnig"><i class="twitter"> </i></a></li>       
          </ul>
        </div>
        <div class="col-sm-4 ft-grid1">
          <h3>Contact us</h3>
          <p><a href="mailto:misscrystalnigeriapageant@gmail.com">misscrystalnigeriapageant@gmail.com</a></p>
        </div>
        <div class="clearfix"> </div>
      </div>
    </div>
    <div class="class-footer">
      <div class="container">
        <div class="col-md-6 footer-nav">
          <ul>
            <li ><%= link_to "Home", { controller: "welcome" } %></li>
            <li><a  href="welcome/about"  >About us</a></li>
            <li><a  href="/admin"  >Admin</a></li>            
          </ul>
        </div>
        <div class="col-md-6 footer-grid">
          <p >© 2016 MissCrystalNigeria. All rights reserved | Design by <a href="http://dicedorange.com/" target="_blank">DicedOrange</a> </p>
        </div>
          <div class="clearfix"> </div>
    </div>
  </div>
</div>
<!--//footter -->

表单模型

class Form < ActiveRecord::Base
    mount_uploader :image, ImageUploader
    mount_uploader :imaget, ImageUploader

    has_one :referee

end

表单控制器

class FormsController < ApplicationController
  before_action :set_form, only: [:show, :edit, :update, :destroy]

  layout 'aware'


  # GET /forms
  # GET /forms.json
  def index
    flash[:notice] = "Access Denied"
    redirect_to :controller => 'welcome', :action => 'index', notice: 'Access Denied'
    @forms = Form.all
  end

  # GET /forms/1
  # GET /forms/1.json
  def show
    flash[:notice] = "Access Denied"
    redirect_to :controller => 'welcome', :action => 'index', notice: 'Access Denied'
  end

  # GET /forms/new
  def new
    @form = Form.new
    referees = Referee.all
    @referee = referees.order(:name)
  end

  # GET /forms/1/edit
  def edit
    flash[:notice] = "Access Denied"
    redirect_to :controller => 'welcome', :action => 'index', notice: 'Access Denied'
  end

  # POST /forms
  # POST /forms.json
  def create
    @form = Form.new(form_params)

    respond_to do |format|
      if @form.save
        flash[:notice] = 'Successfully Submitted Form'
        format.html { redirect_to :controller => 'welcome', :action => 'index', notice: 'Form was successfully created.' }
        format.json { render :show, status: :created, location: @form }
      else
        format.html { render :new }
        format.json { render json: @form.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /forms/1
  # PATCH/PUT /forms/1.json
  def update
    respond_to do |format|
      if @form.update(form_params)
        format.html { redirect_to @form, notice: 'Form was successfully updated.' }
        format.json { render :show, status: :ok, location: @form }
      else
        format.html { render :edit }
        format.json { render json: @form.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /forms/1
  # DELETE /forms/1.json
  def destroy
    @form.destroy
    respond_to do |format|
      format.html { redirect_to forms_url, notice: 'Form was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_form
      @form = Form.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def form_params
      params.require(:form).permit(:first_name, :valide, :image, :referee, :localgovt, :stateoo, :imaget, :referee_id, :event_id, :last_name, :other_names, :email_address, :backup_email_address, :first_street_address, :second_street_address, :third_street_address, :city, :postal_code, :country, :settlement, :phone_home, :phone_mobile, :phone_work, :age, :dob, :place_of_birth, :height, :weight, :swimsuit_size, :dress_size, :shoe_size, :employment_school, :degrees, :other_awards, :family_bio, :facebook_url, :twitter_url, :fav_color, :fav_food, :fav_sport, :always_naija, :nalways_naija, :hoobies, :sports, :life_ambition, :performable_talent, :special_training, :languages, :like_to_meet, :most_unusual_thing, :most_proud_moment, :countries_visited, :intresting_selfbio, :true_information, :true_age, :true_tandc, :date)
    end
end

裁判模特

class Referee < ActiveRecord::Base
    has_many :forms
end

裁判控制员

class RefereesController < InheritedResources::Base

    def index
        flash[:notice] = "Access Denied"
        redirect_to :controller => 'welcome', :action => 'index', notice: 'Access Denied'
    end

    def show
        flash[:notice] = "Access Denied"
        redirect_to :controller => 'welcome', :action => 'index', notice: 'Access Denied'
    end

    def edit
        flash[:notice] = "Access Denied"
        redirect_to :controller => 'welcome', :action => 'index', notice: 'Access Denied'       
    end

  private

    def referee_params
      params.require(:referee).permit(:name, :post)
    end
end

无论何时我尝试创建表单,我都会遇到这个恼人的错误

  

FormsController中的ActiveRecord :: AssociationTypeMismatch #create

     

裁判(#69872442153920)预计,得到了弦(#69872584329080)    提取的来源(第38行):

36#POST /forms.json 37 def create

  

38 @form = Form.new(form_params)

39 40 respond_to do | format | 41 if @ form.save

1 个答案:

答案 0 :(得分:1)

看起来您有两个输入裁判的选项:集合选择和文本字段。因此,在您的表格参数中,您要么提交裁判ID,要么仅提供一串裁判的姓名。所以你的Form模型期待一个Referee对象,但它只是传递了一个String。

您有几个选项 - 如果选择了ID,您需要执行fileName: ${log-path}/rollingfile.log 并将其与其他参数一起传递给Form模型。或者,如果您要提交名称,则需要创建一个新的裁判,然后将其关联。

或者您可以使用嵌套表单并提交必要的裁判参数。您可以在表单中执行以下操作:

Referee.find(params[:referee_id]