Skip to content
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

NoMethodError: undefined method `name' for Hash #14

Open
david-boyd opened this issue May 9, 2014 · 3 comments
Open

NoMethodError: undefined method `name' for Hash #14

david-boyd opened this issue May 9, 2014 · 3 comments

Comments

@david-boyd
Copy link

We have found an intermittent issue that we cannot reproduce however wondering if anyone can shed some light on this.

The issue is in line 129 of record.rb
field_name = @layout.field_mapping[field.name] || field.name rescue field.name

If I understand this correctly
field is a hash that has been extended to add a method .name.
Using core_ext.rb rfm_extend_members - def each
adding Fmpxmlresult::Resultset::Column

The error below shows that the Hash doesn't have the method .name

NoMethodError: undefined method name' for {"name"=>"addr_full", "data"=>{"__content__"=>" NSW "}}:Hash /data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/record.rb:129:inrescue in block in initialize'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/record.rb:129:in block in initialize' /data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/record.rb:127:ineach'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/record.rb:127:in initialize' /data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/base.rb:111:innew'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/base.rb:111:in rescue in new' /data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/base.rb:108:innew'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/record.rb:171:in block in build_records' /data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/utilities/core_ext.rb:94:inblock in each'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/utilities/core_ext.rb:91:in each' /data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/utilities/core_ext.rb:91:ineach'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/record.rb:170:in build_records' /data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/resultset.rb:128:ininitialize'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/layout.rb:285:in new' /data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/layout.rb:285:inget_records'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/ginjo-rfm-2.1.7/lib/rfm/layout.rb:179:in all' /data/myi/releases/20140407053924/app/jobs/load_fm_job.rb:101:inblock in sync_parents'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/mongoid-3.1.6/lib/mongoid/unit_of_work.rb:39:in unit_of_work' /data/myi/releases/20140407053924/app/jobs/load_fm_job.rb:77:insync_parents'
/data/myi/releases/20140407053924/app/jobs/load_fm_job.rb:16:in perform' /data/myi/shared/bundled_gems/ruby/2.0.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:inpublic_send'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in dispatch' /data/myi/shared/bundled_gems/ruby/2.0.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:indispatch'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in block in handle_message' /data/myi/shared/bundled_gems/ruby/2.0.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:inblock in task'
/data/myi/shared/bundled_gems/ruby/2.0.0/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in block in initialize' /data/myi/shared/bundled_gems/ruby/2.0.0/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:inblock in create'

We are simply doing a FMLayout.all call.
It's really weird it doesnt happen all the time, it only happens sometimes in our production system. During our nightly Sync. Also other .all calls work for other layouts.

Really stuck here only thing i can think to do is hack record.rb line 129
from
field_name = @layout.field_mapping[field.name] || field.name rescue field.name
to
field_name = @layout.field_mapping[field.name] || field.name rescue field[name]

@ginjo
Copy link
Owner

ginjo commented Aug 5, 2014

Ok... been a lot of changes recently in the underlying parsing engine of rfm. Give the latest master branch a try - I suspect this issue will be gone. If not, see if you can post an example fmrestulset.xml that demonstrates the issue. Thanks.

@david-boyd
Copy link
Author

Cheers William, we are testing out version 3. I will let you know if we see the issue again.

@traels
Copy link

traels commented Apr 16, 2015

I've just had the same kind of error. I'm using Rfm models and after a Policy.create I got "undefined method `id' for {}:Policy".
It has happend a few times, no exceptions are raised in Rfm, the model is just an empty hash after create.
I created a few tests and ran it alot of times and it did not happen, so far I've only seen it in production :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants