Changing text in view with variables

in my view:

<% if @main_singer_1 == @your_singer %> <% if @main_drummer_1 == @your_drummer %>

i want to have this in a loop so i can change _1

How would I do this.

I have some idea but I am not sure.

[1..20].each do ..... and then replace _1 with each of the numbers

or if someone can show the code to do this.

number = "1"

<% if @main_singer_'number' == @your_singer %>

in my view:

<% if @main_singer_1 == @your_singer %> <% if @main_drummer_1 == @your_drummer %>

i want to have this in a loop so i can change _1

Well you can do this with instance_variable_get but it sounds like you
could make things easier for your self by having arrays @main_singers
and @main_drummers

Fred

so if number = 1 you would use <% if @main_singer_instance_variable_get(number) == @your_singer %> ?

opps. I got it

<% if instance_variable_get(@main_singer#{num}) == ..... %>

thanks Frederick Cheung

No, what am I doing, No it doesn't work I am way to too tired.

Rather than have your controller create all those individual variables, have it pass the singers and drummers in arrays. Then you can loop through the array w/code like this:

  <% @main_singer.each do |singer| %>     <% if singer == @your_singer then %>
      blah blah blah     <% end %>   <% end %>

hth,

-Roy