0

我将 select_tag 用于列表框,用于创建用户,用户正在创建但在数据库中为列表框中的选定选项存储空值。

查看代码:

    About     :
<div class="field">
  &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp
  <%= select_tag "about_id",options_from_collection_for_select(@abouts, "id", "name"),:multiple =>true%>
</div>

控制器动作创建:

def create
    @student = Student.new(params[:student])
    respond_to do |format|
      if @student.save
      Query.query_confirmation(@student).deliver

       format.html { redirect_to :controller=>"students",:action=>"new", notice: 'Student was successfully created.' }
        flash[:notice]="Your Question has been sent to the University they will revert back soon"
        format.json { render json: @student, status: :created, location: @student }
      else
        format.html { render action: "new" }
        format.json { render json: @student.errors, status: :unprocessable_entity }
      end
    end
  end

帮助将不胜感激。

4

0 回答 0