Code Monkey home page Code Monkey logo

devise_uid's Introduction

devise_uid

Build Status Code Climate Dependency Status

Add UID support to Devise. A lot of times, we want a unique ID representing the user model instead of its incremental ID in the database, for example, in API instead of exposing the primary key, we use a random generated unique string to indentify this user.

Installation

Add this line to your application's Gemfile:

gem 'devise_uid'

And then execute:

$ bundle

Automatic Installation

Add devise_uid to any of your Devise models using the following generator:

rails generate devise_uid MODEL

Replace MODEL with the class name you want to add devise_uid. This will add the :uid flag to your model's Devise modules. The generator will also create a migration file. Currently only ActiveRecord is supported.

Manual Installation

Add :uid to the devise call in your model:

class User < ActiveRecord
  devise :database_authenticable, :confirmable, :uid
end

Add uid field to your Devise model migration:

class AddUidToUser< ActiveRecord::Migration
  add_column :users, :uid, :string
  add_index :users, :uid, :unique => true
end

Usage

An uid is generated when a Devise MODEL is created. Access it like this:

user = User.create(email: "[email protected]")
puts user.uid # => "V8aS9tucNzKyH39d4Bpq"

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

devise_uid's People

Contributors

owenthereal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

devise_uid's Issues

Migration name does not end with ".rb"

Using version 0.1.0, the generated migration name is missing the file extensions.

This should just require fixing copy_devise_migration:
migration_template "migration.rb", "db/migrate/devise_uid_add_to_#{table_name}.rb"

Rails 4.0.0 support

Can you update the gemspec to allow for Rails 4.0.0 support?

Line 22:
Remove:
gem.add_dependency("railties", "~> 3.0")
Add:
gem.add_dependency("railties", ">= 3.0")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.