Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused nickname, image from user object #304

Closed
m2omou opened this issue Jul 14, 2015 · 6 comments
Closed

remove unused nickname, image from user object #304

m2omou opened this issue Jul 14, 2015 · 6 comments

Comments

@m2omou
Copy link

m2omou commented Jul 14, 2015

I want to remove the nickname and image from the user object as I don't need them.

I tried to override the assign_provider_attrs methods from the OmniauthCallbacks controller

config/routes.rb

mount_devise_token_auth_for 'User', at: 'auth', controllers: {
                              omniauth_callbacks: 'overrides/omniauth_callbacks',
  }

controllers/overrides/omniauth_callbacks_controller.rb

module Overrides
  class OmniauthCallbacksController < DeviseTokenAuth::OmniauthCallbacksController

    # break out provider attribute assignment for easy method extension
    def assign_provider_attrs(user, auth_hash)

      user.assign_attributes({
                                 email:    auth_hash['info']['email']
                             })
    end
  end
end

Did I missed something ? :) thanks

@booleanbetrayal
Copy link
Collaborator

You can just write a Rails migration to remove those columns and you should be good. The default generator supports them as they tend to be common fields for new projects. Hope this helps!

@lakesare
Copy link

lakesare commented Mar 9, 2016

what do rails migrations have to do with it? they are already not in my model and I'm getting
ActiveRecord::UnknownAttributeError (unknown attribute 'nickname' for User.):
errors correspondingly.

what is the usual way to use other column names (:name instead of :nickname) eg? overriding assign_provider_attrs?

@aeldaly
Copy link

aeldaly commented Jul 15, 2016

bump! I do not understand why an assumption could be made that everyone has a nickname and image fields? And how is it that only 3 people on earth have that problem :D

@booleanbetrayal
Copy link
Collaborator

If someone feels passionately about this, then I'll accept a PR to that effect, so long as tests still pass.

@lynndylanhurley
Copy link
Owner

The reason those fields are used is because that's what's returned by OmniAuth. We could create an initializer setting for this, but it's also really easy to override the controller method to not use those fields, and to remove the columns from the db migration. The amount of code written would be about the same, and the override is more flexible.

But I don't feel that strongly about it either way.

@chintans1
Copy link

Hi, I'm trying to remove the columns from the database but failing to do so. Is there something else needed to let me remove the columns?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants