w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Rails Form: save first form, then redirect to a second or third form with the params of the first form

I think it makes sense that a Prestatair should be nested under a User. But your routes file does not do any nesting yet. I would recommend to nest the routes as such:

resources :users do
  resources :prestataires
  resources :employeurs

After doing this, @user = User.find(params[:user_id]) should work... but you may also see other issues at that point that you'll have to fix. The reason that line will work now lies in the fact that you will now have that params[:user_id] present in the params hash, as provided by the nested :users routes. For more...

Use bundle exec rake routes to see what routes and named_route name the above nesting creates and update your code accordingly.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.