Created
June 10, 2011 21:55
-
-
Save chap/1019854 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
def find_matches | |
User.where(:city => self.city) | |
# self == the user object you called this function on | |
end | |
end | |
class UsersController < ApplicationController | |
def match | |
@user = User.find(params[:id]) | |
@matches = @user.find_matches | |
# @matches is an array of user objects (look at users#index to see how to iterate over an array of user objects | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment