English 中文(简体)
我简单的“Else”有什么错误?
原标题:Whats wrong with my simple If Else?

给RoR/Ruby的新东西似乎最简单。 (委托我,进行阴道搜索和读书,一盘知道什么错误)

因此,我主要认为,我补充说:

<%= if 1>2 %>
  <%=     print "helllloooo" %>
<%= else %>
  <%= print "nada" %>
<%= end %>

没有任何结果。

<><><>>><>>>>>>>>>>>>

本文中我的新《经典》及其《经典》

<th>
  <% if 1 > 2 %>
    <%= print "helllloooo" %>
  <% else %>
    <%= print "nada" %>
  <% end %>  
</th>
最佳回答

你的发言不是要展示的,而是打算展示的。

<%= if 1>2 %>

write

<% if 1 > 2 %>

Same thing for else and end


EDIT

<% if 1 > 2 %>
<%= "helllloooo" %>  #option 1 to display dynamic data
<% else %>
nada                 #option 2 to display static data
<% end %>
问题回答

You don t need to use print, or even ERB for the text. Also, your if, else, and end statements should be <%, not <%=:

<% if 1 > 2 %>
helllloooo
<% else %>
nada
<% end %>

<%= already means "print to the HTML response" in ERB (Ruby s own templating language).

因此,<代码><%=印刷......系指“印刷版......的回印”。

正确的法典希望:

<% if 1>2 %>
<%= "helllloooo" %>
<% else %>
<%= "nada" %>
<% end %>

事实上,你甚至可以忽略<代码><%=。 由于你只是重印地体(而不是任意物体):

<% if 1>2 %>
helllloooo
<% else %>
nada
<% end %>

=是问题。 使用<代码><%。 <代码><%= 用于印刷材料,而<代码><%用于指示。

用于动态内容的使用:和lt;%=>





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签