0

How does it come current_user.some_assoc.new doesn't work any more? Therefore some_assoc.new(:user_id => current_user.id) works perfectly while in my understanding it should do the same?

I will though get the error message NoMethodError: undefined method 'new' for nil:NilClass on the current_user.some_assoc.new call.

I just found this answer: https://stackoverflow.com/a/4954469/744230 where the first two calls do not work for me.

edit:

I just tried something out and found that current_user.some_assocs.new would work if the user model has a has_many :some_assocs, while has_one :some_assoc will not allow you to create some_assoc this way.

Community
  • 1
  • 1
Maxim Zubarev
  • 2,403
  • 2
  • 29
  • 48

0 Answers0