Ruby on rails Rails使用params进行重定向

Ruby on rails Rails使用params进行重定向,ruby-on-rails,ruby-on-rails-3,ruby-on-rails-3.2,Ruby On Rails,Ruby On Rails 3,Ruby On Rails 3.2,我正在使用邪恶宝石构建一个表单向导。在文档中,它正在使用当前的用户对象,但我想使用另一个对象。我正在努力添加一个参数来重定向_,以便可以使用此对象 产品\u controller.rb def create @product = current_user.product.build(params[:product]) @product.ip_address = request.remote_ip if @product.save redirect_to product_st

我正在使用邪恶宝石构建一个表单向导。在文档中,它正在使用当前的用户对象,但我想使用另一个对象。我正在努力添加一个参数来重定向_,以便可以使用此对象

产品\u controller.rb

def create
  @product = current_user.product.build(params[:product])
  @product.ip_address = request.remote_ip

  if @product.save
    redirect_to product_steps_path # This is where I think I need to pass product object but not sure how
  else
    render 'new'
  end
end
class ProductStepsController < ApplicationController
  include Wicked::Wizard
  steps :apps, :templates

  def show
    @product = Product.find(params[:id])
    render_wizard
  end
end
redirect_to product_step_path(product_id: @product.id)
@product = Product.find(params[:product_id])
产品步骤控制器.rb

def create
  @product = current_user.product.build(params[:product])
  @product.ip_address = request.remote_ip

  if @product.save
    redirect_to product_steps_path # This is where I think I need to pass product object but not sure how
  else
    render 'new'
  end
end
class ProductStepsController < ApplicationController
  include Wicked::Wizard
  steps :apps, :templates

  def show
    @product = Product.find(params[:id])
    render_wizard
  end
end
redirect_to product_step_path(product_id: @product.id)
@product = Product.find(params[:product_id])
我在上述代码中遇到的错误是:

ActiveRecord::RecordNotFound in ProductStepsController#show

Couldn't find Product with id=apps

如何在像这样的特定对象上使用wicked gem而不是文档中的当前用户示例?

这就是我要做的工作

产品\u控制器.rb

if @product.save
  redirect_to product_step_path(:id => "apps", : product_id => @ product.id)
else
...
def show
  @asset = Asset.find(params[:asset_id])
  render_wizard
end
产品步骤控制器.rb

if @product.save
  redirect_to product_step_path(:id => "apps", : product_id => @ product.id)
else
...
def show
  @asset = Asset.find(params[:asset_id])
  render_wizard
end

向导gem将
:id
参数作为步骤名称。因此,不应将
:id
作为参数传递,因为它将与步骤名称冲突

产品\u controller.rb

def create
  @product = current_user.product.build(params[:product])
  @product.ip_address = request.remote_ip

  if @product.save
    redirect_to product_steps_path # This is where I think I need to pass product object but not sure how
  else
    render 'new'
  end
end
class ProductStepsController < ApplicationController
  include Wicked::Wizard
  steps :apps, :templates

  def show
    @product = Product.find(params[:id])
    render_wizard
  end
end
redirect_to product_step_path(product_id: @product.id)
@product = Product.find(params[:product_id])
产品步骤控制器.rb

def create
  @product = current_user.product.build(params[:product])
  @product.ip_address = request.remote_ip

  if @product.save
    redirect_to product_steps_path # This is where I think I need to pass product object but not sure how
  else
    render 'new'
  end
end
class ProductStepsController < ApplicationController
  include Wicked::Wizard
  steps :apps, :templates

  def show
    @product = Product.find(params[:id])
    render_wizard
  end
end
redirect_to product_step_path(product_id: @product.id)
@product = Product.find(params[:product_id])

你能发布一个关于你是如何做到这一点的解决方案吗?