On Apr 8, 8:31 pm, Mark <[email protected]> wrote: > Hi, > > i have a problem with if-else. > I get this error: "uninitialized constant > ActionView::Base::CompiledTemplates::Male" > > I want to change the background-color for male and female. So i wrote > this code with if and else. > I think there is a mistake in line 8. How could this work. What do i > have to write? > > 5: <% for article in @articles %><br /> > 6: <table> > 7: <%= h article.gender %> > 8: <%- if (h article.gender = Male) -%> > 9: <table > style="background-color:#d1e1fa;"> > 10: <% else %> > 11: <table > style="background-color:#111111;"> >
did you want to see if article.gender was the string 'Male'?. If so then you need to get rid of the call to h, use == for comparison ( = is for assignment) and write "Male" rather than Male (ie a string literal rather than a constant of the same name) Fred > I hope somebody can help me. > > Thanks > Mark > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

