我使用邪惡的寶石來建立一個表單嚮導。在文檔中,它使用current_user對象,但我想使用不同的對象。我努力向redirect_to添加一個參數,以便我可以使用這個對象。Rails邪惡的寶石與params重定向
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
如何在文檔中使用的特定對象邪惡的寶石是這樣,而不是CURRENT_USER例子嗎?
您可以張貼在你是怎麼做到的解決方案? – kishanio