I've already started this topic here too because I'm not sure which one gem of those both refers to that problem. Let's consider following example:
# .../pitches_controller.rb
def upload_avatar
pitch = Pitch.find(params[:id])
form = PitchAvatarForm.new(pitch)
if form.validate(pitch_avatar_params)
form.save
on_pitch_avatar_upload_succeeded(form)
else
on_pitch_avatar_upload_fialed(form)
end
end
On each form#save execution it couses following error:
form.save
NoMethodError: undefined method `sub' for nil:NilClass
from /Users/rapide/.rvm/gems/ruby-2.3.0@bttf/gems/paperclip-4.2.2/lib/paperclip/storage/s3.rb:255:in `s3_object'
I fixed this issue by assigning attributes to the pitch before creating the form but it looks like an ugly hack. Any idea how to solve this in better way?
# .../pitches_controller.rb - temporary solution
def upload_avatar
pitch = Pitch.find(params[:id])
pitch.assign_attributes(pitch_avatar_params)
form = PitchAvatarForm.new(pitch)
if form.validate(pitch_avatar_params)
form.save
on_pitch_avatar_upload_succeeded(form)
else
on_pitch_avatar_upload_fialed(form)
end
end
Complete Description of Issue
I've already started this topic here too because I'm not sure which one gem of those both refers to that problem. Let's consider following example:
On each
form#save
execution it couses following error:I fixed this issue by assigning attributes to the pitch before creating the form but it looks like an ugly hack. Any idea how to solve this in better way?
Expected behavior
Executing
form#save
should save my file properly.System configuration
Reform version: 2.2.4
Full Backtrace of Exception (if any)