bdx
bdx

Reputation: 3516

Rails - can't convert Symbol into Integer

I have a hash as follows:

display_helpers => { :helper_1 => { :helper => lambda { d.is_master_account? }, :text => "Master Account" } }

I also have an array with contents:

a => [ :helper_1, :other_symbol ]

I am trying to print the value of :text from within the hash as follows:

<%= display_helpers[ a[0] [ :text ] ] %>

When doing this, I keep getting the error "can't convert Symbol into Integer".

Can anyone see what I'm doing wrong?

Upvotes: 0

Views: 2592

Answers (1)

Matthew
Matthew

Reputation: 13332

I'm a little dizzy looking at this, but I think it should be this:

<%= display_helpers[ a[0] ] [ :text ]  %>

Upvotes: 1

Related Questions