下面显示的控制器创建方法在成功创建客户后重定向到显示方法。我希望在从浏览器发布帖子时发生这种重定向,但是当我从另一个程序发布帖子时不应该发生重定向。我怎么做?
def create
@customer = Customer.new(params[:customer])
respond_to do |format|
if @customer.save
format.html { redirect_to @customer, notice: 'Customer was successfully created.' }
format.json { render json: @customer, status: :created, location: @customer }
else
format.html { render action: "new" }
format.json { render json: @customer.errors, status: :unprocessable_entity }
end
end
end