Get current url

30 views
Skip to first unread message

Daynthan Kabilan

unread,
Oct 7, 2013, 10:49:40 AM10/7/13
to rubyonra...@googlegroups.com
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.

Scott Ribe

unread,
Oct 7, 2013, 10:56:43 AM10/7/13
to rubyonra...@googlegroups.com
On Oct 7, 2013, at 8:49 AM, Daynthan Kabilan <dayan...@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...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




Colin Law

unread,
Oct 7, 2013, 10:54:12 AM10/7/13
to rubyonra...@googlegroups.com
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

>
> Regards,
> Daya.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/CADKeJySvxfocH15Z_WON1aqW_11%2BohiAzXSpBVe1FcgsGmt1eA%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Daynthan Kabilan

unread,
Oct 7, 2013, 11:08:55 AM10/7/13
to rubyonra...@googlegroups.com
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.
Reply all
Reply to author
Forward
0 new messages