This look pretty good!  I have to set up a bunch of migrations before I 
can test, so I'll just ask now; what do I do with the Tweet class? 
(Still a bit of a newbie here!)  I notice that you don't say self.agree 
as the method name - this means that they're only added for the scope 
the one request, right?

Thanks!
--Peter

Fabian Streitel wrote:
> How 'bout that:
> 
> class Tweet
>  def agree
>   agree_count += 1
>  end
> 
>  def disagree
>   disagree_count += 1
>  end
> end
> 
> # pass this method either :agree or :disagree
> def agree_or_not( method )
>  tweet = tweet.find(params[:id])
>  tweet.send(method)
>  render :text => consensus(method, tweet.agree_count, 
> tweet.disagree_count)
> end
> 
> def consensus( method, agreed, disagreed )
>   if method == :agree
>     agreed = "#{agreed-1} <strong>+1</strong>"
>   else
>     disagreed = "#{disagreed-1} <strong>+1</strong>"
>   end
> 
>   "<span class='agree'>#{agreed}</span> &ndash; <span
> class='disagree'>#{disagreed}</span>"
> end

-- 
Posted via http://www.ruby-forum.com/.