Comments (8)
This gem comes with a generator that will install the necessary migrations. I would suggest running the generator and then removing any columns that already exist.
Can you elaborate on what you mean by "polymorphic"? I've seen that term used in several contexts when dealing with Rails models.
from devise_token_auth.
"With polymorphic associations, a model can belong to more than one other model, on a single association."
In my case, a user
class is made which can be used across different models for different types of users. We have vendors, customers, etc. all of which share the common functionality of needing a user account.
from devise_token_auth.
Cool, I think everything should work ok. Please post an issue if you run into any trouble
from devise_token_auth.
@ianks - I'm closing this issue, but please re-open (or create another issue) if you run into any trouble.
from devise_token_auth.
Hi @lynndylanhurley and @ianks
I'm exactly in a similar situation here, and I don't know if I should open a separate issue. I've already gotten Devise to setup my polymorphic user model earlier, then added four role models. By changing to DeviseTokenAuth this morning I got many (RSpec) test errors/failures. The major one being: "PG::NotNullViolation: ERROR: null value in column "uid" violates not-null constraint" on 26 out of 34 failures. The others being validation failures on emails. I've managed to shut off the UID failure by doing:
before_save -> do
self.uid = SecureRandom.uuid
skip_confirmation!
end
on the user model as suggested by this airpair tutorial. But then, I saw issue #29 and figured, it should be a bad idea. My factories already include UID and provider is set to 'email' by default. Any ideas on how to fix this? and of course the validations part?
from devise_token_auth.
@lynndylanhurley @ianks @aihaddad why is this still closed it's still happening?
This is what I did :
- Created new rails project (rails 4.2.0)
- Added gems to my Gemfile 'devise_token_auth' and 'omniauth'
- bundle install
- rails g devise_token_auth:install
- rake db:migrate
I still get validation error when I save the user for Validation failed: Uid can't be blank.
As pointed out in #29 that it's a bad idea. What is the alternative to this solution?
before_save -> do
self.uid = SecureRandom.uuid
skip_confirmation!
end
from devise_token_auth.
@c0mrade - if you're using email authentication, the uid
value should be identical to the user model's email
value. The uid
attribute will be set automatically if the provider
attribute is set to email
(which should be the case if you're using email authentication).
from devise_token_auth.
So you're saying that in my test factory (when I'm testing email authentication), both uid and provider should actually be the value of users' email?
And I should remove the part self.uid = SecureRandom.uuid
from before_save callback on my model. Because it will be set by provider if I decide to use facebook/google.
Sorry if this is a dumb question, I'm new to all of this
from devise_token_auth.
Related Issues (20)
- with version 1.2.0 @data is not passed to the omniauth_external_window.html.erb HOT 2
- Why BCrypt?
- set allow_password_change column in create_table file to null: false
- access-token header is blank when token isn't changed yet. HOT 1
- keep getting a 401 on overriden create devise HOT 1
- Add created_at attribute to each token
- question: Is the description of Methods correct?
- Suggestion: 2FA - New credentials validation method | Warden strategy
- Support Rails 7.1 HOT 37
- Sponsored issue: token authentication
- Lockable does not work as expected
- Refactoring : Confirmations controller - useless `if redirect_url` condition HOT 1
- Question about security. HOT 1
- Your application has sessions disabled. To write to the session you must first configure a session store HOT 2
- Don't allow the newly created token to be ejected in `clean_old_tokens` HOT 4
- Possible to use Google oauth2 with devise_token_auth as well as devise?
- Different rails versions supported HOT 1
- dta_find_by on wrong model with set_user_by_token
- Anonymous Login Feature Request
- Unable to destroy HttpOnly cookie when token expired in cookie_enabled mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from devise_token_auth.