Skip to content

Instantly share code, notes, and snippets.

@andrewculver
Created March 28, 2011 02:41
Show Gist options
  • Save andrewculver/889917 to your computer and use it in GitHub Desktop.
Save andrewculver/889917 to your computer and use it in GitHub Desktop.
Assign non-form data to a new user on sign-up with Devise.
class RegistrationsController < Devise::RegistrationsController
protected
def build_resource(hash=nil)
# let devise do it's magic with the form data.
super
# assign any additional information the form doesn't populate.
# (e.g. @organization is populated in ApplicationController.)
resource.organization = @organization
# maintain the existing interface
self.resource
end
end
# Also, update routes.rb to utilize your new registrations controller.
# devise_for :users, :controllers => {:registrations => "registrations"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment