我正在使用 wicked gem 来构建表单向导。在文档中,它使用 current_user 对象,但我想使用不同的对象。我正在努力向 redirect_to 添加一个参数,以便我可以使用这个对象。
products_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
product_steps_controller.rb
class ProductStepsController < ApplicationController
include Wicked::Wizard
steps :apps, :templates
def show
@product = Product.find(params[:id])
render_wizard
end
end
路线:
resources :products
resources :product_steps
我用上面的代码得到的错误是:
ActiveRecord::RecordNotFound in ProductStepsController#show
Couldn't find Product with id=apps
如何在这样的特定对象上使用 wicked gem 而不是文档中的 current_user 示例?