Setting params[:token] with Devise

I’m trying to implement Devise but new to it.

When I request …/api/v1/projects.json, I get ‘undefined method
admin? for nil:NilClass’, which I’m assuming happens because
params[:token] is not being set. See below for code snippets – does
anyone know how/where to set params[:token] with Devise?

class Api::V1::ProjectsController < Api::V1::BaseController
def index
respond_with(Project.for(current_user))
end
end

class Project < ActiveRecord::Base

def self.for(user)
user.admin? ? Project : Project.readable_by(user)
end
end

class User < ActiveRecord::Base
before_save :ensure_authentication_token

devise :database_authenticatable, :registerable, :token_authenticatable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable

end

class Api::V1::BaseController < ActionController::Base
before_filter :authenticate_user

respond_to :json

private

def authenticate_user
  @current_user =

User.find_by_authentication_token(params[:token])
end

def current_user
  @current_user
end

end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs