我有以下控制器(非常基本)。
class ActivityTypesController < ApplicationController
respond_to :html
def show
@model=ActivityType.find(params[:id])
respond_with @model
end
def new
@folder = Folder.find(params[:folder_id])
@model = @folder.activity_types.build
respond_with @folder, @model
end
def create
@folder = Folder.find(params[:folder_id])
@model = @folder.activity_types.build(params[:activity_type])
if @model.save
flash[:notice] = 'hoorraaaaayyy'
end
respond_with @folder, @model, location: root_path
end
def edit
@folder = Folder.find(params[:folder_id])
@model = ActivityType.find(params[:id])
respond_with @folder, @model
end
def update
@folder = Folder.find(params[:folder_id])
@model = @folder.activity_types.find(params[:id])
if @model.update_attributes(params[:activity_type])
flash[:notice] = 'yeeeeaaaaaaah'
end
respond_with @folder, @model, location: root_path
end
有趣的是:动作中的:location
选项#create
被忽略,而在动作中#update
,它被尊重。
我不知道,为什么会这样。更奇怪的是:当删除 inside 时,它似乎停留在:location
动作上并呈现视图,而不是重定向到视图。#create
#update
edit
#show
有谁知道我如何追踪这个问题?