Response inline below:

On Fri, Sep 17, 2010 at 9:52 AM, vishy <[email protected]> wrote:

> I am fairly new to rails and trying to learn rails by creating some
> projects on my own. I am trying to perform a geo search on a
> restaurant model and I am using geokit for that. My model stores the
> latitude and longitude for the location.
>
> I am searching for the specified location entered by the user and
> getting all the restaurants that are near that location. However I
> would also like to apply another filter on the returned result like
> returning the restaurant that only serves italian (for example). Here
> is a snippet of the code that I using.
>
>    @location = Geokit::Geocoders::GoogleGeocoder.geocode
> (params[:location])
>
>    //Using geokit find method to return the restaurants within 2
> miles of the specified address
>    @restaurants = Restaurant.find(:all, :origin => @location, :within
> => 2)
> //finally getting the restaurants that serve the user specified
> cuisine
>    @restaurants = @restaurants.where("cuisine like ?",
> params[:cuisine]) if params[:cuisine]
>



Where method is available on Model class.
http://guides.rubyonrails.org/active_record_querying.html#pure-string-conditions
Use

@restaurants = Restaurant.where("cuisine like ?",params[:cuisine]) if
params[:cuisine]




>
> This results in an " undefined method `where' " error.
>
> I am not able to figure out how can I get this to work. I am using
> rails3 and ruby 1.9.2.
>
> Any help on this will be greatly appreciated.
>
> Thanks,
> vishy
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
Srikanth Shreenivas
http://www.srikanthps.com
@srikanthps

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to