I’m using Attachment fu to allow file attachments to my TimeOff model
(for an employee program). An attachment is only optional for the
app, so some TimeOffs will have files attached and some won’t.
The problem is I can’t delete a TimeOff if there is no file present.
However, it does delete fine if there is a file.
Here is my controller destroy action:
def destroy
@time_off = TimeOff.find(params[:id])
id = @time_off.employee_id
@time_off.destroy
redirect_to :action => 'list', :id => id
end
Here is my error:
TypeError in Time offsController#destroy
can’t convert nil into String
RAILS_ROOT: script/…/config/…
Application Trace | Framework Trace | Full Trace
vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/
file_system_backend.rb:21:in join' vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/ file_system_backend.rb:21:in
full_filename’
vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/
file_system_backend.rb:63:in destroy_file' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/callbacks.rb:333:in
send’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/callbacks.rb:333:in callback' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/callbacks.rb:330:in
each’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/callbacks.rb:330:in callback' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/callbacks.rb:322:in
destroy_without_transactions’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/transactions.rb:125:in destroy' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/connection_adapters/abstract/database_statements.rb: 59:in
transaction’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/transactions.rb:95:in transaction' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/transactions.rb:121:in
transaction’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/transactions.rb:125:in destroy' app/controllers/time_offs_controller.rb:52:in
destroy’