开发者

How can I turn this into a block using a %w array in Ruby?

I have to have a series of buttons with different values:

<p>
  <%= f.submit "Connected", :class => 'button' %> 
  <%= f.submit "Voicemail"%>
  <%= f.submit "Hangup"%>
  <%= f.submit "Not Interested" %> 
  <%= f.submit "Wrong开发者_如何学JAVA Number" %>  
</p`> 

Looking at it it seems I could turn it into a do block and pass a %w array but don't know exactly how....? Thanks...


Example that illustrates the point :

%w[Connected Voicemail].each do |item|
     <%= f.submit "#{item}" %>
end

Since this is Rails, don't put this directly in your view, but construct it in a helper.


you mean like this?

<% button_titles.each do |button_title| %>

   <%= f.submit button_title, :class => 'button' %>

<% end %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜