Skip to content

Preferred way to add current_user to newly created resource #320

@kagemusha

Description

@kagemusha

I'm trying to add current_user to a newly created item. I could do this is a controller, but seems would result in lots of mucking getting strong params to work. Docs seem to suggest this type of stuff done in the resources?

So I was thinking of adding in an after_create in the resource file but current_user is not available there. I thought that doing something like this in base ApplicationController:

def context
{current_user: current_user}
end

would expose current_user in the context in a resource but doesn't seem to be the case.

Suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions