See here :id => @document
@document
is the variable that contains nil
however this should contain some id
(like 1,2 or whatever) of required record check it in your controller and once you will fix this issue sure this error will be resolved.