我正在創建一個應用程序,根據用戶是否被「保證」來突出顯示來自流的用戶消息。如果它爲單個作者設置,它工作正常。例如如何通過導軌中的IF語句運行數組?
controller: @vouch = Vouch.last.vouched_user_nickname
view:
<% Twitter::Search.new(params[:id]).each do |tweet| %>
<li>
<%= image_tag tweet.profile_image_url %>
<% if @vouch.include? tweet.from_user %> <div class="flit_message_containerh">
<u> <a href="http://twitter.com/<%= tweet.from_user %>"> <%= tweet.from_user %></a></u> <%= linkup_mentions(auto_link(h tweet.text)) %>
<div class="time_ago">
<%= link_to distance_of_time_in_words_to_now(tweet.created_at) , tweet %>
<% else %> <div class="flit_message_container">
<u> <a href="http://twitter.com/<%= tweet.from_user %>"> <%= tweet.from_user %></a></u>
<%= linkup_mentions(auto_link(h tweet.text)) %>
<div class="time_ago">
<%= link_to distance_of_time_in_words_to_now(tweet.created_at) , tweet %>
<% end %>
但是我很難爲多用戶暱稱做這件事。
@vouch = Vouch.find(:all,
:select => "vouched_user_nickname",
:group => 'vouched_user_nickname'
)
任何想法將不勝感激。我是一個鐵軌小菜。
耶。那工作。真正優雅和創意的解決方案謝謝。 – user250181 2010-05-24 23:35:56