From: Gennady Bystritsky Date: 2011-01-28T00:43:43+09:00 Subject: Re: Newbie moving from other language - simple inline Rails conditional On Jan 25, 2011, at 12:55 PM, Peter D Bethke wrote: > Hi All, > > I'm moving to Ruby from another language and I'm working through the basics by altering an existing Rails project. One of the basic things I'd like to do is to highlight a link for example with the css id "current" when the current url matches a certain string. > > I'm trying it first as in inline conditional, and failing miserably: > > <%= (request.fullpath == '/home/menu') ? render :text => 'current' %> > > Basically, I'm trying to say "if the fullpath = x, then output the string "current". I'm sure that the answer is simple. The correct syntax for the construct you use is: cond ? expr_true : expr_false in your case there's no expr_false. So re-wright it to something like: <%= (request.fullpath == '/home/menu') ? render(:text => 'current') : "" %> Or if you really do not need the false expression, you can do something like <%= render(:text => 'current') if (request.fullpath == '/home/menu') %> Gennady. > > Ruby is pretty cool, I'm enjoying it immensely. > > Best, > > Peter D Bethke >