When I use redirect_to 'index' in my controller I get the following error. -on Ruby 1.8.7 and Rails 3.1.1-
Started GET "/presentations/1" for 127.0.0.1 at Tue Nov 15 01:48:42 +0200 2011
Processing by PresentationsController#show as HTML
Parameters: {"id"=>"1"}
Redirected to http://localhost:3000index
Completed 302 Found in 2ms
[2011-11-15 01:48:42] ERROR URI::InvalidURIError: the scheme http does not accept registry part: localhost:3000index (or bad hostname?)
And this is how it looks in routes.rb
..
get 'about_us' => 'presentations#index', :as => 'about_us'
..
resources :presentations
Apparently it’s trying to redirect to http://localhost:3000index instead of http://localhost:3000/presentations/index but I couldn’t get why. If I use redirect_to presentations_path or redirect_to :controller => 'presentations', :action => 'index', it’s all working just fine but why this is happening? I thought I should be able to use redirect_to without defining any controller parameter if it’s referring the same controller with the existing setup or am I wrong?
As per your current routes file, you say
So, if you were to type
It would work just fine. Type, rake:routes in your console to ensure routes are generated as you want them to.
Also, http://guides.rubyonrails.org/routing.html might be an excellent resource for you to get started.