Weird Rails URL issue when rendering a new action
- by Tony
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'