I see a few things going on here.
The fact that it says undefined method
on line 13 is because the @event variable is not being assigned, so assigns(:event)
is returning nil.
You should check out why that is happening, maybe you have some authentication that is preventing you from updating the record? Maybe you can check out the testing logs to see what is actually going on.
It could be because you are using let()
which is lazy and the record is not actually available yet when you try to search for it, but I'm not completely sure. You could try using let!()
and see if that helps.
With regards to the actual usage of strong parameters, if you only want title to be assignable you need to do something like the following:
params.require(:event).permit(:title)
If you use permit!
, the event parameters hash and every subhash is whitelisted.