用params渲染动作

时间:2012-07-08 10:46:43

标签: ruby-on-rails ruby-on-rails-3

我有这个问题。我有更新产品的编辑视图,以及我在product_controller中的操作

  def edit_product

    @product = Product.find(params[:product][:id])

    respond_to do |format|
      if @product.update_attributes(params[:product])
        format.html { render action: "edit_product"  }
      else

        format.html { render action: "edit" }
        format.json { render json: @product.errors, status: :unprocessable_entity }
      end
    end

  end

问题在于,当我调用编辑视图时,我传递了id_product,而现在我无法进行渲染操作并且它给出了错误

如何解决它并渲染类似编辑的内容?id_product = ??

这是我的产品资源

  resources :products, :only => [:index] do
    collection do
      post 'new_product'
      post 'edit_product'
    end    
  end

0 个答案:

没有答案
相关问题