Guest User

Untitled

a guest
May 27th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. I can save one Outline and it works fine, but if two objects are being save, target turns up nil.
  2.  
  3. ## controller action
  4.  
  5. if params.has_key?(:new_outline_items)
  6. params[:new_outline_items].each do |attributes|
  7. @current_course.outlines << Outline.new(attributes.merge!(:account_id => @current_account.id))
  8. end
  9. end
  10. @current_course.save!
  11.  
  12. ## Model
  13.  
  14. after_create :set_outlined
  15.  
  16. def set_outlined
  17. target.update_attribute(:outlined,true)
  18. end
  19.  
  20. ## error [plain]
  21. NoMethodError (You have a nil object when you didn't expect it!
  22. The error occurred while evaluating nil.outlined=):
  23. /app/models/outline.rb:10:in `set_outlined'
Add Comment
Please, Sign In to add comment