How make a helper:
If value X is true: print
How make a helper:
If value X is true: print
Try something like this:
def current_li(content, x)
klass = x ? “current” : nil
content_tag(:li, content, :class => klass)
end
On Feb 20, 3:55 pm, James B. [email protected]
Andrew B. wrote:
def current_li(content, x)
klass = x ? “current” : nil
content_tag(:li, content, :class => klass)
end
Thanks, but why this doesn’t work?
<%= current_li {link_to “xxx”, :controller => “yyy”}, @x == 1 %>
On Feb 20, 10:20 pm, James B. [email protected]
wrote:
Andrew B. wrote:
def current_li(content, x)
klass = x ? “current” : nil
content_tag(:li, content, :class => klass)
endThanks, but why this doesn’t work?
<%= current_li {link_to “xxx”, :controller => “yyy”}, @x == 1 %>
because you’re passing a block that generates a link to . something
like
current_li link_to(…), @x == 1
would probably work.
Fred
And same for ?
selected_option (value, content, x)
if x = true then
contentelse
contentFrederick C. wrote:
Come on, should be easy enough if you got the previous one
Not for me
I can’t make it work:
def current_option(value, content, x)
selec = x ? “selected” : nil
content_tag(:option, content, :value => value, :selected => selec)
end
On Feb 24, 8:04 am, Jo Jo [email protected] wrote:
And same for ?
Come on, should be easy enough if you got the previous one (not to
mention that options_for_select etc. do this for you).
Fred
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs