Specifying API key for development and deployment mode

1 view
Skip to first unread message

hnch...@gmail.com

unread,
Jan 26, 2008, 10:59:37 PM1/26/08
to georuby
Hi all,

I'm developing a geocoding app using Graticule+acts_as_geocodable. I
put the API key (google) in environment file. I have 2 API keys for
development mode and deployment mode. Before deploy I have to make
change to environment.rb to use deployment API key. I find it quite
annoying to do this manually repeatedly.
Can anyone suggest a clean way of specifying API key?

Thanks.

Rob Tsuk

unread,
Jan 27, 2008, 12:24:36 AM1/27/08
to geo...@googlegroups.com
On Jan 26, 2008, at 7:59 PM, hnch...@gmail.com wrote:

> Can anyone suggest a clean way of specifying API key?

You can test the value of RAILS_ENV in your environment.rb file, so
something like:

if ENV['RAILS_ENV'] == 'production'
key = production_key
else
key = dev_key
end

Rob

hnch...@gmail.com

unread,
Jan 27, 2008, 1:45:28 AM1/27/08
to georuby
Oh thanks. That's simple.

BTW, can we put different values in development.rb and production.rb?
The last time I tried (for another setting, not gmap), it seems not
work.

Thanks.

On Jan 27, 12:24 pm, Rob Tsuk <r...@tsuk.com> wrote:

John Ward

unread,
Jan 27, 2008, 4:30:34 AM1/27/08
to geo...@googlegroups.com
You should use a yaml config file. You could specify different keys for development, test and production using techniques similar to database.yml

Railcasts  demonstrated this tip here.

http://railscasts.com/episodes/85
Reply all
Reply to author
Forward
0 new messages