Rails 4属性应该是一个数组,但它是一个Fixnum。 - 0

时间:2014-10-15 09:10:51

标签: ruby-on-rails-4 serialization

我想插入多条记录但在SUBJECT_SCORE中有更改。我传递SUBJECT_SCORE作为数组,但得到错误属性应该是一个数组,但是一个Fixnum。 - 0

Controller.rb

def create
    @student_score = studentScore.new(student_score_params)
    respond_to do |format|
      if @student_score.save
        format.html {  flash[:notice] = 'User successfully created.' and redirect_to action: "index"}

        format.json { render :show, status: :created, location: @student_score }
      else
        format.html { render :new }
        format.json { render json: @student_score.errors, status: :unprocessable_entity }
      end
    end
  end
      def student_score_params
          params.require(:student_score).permit(:student_ID, :primary_key, :ASSESSMENT_ID, :SCHOOL_ID,:SUBJECT_SCORE, :GRADE_CODE, :CREATED_BY, :UPDATED_BY)
        end

Model.rb

class StudentScore < ActiveRecord::Base
  serialize :Subject_SCORE ,Array
 end

我如何解决这个问题,以便在行中插入多个记录,主题得分发生变化,所有参数的其余部分都相同

1 个答案:

答案 0 :(得分:0)

我删除了序列号:subject_Score,模型中的数组,它解决了这个问题