richhollis / swagger-docs

Generates swagger-ui json files for Rails APIs with a simple DSL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NameError (undefined local variable or method `current_user')

WWitalik opened this issue · comments

Hey guys. What if I have current user local variable on my controller action?

def index
    @conversation = Conversation.new(current_user.id, recipient_id_param)
    render json: @conversation, user: current_user
end
def create
    @message = current_user.messages.create(message_params.merge(recipient_id: recipient_id_param))
    render json: @message, status: :created
end
def destroy
    @message = current_user.messages.where(recipient_id: recipient_id_param).find(id_param)
    @message.destroy
    render status: :accepted
end

Can I set this variable to imitate current user? Like current user = User.find() or User.find_by().