\"domain1.com\"}, {:domain=>\"www.domain2.com\"}" />
开发者

rails 3 array display value

开发者_如何学PythonHi How do i display the value of domain from this array: {:domain=>"www.domain1.com"}, {:domain=>"domain1.com"}, {:domain=>"www.domain2.com"}

I have tried this:

<% @domains.each do |d| %>
    <%= d %><br />
<% end %>

That displays this:

domainwww.shopcms.dk

domaindomain1.com

domainwww.domain2.com

I have also tried to get valeu of domain like this <%= d.domain %> That gives me an error.

Obviously I want to only display the Domain like www.domain1.com


<% @domains.each do |d| %>
  <%= d[:domain] %><br />
<% end %>


since each element is a hash, if you are sure it only contains one key, you can use

d[:domain] 

to get the value and print it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜