Rails 5 with Devise and Functionalities

  1. Install devise an and testing

https://github.com/plataformatec/devise

2. Add Admin Role model

https://github.com/plataformatec/devise/wiki/How-To:-Add-an-Admin-Role

3.  Add confirmation to user who can actively use the content on website

https://github.com/plataformatec/devise/wiki/How-To:-Add-:confirmable-to-Users

If you have already generated devise view’s referring in 1st point for the application you then only generate confirmation view By:

rails generate devise:views confirmable 

4. .  Require Admin to activate

https://github.com/plataformatec/devise/wiki/How-To:-Require-admin-to-activate-account-before-sign_in

Advertisements

Add existing/new project to GitHub/BitBucket

1. Create a new empty repository on GitHub.
2. open command prompt in windows or shell in unix
3. Move to Main directory of your Ruby or any other project.
4. git init
5. git add .
6. git commit -m “First Commit”
7. git remote add origin ‘copy the http URL from github/BitBucket’
if you want to verify you newly added URL
8 git remote -v
Push the change on remote machine
9 git push origin master

Validtions in Rails Model

Different Validations in Rails :

  1. validates_presence_of  :status
  2. validates_numericality_of :fingers
  3. validates_uniqueness_of :toothmarks
  4. validates_confirmation_of :password
  5. validates_acceptance_of :zombification
  6. validates_length_of :password, minimum: 3
  7. validates_format_of :email, with: /regex/i
  8. validates_inclusion_of :age, in: 21..99
  9. validates_exclusion_of :age, in: 0…21,
  10. message: “Sorry you must be over 21”

Including multiple validations in one line ( ‘ ,’  separated)

validates :status,   presence: true,
uniqueness: true,
numericality: true,
length: { minimum: 0, maximum: 2000 },
format: { with: /.*/ },
acceptance: true,
confirmation: true

Ruby on Rails guide web sites

1. Gems release, current  version, popularity, bug tracker and for gem wiki link

https://www.ruby-toolbox.com/

(a) https://apidock.com  For all tags and usage

2. Ruby language Fundamentals

http://ruby-doc.org/ under it http://docs.ruby-doc.com/docs/ProgrammingRuby/

3. Rails API doc

http://railsapi.com/

4. Get started with rails installation

http://rubyonrails.org/

5. Subversion Git

http://gitref.org/

6.  Live example

http://railsforzombies.org/

7. Online practice Ruby

codepad.org