I just set up the Devise auth library and I am confused about how it is meant to be queried.
For example, before when I made my own users table, I made this user.rb file
class User < ActiveRecord::Base
set_primary_key:uid
end
And I was able to query by uid like this:
@User = User.find(1)
print @User
Now that Devise added a number of columns and the users.rb file looks like this:
class Users < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:first_name, :last_name, :organization_name
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
end
The above code to query this table does not work and I am not sure how it is meant to be queried.
Also, I am not sure if I should do something like this
rails generate devise User
Where am I going wrong here?
I don’t think it’s a good practice to override the Rails default primary keys, perhaps you could try finding your users the following way instead: