2

我正在将电子表格中的数据导入应用程序数据库。

数据按行解析。每个解析的行看起来像:

{:department=>{
  :school=>"Graduate School of Business",
  :name=>"Graduate School of Business",
  :program=>"MBA Program",
  :url=>"http://www.gsb.stanford.edu/mba",
  :intro=>"The Stanford MBA Program is a two-year, full-time, residential program.",
  :students_number=>"Approximately 80 annually",
  :students_with_aids_number=>nil,
  :gre_scroe=>nil,
  :toefl_score=>nil,
  :world_rank=>nil,
  :us_rank=>nil,
  :without_aid_deadline=>nil,
  :with_aid_deadline=>nil,
  :salary=>nil,
  :institute_id=>1}
}

创建部门:

 # att is the hash shown above
    department = Department.new(department_params(att))
    if !department.save
        puts "Error: \n department can't be save: #{department.errors.full_messages}"
    end

 def department_params params
   params.require(:department).permit(:name,:url,:institute_id)
 end

但我得到了错误:

no implicit conversion of Symbol into String

这指向

params.require(:department).permit(:name,:url,:institute_id)

我该如何解决?谢谢!

4

1 回答 1

5

让 rails-api 和 strong_parameters 一起工作

我认为这将是非常相似的事情。您只需要包含ActionController::StrongParameters链接问题中描述的不需要。

就我而言,它正在添加新的初始化程序

ActionController::API.send :include, ActionController::StrongParameters
于 2013-07-17T15:26:33.967 回答