New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

has_many NoMethodError: undefined method `name' for nil:NilClass -- on the ActiveScaffold column #380

Closed
markmcdonald51 opened this Issue Jan 12, 2015 · 10 comments

Comments

Projects
None yet
4 participants
@markmcdonald51

markmcdonald51 commented Jan 12, 2015

Hello all,
I have a very simple model for Category and Entity

class Entity < ActiveRecord::Base
belongs_to :category
end

class Category < ActiveRecord::Base
has_many :entities
has_many :phrases
validates :name, presence: :true, uniqueness: true
end

which in AS when i am trying to add in more categories it errors out with this:

NoMethodError: undefined method `name' for nil:NilClass -- on the ActiveScaffold column

This seems like a pretty simple setup but im not sure as to why there would be any errors.

Started PUT "/categories/1" for 127.0.0.1 at 2015-01-12 08:41:47 -0500
Processing by CategoriesController#update as JS
Parameters: {"utf8"=>"✓", "record"=>{"name"=>"Agriculture, Forestry, Fishing", "description"=>"test ", "entities"=>{"0"=>"", "1421069919306"=>{"name"=>""}, "12"=>{"name"=>"3M ", "id"=>"12"}, "329"=>{"name"=>"A. Schulman ", "id"=>"329"}}, "phrases"=>{"0"=>"", "1421069920023"=>{"text_phrase"=>"test", "position"=>""}}}, "associated_id"=>"329", "commit"=>"Update", "id"=>"1"}
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = ? LIMIT 1 ["id", 1] begin transaction
Entity Load (0.1ms) SELECT "entities".* FROM "entities" WHERE "entities"."category_id" = ? [["category_id", 1]]
Entity Load (0.1ms) SELECT "entities".* FROM "entities" WHERE "entities"."id" = ? LIMIT 1 [["id", 12]]
Entity Load (4.2ms) SELECT "entities".* FROM "entities" WHERE "entities"."id" = ? LIMIT 1 [["id", 329]]
NoMethodError: undefined method `name' for nil:NilClass -- on the ActiveScaffold column = :entities for #<Category id: 1, name: "Agriculture, Forestry, Fishing", description: "test ", created_at: "2015-01-04 17:39:56", updated_at: "2015-01-04 18:03:25">
(0.1ms) rollback transaction
Completed 500 Internal Server Error in 50ms

NoMethodError (undefined method name' for nil:NilClass): activerecord (4.1.0) lib/active_record/associations/has_many_association.rb:79:incached_counter_attribute_name'
activerecord (4.1.0) lib/active_record/associations/has_many_association.rb:75:in has_cached_counter?' active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:67:inhas_many_counter_cache_hack?'
active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:132:in update_column_from_params' active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:111:inblock in update_record_from_params'
active_scaffold (3.4.12) lib/active_scaffold/data_structures/action_columns.rb:86:in block in each' active_scaffold (3.4.12) lib/active_scaffold/data_structures/action_columns.rb:74:ineach'
active_scaffold (3.4.12) lib/active_scaffold/data_structures/action_columns.rb:74:in each' active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:101:inupdate_record_from_params'
active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb:107:in block in update_save' activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:211:inblock in transaction'
activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:219:in within_new_transaction' activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:211:intransaction'
activerecord (4.1.0) lib/active_record/transactions.rb:208:in transaction' active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb:106:inupdate_save'
active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb💯in do_update' active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb:14:inupdate'
actionpack (4.1.0) lib/action_controller/metal/implicit_render.rb:4:in send_action' actionpack (4.1.0) lib/abstract_controller/base.rb:189:inprocess_action'
actionpack (4.1.0) lib/action_controller/metal/rendering.rb:10:in process_action' actionpack (4.1.0) lib/abstract_controller/callbacks.rb:20:inblock in process_action'
activesupport (4.1.0) lib/active_support/callbacks.rb:113:in call' activesupport (4.1.0) lib/active_support/callbacks.rb:113:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'

Any help is very appreciated. --mark

@scambra

This comment has been minimized.

Show comment
Hide comment
@scambra

scambra Jan 12, 2015

Member

The error notified by ActiveScaffold usually includes column name, such as:
NoMethodError: undefined method `name' for nil:NilClass -- on the ActiveScaffold column = :[column name] for ...

Can you post that full line?
Also, try in rails console, replacing [column_name] with the column giving error:
Category.find(1).association(:[column_name]).send(:cached_counter_attribute_name)
Category.find(1).association(:[column_name]).send(:has_cached_counter?)

Member

scambra commented Jan 12, 2015

The error notified by ActiveScaffold usually includes column name, such as:
NoMethodError: undefined method `name' for nil:NilClass -- on the ActiveScaffold column = :[column name] for ...

Can you post that full line?
Also, try in rails console, replacing [column_name] with the column giving error:
Category.find(1).association(:[column_name]).send(:cached_counter_attribute_name)
Category.find(1).association(:[column_name]).send(:has_cached_counter?)

@markmcdonald51

This comment has been minimized.

Show comment
Hide comment
@markmcdonald51

markmcdonald51 Jan 12, 2015

Hi Sergio,

THanks for the reply.

Hmmm, so something like:

irb(main):019:0> Category.find(6)
Category Load (0.3ms) SELECT "categories".* FROM "categories" WHERE
"categories"."id" = ? LIMIT 1 [["id", 6]]
=> #<Category id: 6, name: "Finance, Insurance, Banks, Real Estate",
description: "Each insured state nonmember bank must monitor con...",
created_at: "2015-01-04 17:39:57", updated_at: "2015-01-04 18:19:04">

irb(main):020:0> Category.find(6).entities
Category Load (0.3ms) SELECT "categories".* FROM "categories" WHERE
"categories"."id" = ? LIMIT 1 [["id", 6]]
Entity Load (0.2ms) SELECT "entities".* FROM "entities" WHERE
"entities"."category_id" = ? [["category_id", 6]]
=> #<ActiveRecord::Associations::CollectionProxy [#<Entity id: 2, name:
"AFLAC ", aasm_state: "querying", category_id: 6, created_at: "2015-01-04
17:33:48", updated_at: "2015-01-05 20:33:29">]>
irb(main):021:0>

--> Category.find(6).entities(:name).send would throw an error as it is a
Category has a 'has_many' relationship with Entities.

this just causes an error:
Category.find(1).association(:[column_name]).send(:cached_counter_attribute_name)

Not sure what exactly you are asking here.

Started PUT "/categories/6" for 127.0.0.1 at 2015-01-12 10:21:52 -0500
Processing by CategoriesController#update as JS
Parameters: {"utf8"=>"✓", "record"=>{"name"=>"Finance, Insurance, Banks,
Real Estate", "description"=>"Each insured state nonmember bank must
monitor conditions in the real estate .... Type and frequency of financial
statements, including requirements for ... that appropriate loan-to-value
limits vary not only among categories of real estate ... and sound banking
practices and part of a clearly defined and well-documented ...",
"entities"=>{"0"=>"", "2"=>{"name"=>"AFLAC ", "id"=>"2"},
"1421076101103"=>{"name"=>""}, "329"=>{"name"=>"A. Schulman ",
"id"=>"329"}}, "phrases"=>{"0"=>"", "1"=>{"text_phrase"=>""breached my
contract"", "position"=>"1", "id"=>"1"}, "2"=>{"text_phrase"=>""screwed
me out of"", "position"=>"2", "id"=>"2"},
"1421076101520"=>{"text_phrase"=>"", "position"=>""}}},
"associated_id"=>"329", "commit"=>"Update", "id"=>"6"}
Category Load (1.7ms) SELECT "categories".* FROM "categories" WHERE
"categories"."id" = ? LIMIT 1 ["id", 6] begin transaction
Entity Load (0.2ms) SELECT "entities".* FROM "entities" WHERE
"entities"."category
_id" = ? [["category_id", 6]]
Entity Load (0.1ms) SELECT "entities".* FROM "entities" WHERE
"entities"."id" = ? LIMIT 1 [["id", 329]]
NoMethodError: undefined method `name' for nil:NilClass -- on the
ActiveScaffold column = :entities for #<Category id: 6, name: "Finance,
Insurance, Banks, Real Estate", description: "Each insured state nonmember
bank must monitor con...", created_at: "2015-01-04 17:39:57", updated_at:
"2015-01-04 18:19:04">
(0.1ms) rollback transaction
Completed 500 Internal Server Error in 20ms

NoMethodError (undefined method name' for nil:NilClass): activerecord (4.1.0) lib/active_record/associations/has_many_association.rb:79:incached_counter_attribute_name'
activerecord (4.1.0)
lib/active_record/associations/has_many_association.rb:75:in
has_cached_counter?' active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:67:inhas_many_counter_cache_hack?'
active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:132:in
update_column_from_params' active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:111:inblock in update_record_from_params'
active_scaffold (3.4.12)
lib/active_scaffold/data_structures/action_columns.rb:86:in block in each' active_scaffold (3.4.12) lib/active_scaffold/data_structures/action_columns.rb:74:ineach'
active_scaffold (3.4.12)
lib/active_scaffold/data_structures/action_columns.rb:74:in each' active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:101:inupdate_record_from_params'
active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb:107:in
block in update_save' activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:211:inblock in transaction'
activerecord (4.1.0)
lib/active_record/connection_adapters/abstract/database_statements.rb:219:in
within_new_transaction' activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:211:intransaction'
activerecord (4.1.0) lib/active_record/transactions.rb:208:in
transaction' active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb:106:inupdate_save'
active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb💯in
do_update' active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb:14:inupdate'
actionpack (4.1.0) lib/action_controller/metal/implicit_render.rb:4:in
send_action' actionpack (4.1.0) lib/abstract_controller/base.rb:189:inprocess_action'
actionpack (4.1.0) lib/action_controller/metal/rendering.rb:10:in
process_action' actionpack (4.1.0) lib/abstract_controller/callbacks.rb:20:inblock in
process_action'
activesupport (4.1.0) lib/active_support/callbacks.rb:113:in call' activesupport (4.1.0) lib/active_support/callbacks.rb:113:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:229:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:229:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:229:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:229:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:86:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:86:in
run_callbacks' actionpack (4.1.0) lib/abstract_controller/callbacks.rb:19:inprocess_action'
actionpack (4.1.0) lib/action_controller/metal/rescue.rb:29:in
process_action' actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:31:inblock in process_action'
activesupport (4.1.0) lib/active_support/notifications.rb:159:in block in instrument' activesupport (4.1.0) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (4.1.0) lib/active_support/notifications.rb:159:in
instrument' actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:30:inprocess_action'
actionpack (4.1.0) lib/action_controller/metal/params_wrapper.rb:250:in
process_action' activerecord (4.1.0) lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
actionpack (4.1.0) lib/abstract_controller/base.rb:136:in process' actionview (4.1.0) lib/action_view/rendering.rb:30:inprocess'
actionpack (4.1.0) lib/action_controller/metal.rb:195:in dispatch' actionpack (4.1.0) lib/action_controller/metal/rack_delegation.rb:13:indispatch'
actionpack (4.1.0) lib/action_controller/metal.rb:231:in block in action' actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:80:incall'
actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:80:in
dispatch' actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:48:incall'
actionpack (4.1.0) lib/action_dispatch/journey/router.rb:71:in block in call' actionpack (4.1.0) lib/action_dispatch/journey/router.rb:59:ineach'
actionpack (4.1.0) lib/action_dispatch/journey/router.rb:59:in call' actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:676:incall'
rack (1.5.2) lib/rack/etag.rb:23:in call' rack (1.5.2) lib/rack/conditionalget.rb:35:incall'
rack (1.5.2) lib/rack/head.rb:11:in call' actionpack (4.1.0) lib/action_dispatch/middleware/params_parser.rb:27:incall'
actionpack (4.1.0) lib/action_dispatch/middleware/flash.rb:254:in call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:incontext'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in call' actionpack (4.1.0) lib/action_dispatch/middleware/cookies.rb:560:incall'
activerecord (4.1.0) lib/active_record/query_cache.rb:36:in call' activerecord (4.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:incall'
activerecord (4.1.0) lib/active_record/migration.rb:380:in call' actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call'
activesupport (4.1.0) lib/active_support/callbacks.rb:82:in
run_callbacks' actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:27:incall'
actionpack (4.1.0) lib/action_dispatch/middleware/reloader.rb:73:in call' actionpack (4.1.0) lib/action_dispatch/middleware/remote_ip.rb:76:incall'
actionpack (4.1.0)
lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' actionpack (4.1.0) lib/action_dispatch/middleware/show_exceptions.rb:30:incall'
railties (4.1.0) lib/rails/rack/logger.rb:38:in call_app' railties (4.1.0) lib/rails/rack/logger.rb:20:inblock in call'
activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in block in tagged' activesupport (4.1.0) lib/active_support/tagged_logging.rb:26:intagged'
activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in tagged' railties (4.1.0) lib/rails/rack/logger.rb:20:incall'
actionpack (4.1.0) lib/action_dispatch/middleware/request_id.rb:21:in
call' rack (1.5.2) lib/rack/methodoverride.rb:21:incall'
rack (1.5.2) lib/rack/runtime.rb:17:in call' activesupport (4.1.0) lib/active_support/cache/strategy/local_cache_middleware.rb:26:incall'
rack (1.5.2) lib/rack/lock.rb:17:in call' actionpack (4.1.0) lib/action_dispatch/middleware/static.rb:64:incall'
rack (1.5.2) lib/rack/sendfile.rb:112:in call' railties (4.1.0) lib/rails/engine.rb:514:incall'
railties (4.1.0) lib/rails/application.rb:144:in call' rack (1.5.2) lib/rack/lock.rb:17:incall'
rack (1.5.2) lib/rack/content_length.rb:14:in call' rack (1.5.2) lib/rack/handler/webrick.rb:60:inservice'

/home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:in
`service'

/home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in
run' /home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:inblock in start_thread'

Rendered
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.1.0/lib/action_dispatch/middleware/templates/rescues/_source.erb
(0.9ms)
Rendered
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.1.0/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb
(0.9ms)
Rendered
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.1.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb
(1.8ms)
Rendered
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.1.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb
(54.7ms)

On Mon, Jan 12, 2015 at 10:08 AM, Sergio Cambra notifications@github.com
wrote:

The error notified by ActiveScaffold usually includes column name, such as:
NoMethodError: undefined method `name' for nil:NilClass -- on the
ActiveScaffold column = :[column name] for ...

Can you post that full line?
Also, try in rails console, replacing [column_name] with the column giving
error:

Category.find(1).association(:[column_name]).send(:cached_counter_attribute_name)
Category.find(1).association(:[column_name]).send(:has_cached_counter?)


Reply to this email directly or view it on GitHub
#380 (comment)
.

markmcdonald51 commented Jan 12, 2015

Hi Sergio,

THanks for the reply.

Hmmm, so something like:

irb(main):019:0> Category.find(6)
Category Load (0.3ms) SELECT "categories".* FROM "categories" WHERE
"categories"."id" = ? LIMIT 1 [["id", 6]]
=> #<Category id: 6, name: "Finance, Insurance, Banks, Real Estate",
description: "Each insured state nonmember bank must monitor con...",
created_at: "2015-01-04 17:39:57", updated_at: "2015-01-04 18:19:04">

irb(main):020:0> Category.find(6).entities
Category Load (0.3ms) SELECT "categories".* FROM "categories" WHERE
"categories"."id" = ? LIMIT 1 [["id", 6]]
Entity Load (0.2ms) SELECT "entities".* FROM "entities" WHERE
"entities"."category_id" = ? [["category_id", 6]]
=> #<ActiveRecord::Associations::CollectionProxy [#<Entity id: 2, name:
"AFLAC ", aasm_state: "querying", category_id: 6, created_at: "2015-01-04
17:33:48", updated_at: "2015-01-05 20:33:29">]>
irb(main):021:0>

--> Category.find(6).entities(:name).send would throw an error as it is a
Category has a 'has_many' relationship with Entities.

this just causes an error:
Category.find(1).association(:[column_name]).send(:cached_counter_attribute_name)

Not sure what exactly you are asking here.

Started PUT "/categories/6" for 127.0.0.1 at 2015-01-12 10:21:52 -0500
Processing by CategoriesController#update as JS
Parameters: {"utf8"=>"✓", "record"=>{"name"=>"Finance, Insurance, Banks,
Real Estate", "description"=>"Each insured state nonmember bank must
monitor conditions in the real estate .... Type and frequency of financial
statements, including requirements for ... that appropriate loan-to-value
limits vary not only among categories of real estate ... and sound banking
practices and part of a clearly defined and well-documented ...",
"entities"=>{"0"=>"", "2"=>{"name"=>"AFLAC ", "id"=>"2"},
"1421076101103"=>{"name"=>""}, "329"=>{"name"=>"A. Schulman ",
"id"=>"329"}}, "phrases"=>{"0"=>"", "1"=>{"text_phrase"=>""breached my
contract"", "position"=>"1", "id"=>"1"}, "2"=>{"text_phrase"=>""screwed
me out of"", "position"=>"2", "id"=>"2"},
"1421076101520"=>{"text_phrase"=>"", "position"=>""}}},
"associated_id"=>"329", "commit"=>"Update", "id"=>"6"}
Category Load (1.7ms) SELECT "categories".* FROM "categories" WHERE
"categories"."id" = ? LIMIT 1 ["id", 6] begin transaction
Entity Load (0.2ms) SELECT "entities".* FROM "entities" WHERE
"entities"."category
_id" = ? [["category_id", 6]]
Entity Load (0.1ms) SELECT "entities".* FROM "entities" WHERE
"entities"."id" = ? LIMIT 1 [["id", 329]]
NoMethodError: undefined method `name' for nil:NilClass -- on the
ActiveScaffold column = :entities for #<Category id: 6, name: "Finance,
Insurance, Banks, Real Estate", description: "Each insured state nonmember
bank must monitor con...", created_at: "2015-01-04 17:39:57", updated_at:
"2015-01-04 18:19:04">
(0.1ms) rollback transaction
Completed 500 Internal Server Error in 20ms

NoMethodError (undefined method name' for nil:NilClass): activerecord (4.1.0) lib/active_record/associations/has_many_association.rb:79:incached_counter_attribute_name'
activerecord (4.1.0)
lib/active_record/associations/has_many_association.rb:75:in
has_cached_counter?' active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:67:inhas_many_counter_cache_hack?'
active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:132:in
update_column_from_params' active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:111:inblock in update_record_from_params'
active_scaffold (3.4.12)
lib/active_scaffold/data_structures/action_columns.rb:86:in block in each' active_scaffold (3.4.12) lib/active_scaffold/data_structures/action_columns.rb:74:ineach'
active_scaffold (3.4.12)
lib/active_scaffold/data_structures/action_columns.rb:74:in each' active_scaffold (3.4.12) lib/active_scaffold/attribute_params.rb:101:inupdate_record_from_params'
active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb:107:in
block in update_save' activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:211:inblock in transaction'
activerecord (4.1.0)
lib/active_record/connection_adapters/abstract/database_statements.rb:219:in
within_new_transaction' activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:211:intransaction'
activerecord (4.1.0) lib/active_record/transactions.rb:208:in
transaction' active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb:106:inupdate_save'
active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb💯in
do_update' active_scaffold (3.4.12) lib/active_scaffold/actions/update.rb:14:inupdate'
actionpack (4.1.0) lib/action_controller/metal/implicit_render.rb:4:in
send_action' actionpack (4.1.0) lib/abstract_controller/base.rb:189:inprocess_action'
actionpack (4.1.0) lib/action_controller/metal/rendering.rb:10:in
process_action' actionpack (4.1.0) lib/abstract_controller/callbacks.rb:20:inblock in
process_action'
activesupport (4.1.0) lib/active_support/callbacks.rb:113:in call' activesupport (4.1.0) lib/active_support/callbacks.rb:113:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:229:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:229:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:149:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in block in halting_and_conditional' activesupport (4.1.0) lib/active_support/callbacks.rb:229:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:229:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:166:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in block in halting' activesupport (4.1.0) lib/active_support/callbacks.rb:86:incall'
activesupport (4.1.0) lib/active_support/callbacks.rb:86:in
run_callbacks' actionpack (4.1.0) lib/abstract_controller/callbacks.rb:19:inprocess_action'
actionpack (4.1.0) lib/action_controller/metal/rescue.rb:29:in
process_action' actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:31:inblock in process_action'
activesupport (4.1.0) lib/active_support/notifications.rb:159:in block in instrument' activesupport (4.1.0) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (4.1.0) lib/active_support/notifications.rb:159:in
instrument' actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:30:inprocess_action'
actionpack (4.1.0) lib/action_controller/metal/params_wrapper.rb:250:in
process_action' activerecord (4.1.0) lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
actionpack (4.1.0) lib/abstract_controller/base.rb:136:in process' actionview (4.1.0) lib/action_view/rendering.rb:30:inprocess'
actionpack (4.1.0) lib/action_controller/metal.rb:195:in dispatch' actionpack (4.1.0) lib/action_controller/metal/rack_delegation.rb:13:indispatch'
actionpack (4.1.0) lib/action_controller/metal.rb:231:in block in action' actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:80:incall'
actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:80:in
dispatch' actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:48:incall'
actionpack (4.1.0) lib/action_dispatch/journey/router.rb:71:in block in call' actionpack (4.1.0) lib/action_dispatch/journey/router.rb:59:ineach'
actionpack (4.1.0) lib/action_dispatch/journey/router.rb:59:in call' actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:676:incall'
rack (1.5.2) lib/rack/etag.rb:23:in call' rack (1.5.2) lib/rack/conditionalget.rb:35:incall'
rack (1.5.2) lib/rack/head.rb:11:in call' actionpack (4.1.0) lib/action_dispatch/middleware/params_parser.rb:27:incall'
actionpack (4.1.0) lib/action_dispatch/middleware/flash.rb:254:in call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:incontext'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in call' actionpack (4.1.0) lib/action_dispatch/middleware/cookies.rb:560:incall'
activerecord (4.1.0) lib/active_record/query_cache.rb:36:in call' activerecord (4.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:incall'
activerecord (4.1.0) lib/active_record/migration.rb:380:in call' actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call'
activesupport (4.1.0) lib/active_support/callbacks.rb:82:in
run_callbacks' actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:27:incall'
actionpack (4.1.0) lib/action_dispatch/middleware/reloader.rb:73:in call' actionpack (4.1.0) lib/action_dispatch/middleware/remote_ip.rb:76:incall'
actionpack (4.1.0)
lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' actionpack (4.1.0) lib/action_dispatch/middleware/show_exceptions.rb:30:incall'
railties (4.1.0) lib/rails/rack/logger.rb:38:in call_app' railties (4.1.0) lib/rails/rack/logger.rb:20:inblock in call'
activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in block in tagged' activesupport (4.1.0) lib/active_support/tagged_logging.rb:26:intagged'
activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in tagged' railties (4.1.0) lib/rails/rack/logger.rb:20:incall'
actionpack (4.1.0) lib/action_dispatch/middleware/request_id.rb:21:in
call' rack (1.5.2) lib/rack/methodoverride.rb:21:incall'
rack (1.5.2) lib/rack/runtime.rb:17:in call' activesupport (4.1.0) lib/active_support/cache/strategy/local_cache_middleware.rb:26:incall'
rack (1.5.2) lib/rack/lock.rb:17:in call' actionpack (4.1.0) lib/action_dispatch/middleware/static.rb:64:incall'
rack (1.5.2) lib/rack/sendfile.rb:112:in call' railties (4.1.0) lib/rails/engine.rb:514:incall'
railties (4.1.0) lib/rails/application.rb:144:in call' rack (1.5.2) lib/rack/lock.rb:17:incall'
rack (1.5.2) lib/rack/content_length.rb:14:in call' rack (1.5.2) lib/rack/handler/webrick.rb:60:inservice'

/home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:in
`service'

/home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in
run' /home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:inblock in start_thread'

Rendered
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.1.0/lib/action_dispatch/middleware/templates/rescues/_source.erb
(0.9ms)
Rendered
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.1.0/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb
(0.9ms)
Rendered
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.1.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb
(1.8ms)
Rendered
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.1.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb
(54.7ms)

On Mon, Jan 12, 2015 at 10:08 AM, Sergio Cambra notifications@github.com
wrote:

The error notified by ActiveScaffold usually includes column name, such as:
NoMethodError: undefined method `name' for nil:NilClass -- on the
ActiveScaffold column = :[column name] for ...

Can you post that full line?
Also, try in rails console, replacing [column_name] with the column giving
error:

Category.find(1).association(:[column_name]).send(:cached_counter_attribute_name)
Category.find(1).association(:[column_name]).send(:has_cached_counter?)


Reply to this email directly or view it on GitHub
#380 (comment)
.

@scambra

This comment has been minimized.

Show comment
Hide comment
@scambra

scambra Jan 12, 2015

Member

Category.find(6).association(:entities).send(:cached_counter_attribute_name)
Category.find(6).association(:entities).send(:has_cached_counter?)

Member

scambra commented Jan 12, 2015

Category.find(6).association(:entities).send(:cached_counter_attribute_name)
Category.find(6).association(:entities).send(:has_cached_counter?)

@markmcdonald51

This comment has been minimized.

Show comment
Hide comment
@markmcdonald51

markmcdonald51 Jan 12, 2015

rails c
Loading development environment (Rails 4.1.0)
irb(main):001:0> Category.find(6).association(:entities).send(:cached_counter_attribute_name)
Category Load (0.4ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = ? LIMIT 1 [["id", 6]]
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:74: warning: circular argument reference - reflection
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:78: warning: circular argument reference - reflection
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:82: warning: circular argument reference - reflection
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:101: warning: circular argument reference - reflection
NoMethodError: undefined method name' for nil:NilClass from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:79:incached_counter_attribute_name'
from (irb):1
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/console.rb:90:in start' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/console.rb:9:instart'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:69:in console' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:inrun_command!'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in <top (required)>' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:inrequire'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in block in require' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:inload_dependency'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in require' from /home/mark/Rails/U2_active_scaffold/bin/rails:8:in<top (required)>'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in load' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:inblock in load'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in load_dependency' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:inload'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/commands/rails.rb:6:in call' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/command_wrapper.rb:38:incall'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:183:in block in serve' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:156:infork'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:156:in serve' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:131:inblock in run'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:125:in loop' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:125:inrun'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application/boot.rb:18:in <top (required)>' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from -e:1:in

'irb(main):002:0>

------------------------------next console command-------------------------------------

:002:0> Category.find(6).association(:entities).send(:has_cached_counter?)
Category Load (0.9ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = ? LIMIT 1 [["id", 6]]
NoMethodError: undefined method name' for nil:NilClass from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:79:incached_counter_attribute_name'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:75:in has_cached_counter?' from (irb):2 from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/console.rb:90:instart'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/console.rb:9:in start' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:69:inconsole'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in run_command!' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in<top (required)>'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in require' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:inblock in require'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in load_dependency' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:inrequire'
from /home/mark/Rails/U2_active_scaffold/bin/rails:8:in <top (required)>' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:inload'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in block in load' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:inload_dependency'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in load' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/commands/rails.rb:6:incall'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/command_wrapper.rb:38:in call' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:183:inblock in serve'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:156:in fork' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:156:inserve'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:131:in block in run' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:125:inloop'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:125:in run' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application/boot.rb:18:in<top (required)>'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire'
from -e:1:in `

'irb(main):003:0>

Thanks Sergio.

markmcdonald51 commented Jan 12, 2015

rails c
Loading development environment (Rails 4.1.0)
irb(main):001:0> Category.find(6).association(:entities).send(:cached_counter_attribute_name)
Category Load (0.4ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = ? LIMIT 1 [["id", 6]]
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:74: warning: circular argument reference - reflection
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:78: warning: circular argument reference - reflection
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:82: warning: circular argument reference - reflection
/home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:101: warning: circular argument reference - reflection
NoMethodError: undefined method name' for nil:NilClass from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:79:incached_counter_attribute_name'
from (irb):1
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/console.rb:90:in start' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/console.rb:9:instart'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:69:in console' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:inrun_command!'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in <top (required)>' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:inrequire'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in block in require' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:inload_dependency'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in require' from /home/mark/Rails/U2_active_scaffold/bin/rails:8:in<top (required)>'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in load' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:inblock in load'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in load_dependency' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:inload'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/commands/rails.rb:6:in call' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/command_wrapper.rb:38:incall'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:183:in block in serve' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:156:infork'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:156:in serve' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:131:inblock in run'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:125:in loop' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:125:inrun'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application/boot.rb:18:in <top (required)>' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from -e:1:in

'irb(main):002:0>

------------------------------next console command-------------------------------------

:002:0> Category.find(6).association(:entities).send(:has_cached_counter?)
Category Load (0.9ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = ? LIMIT 1 [["id", 6]]
NoMethodError: undefined method name' for nil:NilClass from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:79:incached_counter_attribute_name'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.0/lib/active_record/associations/has_many_association.rb:75:in has_cached_counter?' from (irb):2 from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/console.rb:90:instart'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/console.rb:9:in start' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:69:inconsole'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in run_command!' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in<top (required)>'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in require' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:inblock in require'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in load_dependency' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:inrequire'
from /home/mark/Rails/U2_active_scaffold/bin/rails:8:in <top (required)>' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:inload'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in block in load' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:inload_dependency'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in load' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/commands/rails.rb:6:incall'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/command_wrapper.rb:38:in call' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:183:inblock in serve'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:156:in fork' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:156:inserve'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:131:in block in run' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:125:inloop'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application.rb:125:in run' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.2.0/lib/spring/application/boot.rb:18:in<top (required)>'
from /home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from /home/mark/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire'
from -e:1:in `

'irb(main):003:0>

Thanks Sergio.

@scambra

This comment has been minimized.

Show comment
Hide comment
@scambra

scambra Jan 12, 2015

Member

I think there is a bug in activerecord 4.1.0 with has_cached_counter? and ruby 2.2. It was fixed on activerecord 4.1.2

Member

scambra commented Jan 12, 2015

I think there is a bug in activerecord 4.1.0 with has_cached_counter? and ruby 2.2. It was fixed on activerecord 4.1.2

@scambra scambra closed this Jan 12, 2015

@markmcdonald51

This comment has been minimized.

Show comment
Hide comment
@markmcdonald51

markmcdonald51 Jan 12, 2015

Going to check it. Will let you know. Stay Tuned!!

markmcdonald51 commented Jan 12, 2015

Going to check it. Will let you know. Stay Tuned!!

@markmcdonald51

This comment has been minimized.

Show comment
Hide comment
@markmcdonald51

markmcdonald51 Jan 12, 2015

Krap... how do i get that version of AS in my project? Do i need to point
it at your branch?

gem "active_scaffold", '~> 4.1.2'

didnt work

cheers Sergio.

On Mon, Jan 12, 2015 at 10:44 AM, Sergio Cambra notifications@github.com
wrote:

I think there is a bug in activerecord 4.1.0 with has_cached_counter? and
ruby 2.2. It was fixed on activerecord 4.1.2


Reply to this email directly or view it on GitHub
#380 (comment)
.

markmcdonald51 commented Jan 12, 2015

Krap... how do i get that version of AS in my project? Do i need to point
it at your branch?

gem "active_scaffold", '~> 4.1.2'

didnt work

cheers Sergio.

On Mon, Jan 12, 2015 at 10:44 AM, Sergio Cambra notifications@github.com
wrote:

I think there is a bug in activerecord 4.1.0 with has_cached_counter? and
ruby 2.2. It was fixed on activerecord 4.1.2


Reply to this email directly or view it on GitHub
#380 (comment)
.

@scambra

This comment has been minimized.

Show comment
Hide comment
@scambra

scambra Jan 13, 2015

Member

You should update rails version to 4.1.2, the bug is in activerecord (a rails gem) with ruby 2.2

Member

scambra commented Jan 13, 2015

You should update rails version to 4.1.2, the bug is in activerecord (a rails gem) with ruby 2.2

@mattheworiordan

This comment has been minimized.

Show comment
Hide comment
@mattheworiordan

mattheworiordan Feb 18, 2015

FYI, I can confirm this is an issue with ActiveRecord and Ruby 2.2. I was using ActiveRecord 3.2 (not with ActiveScaffold) and since changing to the 3-2-stable branch, the issue is gone. I have raised an issue for this at rails/rails#18991.

mattheworiordan commented Feb 18, 2015

FYI, I can confirm this is an issue with ActiveRecord and Ruby 2.2. I was using ActiveRecord 3.2 (not with ActiveScaffold) and since changing to the 3-2-stable branch, the issue is gone. I have raised an issue for this at rails/rails#18991.

langalex added a commit to cobot/cobot_office_space that referenced this issue Apr 28, 2016

aepyornis added a commit to skomputer/lilsis that referenced this issue Jun 29, 2016

Upgrade rails to 4.1.2; Update seeds.rb
* Updates rails because of ActiveRecord bug. see: activescaffold/active_scaffold#380
* Add networks to seeds.rb
* Add on SfGuarduser to seeds.rb
* Loads seeds.rb after cleaning database with database_cleaner.
@elquimista

This comment has been minimized.

Show comment
Hide comment
@elquimista

elquimista Aug 25, 2016

Changing Rails version from 3.2.15 to 3.2.22 fixed this for me.

elquimista commented Aug 25, 2016

Changing Rails version from 3.2.15 to 3.2.22 fixed this for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment