Apane101
Apane101

Reputation: 1123

What does the devise default create action look like?

So, I'd like to add this bit of code to the devise registrations controller.

When I'm calling @user.save. just before that, I need to call, @user.uid = SecureRandom.hex(whatever-value).

However, I don't want to change the way the create action currently functions. I'd just like to add the @user.id = SecureRandom.hex line.

So, how does the original devise create action look?

Upvotes: 0

Views: 215

Answers (1)

rmagnum2002
rmagnum2002

Reputation: 11421

https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb

def create
    build_resource(sign_up_params)

    if resource.save
      if resource.active_for_authentication?
        set_flash_message :notice, :signed_up if is_navigational_format?
        sign_up(resource_name, resource)
        respond_with resource, :location => after_sign_up_path_for(resource)
      else
        set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
        expire_session_data_after_sign_in!
        respond_with resource, :location => after_inactive_sign_up_path_for(resource)
      end
    else
      clean_up_passwords resource
      respond_with resource
    end
  end

even more docs:

https://github.com/plataformatec/devise/wiki

Upvotes: 1

Related Questions