From: Hassan Schroeder Date: 2012-04-26T08:46:28+09:00 Subject: Re: Method Missing as Filter On Wed, Apr 25, 2012 at 4:13 PM, Christopher D. wrote: > I can check that there is indeed a username ("Tom") and return 1 if > there is one and 0 by using this code > User.find_by_username("Tom")? 1 : 0 > > How would I find out Tom's corresponding id? Here's a couple of ways: @user = User.find_by_username("Tom") ? @user.id : 0 User.find_by_username("Tom").id rescue 0 I'll bet there will be other suggestions :-) -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com http://about.me/hassanschroeder twitter: @hassan