0

I have the following Code

@venue = Venue.friendly.find(params[:id])
@venues_nearby = Venue.within(100, :origin => [@venue.lat, @venue.lng]).where(:id != @venue.id)

I want to exclude the Record @venue.id

Is there any way to chain the same with the .within method?

Harsha M V
  • 54,075
  • 125
  • 354
  • 529

1 Answers1

1

"within" returns a scope so you can do this using normal arel where:

Location.within(3.9, origin: @loc_a).where("id != #{@loc_e.id}")

If you want a nicer syntax like you had you could use the squeel gem to get:

Location.within(3.9, origin: @loc_a).where{ id != @loc_e.id }

Michael Noack
  • 356
  • 1
  • 5