【发布时间】:2011-03-01 23:42:05
【问题描述】:
我正在呈现一个新动作,但不知何故获得了“索引”URL。更具体地说,我的创建操作如下所示:
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
当出现错误时,我会收到“新”操作,但我的 URL 是索引 URL - http://domain.com/listings
有人知道为什么会这样吗?我的路线文件相当标准:
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'
【问题讨论】:
标签: ruby-on-rails routing