如何获取rails参数以接受字符串数组?

时间:2021-01-20 15:07:18

I have a model which has an array of strings.

我有一个有一个字符串数组的模型。

class A < ApplicationRecord
  serialize :vals, Array
end

How can I get my controller

我怎样才能得到我的控制器

class AController < ApplicationController
  def create
    par = params.require(:a).permit(:vals)
    ...
  end
end

to accept an array of inputs?

接受一系列输入?

1 个解决方案

#1


1  

Try declaring it as an array of values:

尝试将其声明为值数组:

def create
  par = params.require(:a).permit(vals: [])
  ...
end

#1


1  

Try declaring it as an array of values:

尝试将其声明为值数组:

def create
  par = params.require(:a).permit(vals: [])
  ...
end