Note that there are some explanatory texts on larger screens.

plurals
  1. PORails validation error: Account can not be blank
    primarykey
    data
    text
    <p>I am receiving the following error when running my rake task:</p> <pre><code>Validation failed: Account can't be blank </code></pre> <p>This is the bit of code throwing the error:</p> <pre><code> test.entries.create!({ :account_id =&gt; account.id, :date =&gt; date }) </code></pre> <p>My validation for both <code>test</code> and <code>entries</code> only validates the presence of <code>:account_id</code>. I know the error message is humanized to remove the <code>.id</code>, but it is obvious that <code>:account_id</code> exists. What am I missing here? I am using rails 3.1.14.</p> <p>EDIT:</p> <p>The full trace error is below-</p> <pre><code>rake aborted! Validation failed: Account can't be blank /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/validations.rb:56:in `save!' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/attribute_methods/dirty.rb:33:in `save!' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/transactions.rb:264:in `block in save!' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/transactions.rb:208:in `transaction' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/transactions.rb:311:in `with_transaction_returning_status' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/transactions.rb:264:in `save!' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/associations/has_many_through_association.rb:85:in `save_through_record' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/associations/has_many_through_association.rb:52:in `insert_record' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/autosave_association.rb:348:in `block in save_collection_association' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/autosave_association.rb:341:in `each' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/autosave_association.rb:341:in `save_collection_association' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/autosave_association.rb:191:in `block in add_autosave_association_callbacks' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/autosave_association.rb:161:in `instance_eval' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/autosave_association.rb:161:in `block in define_non_cyclic_method' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:413:in `_run__3251750978270077373__create__1709181034843668520__callbacks' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:405:in `__run_callback' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:385:in `_run_create_callbacks' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:81:in `run_callbacks' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/callbacks.rb:268:in `create' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/persistence.rb:348:in `create_or_update' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/callbacks.rb:264:in `block in create_or_update' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:447:in `_run__3251750978270077373__save__1709181034843668520__callbacks' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:405:in `__run_callback' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:385:in `_run_save_callbacks' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:81:in `run_callbacks' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/callbacks.rb:264:in `create_or_update' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/persistence.rb:104:in `save!' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/validations.rb:56:in `save!' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/attribute_methods/dirty.rb:33:in `save!' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/transactions.rb:264:in `block in save!' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/transactions.rb:208:in `transaction' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/transactions.rb:311:in `with_transaction_returning_status' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/transactions.rb:264:in `save!' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/associations/has_many_association.rb:14:in `insert_record' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/associations/collection_association.rb:436:in `block (2 levels) in create_record' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/associations/collection_association.rb:344:in `add_to_target' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/associations/collection_association.rb:434:in `block in create_record' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/associations/collection_association.rb:149:in `block in transaction' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/transactions.rb:208:in `transaction' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/associations/collection_association.rb:148:in `transaction' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/associations/collection_association.rb:433:in `create_record' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/associations/collection_association.rb:123:in `create!' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/activerecord-3.2.14/lib/active_record/associations/collection_proxy.rb:46:in `create!' /Users/Luigi/Desktop/Projects/test/lib/tasks/createnew.rake:179:in `block (5 levels) in &lt;top (required)&gt;' /Users/Luigi/Desktop/Projects/test/lib/tasks/createnew.rake:165:in `each' /Users/Luigi/Desktop/Projects/test/lib/tasks/createnew.rake:165:in `block (4 levels) in &lt;top (required)&gt;' /Users/Luigi/Desktop/Projects/test/lib/tasks/createnew.rake:90:in `upto' /Users/Luigi/Desktop/Projects/test/lib/tasks/createnew.rake:90:in `block (3 levels) in &lt;top (required)&gt;' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain' /Users/Luigi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain' /Users/Luigi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/gems/rake-0.9.2.2/bin/rake:33:in `&lt;top (required)&gt;' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/bin/rake:19:in `load' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/bin/rake:19:in `&lt;main&gt;' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/bin/ruby_noexec_wrapper:14:in `eval' /Users/Luigi/.rvm/gems/ruby-1.9.3-p429@test/bin/ruby_noexec_wrapper:14:in `&lt;main&gt;' </code></pre> <p>The particular line of code mentioned above is on line 179, and it is inside a loop that starts on line 165, which is inside a loop that starts on line 90.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload