我正试图做一个简单的删除记录在数据库中。当我尝试删除一条记录时,它创建一个新的记录
<b> <%= button_to "Cancel your invitation", { :controller=>"invites", :method => 'destroy', :id => invite.id },
:confirm => "Are you sure you want to delete this invite?" %></b>
我指定控制器,因为我正在从用户视图执行此操作。
当我点击按钮时,它会为新记录创建一个空白条目。那么为什么当我指定一个销毁方法时会使用create方法呢?
一些更成: 我的配置/路线很简单,只要可以是:
资源:邀请
我的控制器是很基本的太:
def create
@invite = Invite.new(params[:invite])
if @invite.save
redirect_to current_user
else
redirect_to root_path
end
end
def destroy
Invite.find(params[:id]).destroy
redirect_to current_user
end
你的控制器是什么样的? – 2011-06-02 17:21:11