Weird Rails URL issue when rendering a new action
Posted
by Tony
on Stack Overflow
See other posts from Stack Overflow
or by Tony
Published on 2010-06-10T03:37:19Z
Indexed on
2010/06/10
3:42 UTC
Read the original article
Hit count: 287
ruby-on-rails
|routing
I am rendering a new action but somehow getting the "index" URL. To be more specific, my create action looks like this:
class ListingsController < ApplicationController
def create
@listing = Listing.new(params[:listing])
@listing.user = @current_user
if @listing.save
redirect_to @listing
else
flash[:error] = "There were errors"
render :action => "new"
end
end
end
When there are errors, I get the "new" action but my URL is the index URL - http://domain.com/listings
Anyone know why this would happen? My routes file is fairly standard:
map.connect 'listings/send_message', :controller => 'listings', :action => 'send_message'
map.resources :listings
map.root :controller => "listings"
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
© Stack Overflow or respective owner