简体   繁体   中英

Setup dynamic api keys for rails geocoder gem

I'm trying to implement a general 'application settings' page for my application. on this page I want my customers to be able to put their own google api key for the rails geocoder gem. I have read through the documentation but could not find any way to set this api key in a dynamic way (through a form).

Is there any way to do this dynamically so the client can use his own google api key?

Small note, every application will only have 1 api key, but I'm trying to do this dynamically so I won't have to think about it anymore down the line.

You could use Geocode.configure :

Geocoder.configure(
     :timeout  => 5,
     :lookup   => :yandex,
     :api_key  => "2a9fsa983jaslfj982fjasd",
     :units    => :km
)

https://github.com/alexreisner/geocoder/blob/e45f8bd3173c28e03efbfaf03eab7c5afaf4621a/lib/geocoder/configuration.rb#L7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM