Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError (undefined local variable or method `current_user') #181

Open
WWitalik opened this issue Jul 4, 2019 · 0 comments
Open

NameError (undefined local variable or method `current_user') #181

WWitalik opened this issue Jul 4, 2019 · 0 comments

Comments

@WWitalik
Copy link

WWitalik commented Jul 4, 2019

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant