Find_by

RubyonRails_newbie
Mon, 01 Feb 2010 22:30:25 -0000

Hi All,

I''m looking to improve finding friends on my site, by adding a
''''suggestion'''' page/area.

BAsically, a query should be run against a logged in user and find
other people from the same town/location. Or that share a similar
hobby etc.

I have a controller and an index page i want to update this with.

what I have so far:

Controller:

  def thingsincommon
       @users = User.find_by_user_id( @user.id, 1, :limit =>
1, :conditions => "location like ''London%''")

  end

To be honest, this query would only work for thise people who live
near somewhere similar to london. Is it possible to amend it further
to read the user''s location (which they add as part of further site
registration) so then the query is looking for other people nearby
etc?

Html.erb:

		<% if @user.thingsincommon %>

	<% end %>

Thing is, i can''t find a tutorial to cover this, so I can see the
example. The api site is handy for controller stuff, but when I want
to render results based on the query, I''m finding it difficult..

Any ideas how to accomplish this?

Kind Regards