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 %> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 1 May 2008, at 23:04, OhMyRuby wrote:> > 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> 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 %> > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
so if number = 1 you would use <% if @main_singer_instance_variable_get(number) =@your_singer %> ? On May 1, 3:06 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 1 May 2008, at 23:04, OhMyRuby wrote: > > > > > 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 > > > 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 %>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
opps. I got it
<% if instance_variable_get(@main_singer#{num}) == ..... %>
thanks Frederick Cheung
On May 1, 3:24 pm, OhMyRuby
<rashan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> so if number = 1
> you would use <% if @main_singer_instance_variable_get(number) =>
@your_singer %> ?
>
> On May 1, 3:06 pm, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> wrote:
>
> > On 1 May 2008, at 23:04, OhMyRuby wrote:
>
> > > 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
>
> > > 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
%>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
No, what am I doing, No it doesn''t work I am way to too tired. On May 1, 3:24 pm, OhMyRuby <rashan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> so if number = 1 > you would use <% if @main_singer_instance_variable_get(number) => @your_singer %> ? > > On May 1, 3:06 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > On 1 May 2008, at 23:04, OhMyRuby wrote: > > > > 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 > > > > 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 %>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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
-----Original Message-----
From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of
OhMyRuby
Sent: Thursday, May 01, 2008 3:04 PM
To: Ruby on Rails: Talk
Subject: [Rails] 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 %>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---