Ruby on rails RubyonRails选择标签

Ruby on rails RubyonRails选择标签,ruby-on-rails,Ruby On Rails,我正在为列表框使用select_标记,为了创建用户,用户正在创建,但在数据库中,为列表框中的所选选项存储null值 查看代码: About : <div class="field"> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp &l

我正在为列表框使用select_标记,为了创建用户,用户正在创建,但在数据库中,为列表框中的所选选项存储null值

查看代码:

    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>

非常感谢您的帮助。

提示:日志文件是您的朋友。检查以查看create方法中学生的参数中实际接收到的内容,以及这些属性与数据库中学生定义的关系。Started GET/students/new?notice=student+was+successfully+created。对于2012-07-03 10:11:31+0530时的127.0.0.1,由StudentsControllernew处理为HTML参数:{notice=>Student已成功创建。}[1m[36mAbout Load 0.0ms[0m[1m选择abouts.*自abouts[0m Rendered students/_form.html.erb 3.0ms Rendered students/new.html.erb in layouts/application 4.0ms在23ms视图中完成200 OK:18.0ms | ActiveRecord:1.0ms这是我在日志文件中得到的内容,这是您应该查看的步骤后一步中的日志摘录。您需要查看的是与创建相关的日志学生是处理提交的步骤。在这里,表单填充的参数被重新组合到学生中并存储在数据库中。你的参数与你的数据结构匹配吗?我不相信你的“学生”被设计来处理多个选择输入,只需约个id。在logger中,它获取多个值,但插入null作为数据库中的值。
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