Ruby on Rails select_tag

时间:2012-07-03 04:35:37

标签: ruby-on-rails

我正在使用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

帮助将受到高度赞赏。

0 个答案:

没有答案