2013-02-02 49 views

回答

3

以下語句在Building Partial Objects Step by Step頁面中給出。

This also means to get to the create action we don't have a product_id yet so we can either create this object in another controller and redirect to the wizard, or we can use a route with a placeholder product_id such as [POST] /products/building/build in order to hit this create action.

您可以創建另一個控制器的對象,並重定向到嚮導或使用路由使用佔位符擊中創建行動。

1

這裏是我的應用程序的樣本,其工作對我來說

class RegistrationsController < Devise::RegistrationsController 
    protected 

    def after_sign_up_path_for(resource) 
    user_background = resource.build_user_background 
    user_background.save 
    user_background_build_path(user_background.id, :first_step_name) 
    end 

end 

這將創建UserBackground對象,然後通過用戶與新創建的對象ID惡人控制器的第一步。