paperclip and functional test problems (rails) - ruby-on-rails

I'm having problems with my functional tests involving paperclip and attachments. I'm using the fixture_file_upload method to fake the attachment uploads.
My tests intermittently give me the error below (or one similar to it), generated by a factory_girl call to create the object containing the attachment, which is in my setup block.
#asset = Factory(:asset, :item => fixture_file_upload('test.png','image/png'))
However, even though the setup block is run for every test in the final, this error isn't generated for every test. Running a single test in the file (which calls the setup block and the above method) runs fine. It's just with multiple tests that I get the error (and it's not always the same depending on how many tests are run.) So there's some sort of conflict with multiple calls to fixture_file_upload.
Anyone have any ideas of how to get around this problem? Thank you.
Errno::ENOENT: No such file or directory - /var/folders/cm/cmC3aPSEE7i3lzQGMwM2Kk+++TI/-Tmp-/stream,17938,0,17938,0
/Users/francis/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/fileutils.rb:1407:in `stat'
/Users/francis/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/fileutils.rb:1407:in `block in fu_each_src_dest'
/Users/francis/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/fileutils.rb:1423:in `fu_each_src_dest0'
/Users/francis/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/fileutils.rb:1405:in `fu_each_src_dest'
/Users/francis/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/fileutils.rb:504:in `mv'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip/storage.rb:42:in `block in flush_writes'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip/storage.rb:38:in `each'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip/storage.rb:38:in `flush_writes'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:144:in `save'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip.rb:384:in `block in save_attached_files'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip.rb:377:in `block in each_attachment'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip.rb:376:in `each'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip.rb:376:in `each_attachment'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/paperclip-2.3.3/lib/paperclip.rb:383:in `save_attached_files'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb:429:in `_run_save_callbacks'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/callbacks.rb:290:in `create_or_update'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/persistence.rb:53:in `save!'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/validations.rb:46:in `save!'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:240:in `block in save!'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:287:in `block in with_transaction_returning_status'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:202:in `transaction'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:285:in `with_transaction_returning_status'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activerecord-3.0.0.beta4/lib/active_record/transactions.rb:240:in `save!'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/factory_girl-1.3.1/lib/factory_girl/proxy/create.rb:6:in `result'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:326:in `run'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:270:in `create'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:301:in `default_strategy'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/factory_girl-1.3.1/lib/factory_girl.rb:20:in `Factory'
/Users/francis/dev/r3/works/test/functional/assets_controller_test.rb:13:in `block in <class:AssetsControllerTest>'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb:433:in `_run_setup_callbacks'
/Users/francis/.rvm/gems/ruby-1.9.2-preview3/gems/activesupport-3.0.0.beta4/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

Looks like this issue: https://github.com/thoughtbot/paperclip/issues/270. There is a possible workaround in the article.

Related

Resetting & reseeding DB using rake task

Using the code below to reset & reseed the DB
task init: [:environment, 'db:migrate:reset', 'db:seed']
db:seed creates a few users & few objects. It also updates role for few users.
db:seed throws following error NoMethodError: undefined method 'role' for User.
There is a migration file which adds role column to User table.
Unable to resolve this. Tries to write separate task for db:seed. Tried following
task init: [:environment, 'db:migrate:reset', 'db:seed'] do
Rake::Task['db:seed'].invoke
end
Same error as before. Why is column from migration file isn't loaded for db:seed or I am missing something here?
Error log:
NoMethodError: undefined method `role' for #<User:0x00007fd5ecb239e0>
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activemodel-6.0.3.2/lib/active_model/attribute_methods.rb:432:in `method_missing'
/Users/Desktop/rails_app/app/models/user.rb:17:in `update_role'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:428:in `block in make_lambda'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:200:in `block (2 levels) in halting'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:605:in `block (2 levels) in default_terminator'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:604:in `catch'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:604:in `block in default_terminator'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:201:in `block in halting'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `block in invoke_before'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `each'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `invoke_before'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:134:in `run_callbacks'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:825:in `_run_validation_callbacks'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activemodel-6.0.3.2/lib/active_model/validations/callbacks.rb:117:in `run_validations!'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activemodel-6.0.3.2/lib/active_model/validations.rb:337:in `valid?'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/validations.rb:68:in `valid?'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/validations.rb:84:in `perform_validations'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/validations.rb:53:in `save!'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/transactions.rb:318:in `block in save!'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/transactions.rb:212:in `transaction'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/transactions.rb:318:in `save!'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/suppressor.rb:48:in `save!'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/persistence.rb:55:in `create!'
/Users/Desktop/rails_app/app/services/init_data:6:in `process'
/Users/Desktop/rails_app/db/seeds.rb:3:in `<main>'
Using db:reset solved the issue. i.e.
task init: [:environment, 'db:reset']
db:reset executes db:drop, db:setup.
db:setup executes db:schema:load whereas db:migrate:reset executes db:migrate. And db:schema:load is faster than db:migrate.
Not sure why db:migrate causes the issue.
As Sergio suggested stale cache could be the cause. And his suggestion in the comments User.reset_column_information loads all the columns.

SocketError: getaddrinfo while running heroku run rake db:seed on a Heroku App-Rails4

I am using Rails4 and ruby2.0.0. I pushed my app on Heroku & I m getting this error when I run heroku run rake db:seed
Running rake db:seed attached to terminal... up, run.6298
Rendered devise/mailer/confirmation_instructions.html.erb (1.8ms)
Sent mail to xyz#gmail.com (29.3ms) rake aborted! SocketError:
getaddrinfo: Temporary failure in name resolution
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in deliver!'
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/message.rb:2129:in
do_delivery'
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/message.rb:232:in
block in deliver'
/app/vendor/bundle/ruby/2.0.0/gems/actionmailer-4.0.1/lib/action_mailer/base.rb:456:in
block in deliver_mail'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/notifications.rb:159:in
block in instrument'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/notifications/instrumenter.rb:20:in
instrument'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/notifications.rb:159:in
instrument'
/app/vendor/bundle/ruby/2.0.0/gems/actionmailer-4.0.1/lib/action_mailer/base.rb:454:in
deliver_mail'
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/message.rb:232:in
deliver'
/app/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/models/authenticatable.rb:173:in
send_devise_notification'
/app/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/models/confirmable.rb:102:in
send_confirmation_instructions'
/app/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/models/confirmable.rb:158:in
send_on_create_confirmation_instructions'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/callbacks.rb:386:in
_run__3822695918417406283__create__callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/callbacks.rb:80:in
run_callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/callbacks.rb:306:in
create_record'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/timestamp.rb:57:in
create_record'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/persistence.rb:477:in
create_or_update'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/callbacks.rb:302:in
block in create_or_update'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/callbacks.rb:383:in
_run__3822695918417406283__save__callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/callbacks.rb:80:in
run_callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/callbacks.rb:302:in
create_or_update'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/persistence.rb:106:in
save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/validations.rb:51:in
save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/attribute_methods/dirty.rb:32:in
save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:270:in block (2 levels) in save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:326:inblock in with_transaction_returning_status'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in
block in transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in
within_new_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in
transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:209:intransaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:323:in with_transaction_returning_status'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:270:inblock in save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:281:in rollback_active_record_state!'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:269:insave' /app/db/seeds.rb:8:in <top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:inload'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in block in load'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:inload_dependency'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in load'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/engine.rb:540:in
load_seed'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/tasks/database_tasks.rb:154:in
load_seed'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/railties/databases.rake:181:in
block (2 levels) in ' Tasks: TOP => db:seed (See full
trace by running task with --trace)
You are creating devise users in your seed file. Devise automatically sends some emails E.g. email_confirmation.
So you have to set up a proper ActionMailer for production Environment. You might be using an another heroku service for that. E.g mailgun
You can also bypass devise email_confirmation in your seed file.

MissingTemplate exception raised in mailer using delayed job

I use delayed job to carry out background tasks in my app. It does some stuff and then sends a mail. This is an example of the code block preformed as a delayed job.
def task
# do stuff
AppMailer.post.some_template(#variable)
end
This has been working fine, I have a template in the correct directory some_template.text.plain.erb. I have started seeing this raise a MissingTemplate exception and this stops the delayed job and tries again after a given time (as expected when exceptions are raised in delayed job). Some cases this will fail 2 or 3 times and then deliver successfully, other cases there will be no exception raised. How can a template not exist then be found successfully upon the next attempt?
The error is looking for a template .erb is the plain.text.erb causing this problem. Any ideas why this is causing an intermittent problem? I have tried wrapping the sending of the mail in a rescue block as I would rather not send the mail than raise an exception.
def task
# do stuff
begin
AppMailer.post.some_template(#variable)
rescue ActionView::MissingTemplate => e
# do stuff
end
end
But the exception is still raised. Does delayed job do anything that might stop this rescue block working?
Here is the stack trace
Error:
Missing template app_mailer/some_template.erb in view path app/views:vendor/plugins/tolk/app/views
/data/app/shared/bundled_gems/ruby/1.8/gems/actionpack-2.3.14/lib/action_view/paths.rb:74:in `find_template'
/data/app/shared/bundled_gems/ruby/1.8/gems/actionpack-2.3.14/lib/action_view/base.rb:264:in `render'
/data/app/shared/bundled_gems/ruby/1.8/gems/actionmailer-2.3.14/lib/action_mailer/base.rb:600:in `render'
/data/app/shared/bundled_gems/ruby/1.8/gems/actionmailer-2.3.14/lib/action_mailer/base.rb:586:in `render_message'
/data/app/shared/bundled_gems/ruby/1.8/gems/actionmailer-2.3.14/lib/action_mailer/base.rb:526:in `create!'
/data/app/shared/bundled_gems/ruby/1.8/gems/actionmailer-2.3.14/lib/action_mailer/base.rb:485:in `initialize'
/data/app/shared/bundled_gems/ruby/1.8/gems/actionmailer-2.3.14/lib/action_mailer/base.rb:427:in `new'
/data/app/shared/bundled_gems/ruby/1.8/gems/actionmailer-2.3.14/lib/action_mailer/base.rb:427:in `method_missing'
/data/app/releases/20121127213524/app/models/mail_delivery.rb:55:in `send'
/data/app/releases/20121127213524/app/models/mail_delivery.rb:55:in `serialize_mail'
/data/app/shared/bundled_gems/ruby/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:178:in `send'
/data/app/shared/bundled_gems/ruby/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:178:in `evaluate_method'
/data/app/shared/bundled_gems/ruby/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:166:in `call'
/data/app/shared/bundled_gems/ruby/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:93:in `run'
/data/app/shared/bundled_gems/ruby/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:92:in `each'
/data/app/shared/bundled_gems/ruby/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:92:in `send'
/data/app/shared/bundled_gems/ruby/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:92:in `run'
/data/app/shared/bundled_gems/ruby/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:276:in `run_callbacks'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/callbacks.rb:344:in `callback'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/callbacks.rb:265:in `create'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/base.rb:2927:in `create_or_update_without_callbacks'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/callbacks.rb:250:in `create_or_update'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/base.rb:2577:in `save_without_validation'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/validations.rb:1089:in `save_without_dirty'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/dirty.rb:79:in `save_without_transactions'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/transactions.rb:229:in `send'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/transactions.rb:229:in `with_transaction_returning_status'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/transactions.rb:182:in `transaction_without_trace_ActiveRecord_self_name_transaction'
/data/app/shared/bundled_gems/ruby/1.8/gems/newrelic_rpm-3.4.0.1/lib/new_relic/agent/method_tracer.rb:491:in `transaction'
/data/app/shared/bundled_gems/ruby/1.8/gems/newrelic_rpm-3.4.0.1/lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
/data/app/shared/bundled_gems/ruby/1.8/gems/newrelic_rpm-3.4.0.1/lib/new_relic/agent/method_tracer.rb:486:in `transaction'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/transactions.rb:228:in `with_transaction_returning_status'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/transactions.rb:196:in `save'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/transactions.rb:196:in `save'
/data/app/shared/bundled_gems/ruby/1.8/gems/activerecord-2.3.14/lib/active_record/base.rb:727:in `create'
/data/app/releases/20121127213524/app/models/mail_delivery.rb:88:in `method_missing'
/data/app/releases/20121127213524/lib/job_manifest.rb:670:in `notify_user_of_upload_without_audit'
/data/app/releases/20121127213524/lib/job_manifest.rb:6:in `send'
/data/app/releases/20121127213524/lib/job_manifest.rb:6:in `notify_user_of_upload_with_audit'
/data/app/releases/20121127213524/lib/job_manifests/app_send_job.rb:43:in `notify_user_of_upload'
/data/app/releases/20121127213524/lib/job_manifests/app_send_job.rb:43:in `extended'
/data/app/releases/20121127213524/lib/job_manifest.rb:102:in `preflight_completed_changed_delayed'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/performable_method.rb:35:in `send'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/performable_method.rb:35:in `perform'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/backend/base.rb:74:in `invoke_job'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/worker.rb:122:in `run'
/usr/lib64/ruby/1.8/timeout.rb:67:in `timeout'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/worker.rb:122:in `run'
/usr/lib64/ruby/1.8/benchmark.rb:308:in `realtime'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/worker.rb:121:in `run'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/worker.rb:173:in `reserve_and_run_one_job'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/worker.rb:106:in `work_off'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/worker.rb:105:in `times'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/worker.rb:105:in `work_off'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/worker.rb:80:in `start'
/usr/lib64/ruby/1.8/benchmark.rb:308:in `realtime'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/worker.rb:79:in `start'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/worker.rb:76:in `loop'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/worker.rb:76:in `start'
/data/app/shared/bundled_gems/ruby/1.8/gems/delayed_job-2.0.7/lib/delayed/command.rb:100:in `run'
(eval):1
/data/app/current/script/runner:3:in `eval'
/data/app/shared/bundled_gems/ruby/1.8/gems/rails-2.3.14/lib/commands/runner.rb:48
/data/app/current/script/runner:3:in `require'
/data/app/current/script/runner:3
I know there are a couple of problems here but any advice would be appreciated.
It's hard to say from just what you've posted but with Delayed Job Mailer errors I would typically check for two things:
That your workers are being restarted when you deploy new code, so that they are using the latest version of your app.
Are the arguments you're passing to the Mailer method used to retrieve records? If so be careful that records don't change or disappear between the job being created and the job being worked. Consider passing in exactly the attributes you need to build the mail if this is the case.

Active record Undefined method `eq'

I've table tournaments with fields user_id,question_id,answer and I created key like
Primary key (user_id, question_id)
But when I want to change answer field like this:
t=Tournament.where('question_id=200').first
t.answer=2
t.save
I've got error:
NoMethodError: undefined method `eq' for nil:NilClass
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.4/lib/active_support/whiny_nil.rb:48:in `method_missing'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/persistence.rb:255:in `update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/locking/optimistic.rb:77:in `update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/attribute_methods/dirty.rb:68:in `update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/timestamp.rb:60:in `update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/callbacks.rb:285:in `block in update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:413:in `_run_update_callbacks'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/callbacks.rb:285:in `update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/persistence.rb:246:in `create_or_update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/callbacks.rb:277:in `block in create_or_update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:423:in `_run_save_callbacks'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/callbacks.rb:277:in `create_or_update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/persistence.rb:56:in `save!'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/validations.rb:49:in `save!'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/transactions.rb:245:in `block in save!'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/transactions.rb:207:in `transaction'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/transactions.rb:245:in `save!'
from (irb):4
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.4/lib/rails/commands/console.rb:44:in `start'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.4/lib/rails/commands/console.rb:8:in `start'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.4/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
Can anyone help me?
Thanks.
Did you modify your tables at all from a standard Rails genearated one?
if so, see undefined method `eq' for nil:NilClass with rails 3 and ruby enterprise on ubuntu hardy

Active record destroy give me "Can't dup NilClass"

I am using ruby 1.8.7 and rails 2.3.5 and I am getting this weird message "Can't dup NilClass" when I try to run the code below
rr = Node.find(params[:id])
puts rr.inspect
rr.destroy
The application prints out the correct information about the node, when I try to do the exact same thing in script/console it works fine!!! I have no clue what is going on ..
I upgraded my application to rails 2.3.8 but no luck what so ever :(
Please help,
Edit:
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2184:in `dup'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2184:in `scoped_methods'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2188:in `current_scoped_methods'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2178:in `scope'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1543:in `find_every'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1505:in `find_initial'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:613:in `find'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/has_one_association.rb:80:in `find_target'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_proxy.rb:239:in `load_target'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_proxy.rb:112:in `reload'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1250:in `acl'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1460:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1460:in `has_one_dependent_destroy_for_acl'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in `evaluate_method'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in `call'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:93:in `run'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `each'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `run'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:276:in `run_callbacks'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:344:in `callback'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:336:in `destroy_without_transactions'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:229:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:229:in `with_transaction_returning_status'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:in `transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:228:in `with_transaction_returning_status'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:192:in `destroy'
/home/wael/public_html/app/models/node.rb:355:in `destroy'
Wa'el
Is it possibly somehow confusing your Node class with this one?
http://apidock.com/ruby/REXML/Node

Resources