Q:

Devise User Stack Level Too Deep Error - Possibly due to this added Username funcitonality

When I try to access current_user via Devise...
def current_user 
    @user =  User.find(current_user.id)
    @user
end

and render some of their attributes in JSON via this RABL template...
object @user
attributes :email, :username

I get this error...
SystemStackError at /api/current_user
stack level too deep

I think the error is due to something within this User model, which I modified slightly to add in a Username field.  I followed Devise's instructions here to add this functionality...
class User < 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

  attr_accessible :login, :username, :email, :password, :password_confirmation, :remember_me

  has_many :cart_items, dependent: :destroy

  # Virtual attribute for authenticating by either username or email
  # This is in addition to a real persisted field like 'username'
  attr_accessor :login

  def self.find_first_by_auth_conditions(warden_conditions)
      conditions = warden_conditions.dup
      if login = conditions.delete(:login)
        where(conditions).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
      else
        where(conditions).first
      end
  end

end

A:

You are calling current_user from within current_user...
def current_user 
   @user =  User.find(current_user.id)

                          ^^^^

It then calls itself, which then calls itself again, and again... until you get the Stack Overflow
I'm not sure you you seem to need to re-write the current_user method.
afaik Devise already does that for you.
Can you show me where in that tutorial it says to rewrite def current_user?

