2016-07-18 2 views
0
내 응용 프로그램을 실행하는 동안이 오류가 직면하고

: 나는 보고서를 저장할 수 있어요하지만 할 수# <액티브 :: 협회 :: CollectionProxy []> 레일에

<ActiveRecord::Associations::CollectionProxy []>

을 아이콘을 저장합니다. Rails 3.2.13에서는 괜찮 았지만 Rails 4.2.6에서는이 문제를 제기하고 있습니다.

report.rb :

class Report < ActiveRecord::Base 
    belongs_to :user 
    has_many :icons, -> { order 'position_id ASC'} 
    accepts_nested_attributes_for :icons, :reject_if => lambda { |a| a[:icon].blank? }, :allow_destroy => true 
end 

icon.rb :

class Icon < ActiveRecord::Base 
    belongs_to :report 
end 

reports_controller :

def new 
@report = @user.reports.new({ 
     :background_color => Rails.application.config.custom.accounts.send(@user.account.name).colors.background, 
     :text_color => Rails.application.config.custom.accounts.send(@user.account.name).colors.commentary, 
     :button_color => Rails.application.config.custom.accounts.send(@user.account.name).colors.button 
     }) 
3.times { @report.icons.build } 

end 

    def create 
    respond_to do |format| 
     if @report.save  
     format.json { render :json => { :success => true, :user_id => @user.id, :report_id => @report.id, :report_title => @report.title, :icon_array => @report.icons, :redirect => user_report_url(current_user, @report.id) } } 
     else 
     format.json { render :json => { :success => false } } 
     end 
    end 
    end 

내가 보고서를 저장할 수 모르지만, 아이콘 저장되지 않습니다. 제발 도와주세요

+0

이 줄'if @ report.save'를'if @ report.save! '로 변경하면 어떻게됩니까? –

+0

죄송 합니다만 오류는 아닙니다. 로그에서 완전한 스택 추적과 중단되는 라인과 일치하는 코드를 제공 할 수 있습니까? – phoet

답변

1

강한 매개 변수에서 아이콘 속성을 놓친 것 같아요.