Ok, it took me about 8 hours, but I finally figured out how to get it working (if anyone has a better / cleaner way to do this, please let me know).
First, I created my own Devise::RegistrationsController to properly build the resource:
class Users::RegistrationsController < Devise::RegistrationsController def new resource = build_resource({}) resource.build_client resource.client.build_company resource.client.build_address respond_with resource end end
After that, I just needed to configure config / routes.rb for it to work:
devise_for :users, :controllers => { :registrations => "users/registrations" } do get '/users/sign_up', :to => 'users/registrations#new' end
Also I had an error in my project / registration / new.html.erb. This should be f.simple_fields_for :client instead of f.simple_fields_for @client .
Now it correctly creates all objects for nested attributes and automatically saves them when saving a resource.
Kay lucas
source share