class User < ActiveRecord::Base
  has_secure_password
  has_many :tweets
  
  
  def slug
    self.username.downcase.gsub(' ', '-').gsub(/[^\w-]/, '')
  end

  def self.find_by_slug(slug)
    User.all.find do |user|
      user.username.downcase == slug.gsub('-', ' ')
    end
  end
  
  
end
