How do I run an array through an IF statement in rails?
Posted
by codyvbrown
on Stack Overflow
See other posts from Stack Overflow
or by codyvbrown
Published on 2010-05-24T21:56:11Z
Indexed on
2010/05/24
23:11 UTC
Read the original article
Hit count: 180
ruby-on-rails
|ruby
I am creating an application that highlights user messages from a stream based on whether or not the user has been 'vouched'. It works fine if it's setup for a single author. For example
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 %>
But I'm having trouble doing it for multiple user nicknames.
@vouch = Vouch.find(:all,
:select => "vouched_user_nickname",
:group => 'vouched_user_nickname'
)
Any ideas would be greatly appreciated. I'm a rails noob.
© Stack Overflow or respective owner