ruby on rails - RoR get key name from hash -



ruby on rails - RoR get key name from hash -

i new ror , working hashes. trying name keys hash can print them on page. maintain getting undefined method hash. i'm not sure i'm doing wrong , appreciate guidance.

when run this:

- position_names = @contest.positions.map(&:name) = position_names

i this:

undefined method 'name' {"name"=>"p", num=>"3", "ep"=>["sp", "rp"]}:hash

what should here , best way name keys hash?

if @contest.positions returns hash can list this:-

@contest.positions.keys

edited:

try doing this:-

names = [] names = @contest.positions.map {|array| array["name"]}

this give names , can modify way want use.

ruby-on-rails hash

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -