Forum: Ruby on Rails how to redirect_to the index.html page

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4287232616a1dde31cd2dab154acad70?d=identicon&s=25 Pepe Sanchez (jsn1)
on 2008-11-29 17:24
hi all

If I add in my code  redirect_to :action => 'index'  it redicrects to
the index method in the current controller.

how can I redirect it to the  index.html page ?

thanks
4ddf8432a838f716cc499e43131e5e58?d=identicon&s=25 James Englert (Guest)
on 2008-11-29 18:28
(Received via mailing list)
Try redirect_to 'index.html'

Jim Englert
http://jim-rants.com/coding-blog/

On Sat, Nov 29, 2008 at 11:24 AM, Pepe Sanchez <
4287232616a1dde31cd2dab154acad70?d=identicon&s=25 Pepe Sanchez (jsn1)
on 2008-11-29 23:11

Thank you for the example, I tied that

-     redirect_to '/index.html'

and it worked
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (Guest)
on 2008-11-30 00:54
(Received via mailing list)
Hi Pepe, You should do the following:

redirect_to :controller => "index", :action => 'index'

Good luck,

-Conrad

Sent from my iPhone

On Nov 29, 2008, at 2:11 PM, Pepe Sanchez
<rails-mailing-list@andreas-s.net
Fac81a9d95c81d817a2debb6f717f3ac?d=identicon&s=25 Sazima (Guest)
on 2008-11-30 14:49
(Received via mailing list)
Pepe,

Take a look at the API, you can redirect to an action, URL or plain
text.

Cheers, Sazima

On Nov 29, 2:24 pm, Pepe Sanchez <rails-mailing-l...@andreas-s.net>
E7f72bb97b38ad473b23645dffb9e442?d=identicon&s=25 Paul Reitz (paulreitz)
on 2009-03-22 15:18
I'm having a similar problem that none of these solutions will work for.
I understand you can redirect to a URL, the problem is - while I'm
developing my app I want to redirect to 'http://127.0.0.1:3000' but
after I deploy it I want it to redirect to something like
'http://app.somedomain.com'. Is there a constant similar to 'RAILS_ROOT'
that I can use?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-03-22 15:48
(Received via mailing list)
On Mar 22, 2:18 pm, Paul Reitz <rails-mailing-l...@andreas-s.net>
wrote:
> I'm having a similar problem that none of these solutions will work for.
> I understand you can redirect to a URL, the problem is - while I'm
> developing my app I want to redirect to 'http://127.0.0.1:3000'but
> after I deploy it I want it to redirect to something like
> 'http://app.somedomain.com'. Is there a constant similar to 'RAILS_ROOT'
> that I can use?

is redirect_to '/' good enough ? (or are you redirecting to a
different domain to the one you received the request on ?)

Fred
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-03-22 17:11
Paul Reitz wrote:
> I'm having a similar problem that none of these solutions will work for.
> I understand you can redirect to a URL, the problem is - while I'm
> developing my app I want to redirect to 'http://127.0.0.1:3000' but
> after I deploy it I want it to redirect to something like
> 'http://app.somedomain.com'. Is there a constant similar to 'RAILS_ROOT'
> that I can use?

If there is no other way available then you can set your own constant in
   ./config/environments/development.rb
   ./config/environments/production.rb
   ./config/environments/test.rb

So, for development.rb and test.rb
   REDIRECT_HOST = 'http://127.0.0.1:3000'

while in production.rb
   REDIRECT_HOST = 'http://192.168.215.35:3333'

and in your controllers

   redirect_to REDIRECT_HOST
This topic is locked and can not be replied to.