2010-08-03 3 views
1

dB로 저장 버튼을 누르면 오류가 발생합니다 :저장 객체 내가 모델이

You have a nil object when you didn't expect it! 
You might have expected an instance of ActiveRecord::Base. 
The error occurred while evaluating nil.save 


/home/demas/artefacts/dev/study/ruby/rails/tracker/app/controllers/inbox_controller.rb:15:in `save_scr' 
/usr/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1331:in `perform_action' 
/usr/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/filters.rb:617:in `call_filters' 
... 

Request 
Parameters 
{"authenticity_token"=>"m/QBN85+5Kj+Qewtl29mBl5kBtSBr1+Ixv4jxTq6Rfk=", 
"scr"=>{"id"=>"as", 
"description"=>"sa"}, 
"commit"=>"Save"} 

레일즈가 Scr 클래스의 인스턴스를 생성 할 수 없다고 본다. 왜?

+1

'@src ='를 @scr ='(typo) –

답변

3
def save_scr 
    @scr = Scr.new(params[:scr]) 
    puts "==============================" 
    @a = params[:scr] 
    puts @a 
    puts "==============================" 
    @scr.save 
end 
관련 문제