Search field Override ??

20 views
Skip to first unread message

Gloufy

unread,
Oct 1, 2017, 5:07:34 PM10/1/17
to ActiveScaffold : Ruby on Rails Gem
Hi,

I would like find how to do that :

def self.condition_for_near_column(column, value, like_pattern)

   if value!=""

        distance = value

        if params[:search][:zippostal]!=""

         center_point = Geocoder.coordinates(params[:search][:zippostal].to_s+", FRANCE")


        else

          center_point = Geocoder.coordinates("75000, FRANCE")


        end


        box = Geocoder::Calculations.bounding_box(center_point, distance)

        

        ["latitude BETWEEN "+box[0].to_s+" AND "+box[2].to_s+" AND longitude BETWEEN "+box[1].to_s+" AND "+box[3].to_s]

      end

end



but I have :


NameError (undefined local variable or method `params' for Filemaker::PersController:Class):

  

app/controllers/test.rb:1094:in `condition_for_near_column'




Do you know how I can do that ?


Thank again for your help


Gloufy

Sergio Cambra

unread,
Oct 2, 2017, 4:06:05 AM10/2/17
to actives...@googlegroups.com
You can't, it's a class method, you can create a field search helper which
sends two values for near or zippostal in a hash, so you have both in your
condition_for_<column>_column method.

Another hack would be create a condition_for_zippostal_column, save value in
Thread.current variable and return its conditions. But zippostal column must
be in field search columns before near column.
Reply all
Reply to author
Forward
0 new messages