title: How can I make a rails authors resource a devise user?
body: <p>I have setup a rails application with devise on it so users can register and login and they can add posts and other resources based on their roles(Admin,Teacher,Author,Pupil). Admin as access to everything and I am using gem 'cancan' for roles.</p>
  
  <pre><code>if user.role
          if  user.role.name == "Admin"
              can :manage, :all
          elsif user.role.name == "Teacher"
              can :manage, [Book, Story]
              can :read, [Book, Author, Story]
          elsif user.role.name == "Author"
              can :manage, [Book, Author]
              can :read, [Book, Author, Story]
          elsif user.role.name == "Pupil"
              can :manage, [Story]
              can :read, [Book, Author, Story]
          elsif user
              can :read, :all
          end
      else
          can :read, :all
      end
  </code></pre>
  
  <p>Currently Authors are just added to a book when you create the book. In the backend you just add authors as many as you like and then assign that to a book. If your an admin you can edit authors details and if your an author you can edit your own profile area in your author resource but there is no login for an author to do this at all.</p>
  
  <p>What I want to know is: Is it easy to create a devise user type like author from authors already added to the backend or will they need to be created all over again?</p>
  
  <p>=== Edit below here ====</p>
  
  <p>user.rb</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    belongs_to :role
    def confirmation_required?
      false
    end
    # Include default devise modules. Others available are:
    # :confirmable, :lockable, :timeoutable and :omniauthable
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :trackable, :validatable, :confirmable
  
  
    has_attached_file :avatar, styles: {
          large: "600x450#",
          medium: "250x250#",
          small: "100x100#"
      }, :default_url =&gt; "/images/:style/filler.png"
    #validates_attachment_content_type :avatar, :content_type =&gt; ["image/jpg", "image/jpeg", "image/png", "image/gif"]
    validates_attachment_content_type :avatar, :content_type =&gt; /\Aimage\/.*\Z/
    validates :avatar, :email, :username, :password, presence: true
  
  end
  </code></pre>
  
  <p>role.rb</p>
  
  <pre><code>class Role &lt; ActiveRecord::Base
      has_many :users
  end
  </code></pre>
  
  <p>author.rb</p>
  
  <pre><code>class Author &lt; ActiveRecord::Base
      has_many :books, dependent: :destroy
      has_many :ideas, dependent: :destroy
      accepts_nested_attributes_for :books
      accepts_nested_attributes_for :ideas
      validates_uniqueness_of :name
  
      has_attached_file :avatar, :styles =&gt; { :large =&gt; "980x760", :medium =&gt; "300x300&gt;", :thumb =&gt; "100x100&gt;" }, :default_url =&gt; "/images/:style/missing.png"
      validates_attachment_content_type :avatar, :content_type =&gt; /\Aimage\/.*\Z/
  
  
  end
  </code></pre>
  
  <p>Thanks
  Mark</p>