Skip to content

Instantly share code, notes, and snippets.

@Marchino
Created May 9, 2011 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marchino/962240 to your computer and use it in GitHub Desktop.
Save Marchino/962240 to your computer and use it in GitHub Desktop.
Extension of devise RegistrationController
require 'mmplus/mmplus_users_resolver'
class Users::RegistrationsController < Devise::RegistrationsController
append_view_path MmplusUsersResolver.new
protected
def render_with_scope(action, path=self.controller_path)
build_nested_attributes if request.get? or resource.errors.empty?
super
end
def build_nested_attributes
resource.build_profile if resource.profile.nil?
resource.build_billing_address if resource.billing_address.nil?
resource.shipping_addresses.build if resource.shipping_addresses.empty?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment