2013-05-09 60 views
2

我正在將數據從電子表格導入到應用程序數據庫。Rails 4強參數錯誤:沒有將符號隱式轉換爲字符串

數據按行分析。每個解析行的樣子:

{: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) 

怎麼可能我修復它?謝謝!

+0

保育鈞:你還在嗎? ;) – Mailo 2014-01-07 14:48:09

回答

5

Getting rails-api and strong_parameters to work together

我認爲這將是非常類似的東西。你只需要包括ActionController::StrongParameters不需要如鏈接問題中所述。

在我來說,這是增加新的初始化與

ActionController::API.send :include, ActionController::StrongParameters 
相關問題