Forum: Ruby on Rails Get current url

6983e7aaea82078286d067a9d4e688d4?d=identicon&s=25 Daynthan Kabilan (Guest)
on 2013-10-07 16:51
(Received via mailing list)
Hi friends,

i need current url in rails environment file.

i can get current url in conroller by the below command.

request.env['HTTP_HOST']

and now i want get current url in environment.rb file or intializer
folder
files

Regards,
Daya.
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2013-10-07 16:57
(Received via mailing list)
On 7 October 2013 15:49, Daynthan Kabilan <dayanthan86@gmail.com> wrote:
> Hi friends,
>
> i need current url in rails environment file.
>
> i can get current url in conroller by the below command.
>
> request.env['HTTP_HOST']
>
> and now i want get current url in environment.rb file or intializer folder
> files

environment.rb and initialisers are run when the server is started,
there is no current url at that time as the first request may not have
been made yet.

Colin
15eb13d662803f57bc4aea59704988b4?d=identicon&s=25 Scott Ribe (Guest)
on 2013-10-07 16:58
(Received via mailing list)
On Oct 7, 2013, at 8:49 AM, Daynthan Kabilan <dayanthan86@gmail.com>
wrote:

> and now i want get current url in environment.rb file or intializer folder files

There is no "current url" at initialization time. What are you trying to
do?

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice
6983e7aaea82078286d067a9d4e688d4?d=identicon&s=25 Daynthan Kabilan (Guest)
on 2013-10-07 17:10
(Received via mailing list)
hi friends

first thanks for your immediate reply.

i am using omnicontacts for import friends concepts. so i created google
api key that redirect uri is

http://example.com/contacts/gmail/callback

if i enter http://example.com that time i got correct reply

if i enter http://www.example.com that time i got redirect uri is miss
match(google error)

so i create two api keys one for http://example.com another one for
http://www.example.com.

if i get current url in omnicontacts.rb i will give a correct rediect
path
using in conditional statment.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.