Hash Value Assignment Bug?

  • Thread starter Nathaniel S. H. Brown
  • Start date
N

Nathaniel S. H. Brown

I have been trying to build a ACL system, and found what I believe is a bug.
=> {"allow"=>"t", "return_value"=>nil, "id"=>"1000002"}
access = { :acl_id => result["acl_id"], :return_value =>
result["return_value"], :allow => allow }
=> {:return_value=>nil, :acl_id=>nil, :allow=>true}

What I was trying to do, is set the access hash values with the values from
the result Hash. What I result with, is null values.


Warmest regards,
Nathan.
 
D

Derek Chesterfield

Your are assigning a key of :id to result, but accessing a key
of :acl_id in the seconds assignment.
It is not clear what your intentions are with :allow=>allow - is
allow defined somewhere, or did you mean :allow=>result[:allow] ??

=> {"allow"=>"t", "return_value"=>nil, "id"=>"1000002"}
access = { :acl_id => result["acl_id"], :return_value =>
result["return_value"], :allow => allow }
=> {:return_value=>nil, :acl_id=>nil, :allow=>true}
 
N

Nathaniel S. H. Brown

Your are assigning a key of :id to result, but accessing a
key of :acl_id in the seconds assignment.
It is not clear what your intentions are with :allow=>allow -
is allow defined somewhere, or did you mean :allow=>result[:allow] ??

result = {"return_value"=>nil, "allow"=>"t", "id"=>"1000002"}
=> {"allow"=>"t", "return_value"=>nil, "id"=>"1000002"}
access = { :acl_id => result["acl_id"], :return_value =>
result["return_value"], :allow => allow } => {:return_value=>nil,
:acl_id=>nil, :allow=>true}

Thanks Derek, appears it was a simple typo. Shortly after I sent this I
fixed a bug with the local allow variable which wasn't testing for (t|f) but
rather 1|0. After that was fixed, one of the nil's was removed, this
explains the other.

Warmest regards,
Nathan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top