我试图用haml编写这个html,以便在项目是当前项目时添加id标记.这是为jquery突出显示设置.
<% if line_item == @current_item %>
<tr class="line_item id="current_item">
<% else %>
<tr class="line_item">
<% end %>
<td><%= line_item.quantity %>×</td>
<td><%= line_item.product.title %></td>
<td class="item_price"><%= number_to_currency(line_item.total_price) %></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
因为我不想编写辅助方法,所以我将if语句粘贴在标记中:
%tr.line_item{ :id => (line_item == @current_item ? '' : 'current_item') }
%td
= line_item.quantity
%td
\x #{line_item.product.title}
%td.item_price
= number_to_currency(line_item.total_price)
%td.item_remove
= button_to 'Remove', line_item, :method => :delete
Run Code Online (Sandbox Code Playgroud)
但是,'current_item'的这个id标签包含所有项目而不仅仅是当前项目.这导致javascript突出显示所有或错误的条目.关于如何让haml合作的想法?
使用Rails 3开始一个新的Web应用程序.我仍然是Web开发的新手,并且非常喜欢在Ruby 1.8.7和Rails 2.3.5中工作时可用的所有Internet资源.有关在我的新项目中使用Ruby 1.9.2的任何建议吗?
当从linux上的ruby 1.9.3升级到ruby 2.0(至少12.04)时,会出现意外的提示.
rdoc's executable "rdoc" conflicts with /path/bin/rdoc
Overwrite the executable? [yN]
Run Code Online (Sandbox Code Playgroud)
它可以手动覆盖它,但我正在寻找一种方法,我的脚本将自动回复是,而不会停止.
刚刚在一年前的rubygems上发现了这个问题.我gem install在脚本中使用,所以我觉得我可以轻松添加yes | gem install
编辑:尝试yes | gem install rdoc但失败了:
ERROR: Error installing rdoc:
"rdoc" from rdoc conflicts with /usr/local/rubies/2.0.0-p0/bin/rdoc
Run Code Online (Sandbox Code Playgroud)