Skip to content

Documentation of model using current_user from context hash#659

Merged
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
danielpclark:patch-1
Apr 29, 2016
Merged

Documentation of model using current_user from context hash#659
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
danielpclark:patch-1

Conversation

@danielpclark
Copy link
Copy Markdown
Contributor

It is likely that people won't understand how to use the context hash as I didn't understand it at first. It would be good to have an example so I've written one for the README.

class PeopleResource < JSONAPI::Resource
  before_save do
    @model.user_id = context[:current_user].id if @model.new_record?
  end
end

@danielpclark danielpclark changed the title Example of model using current_user from context hash Documentation of model using current_user from context hash Mar 18, 2016
@lgebhardt lgebhardt merged commit e9bcc4e into JSONAPI-Resources:master Apr 29, 2016
@lgebhardt
Copy link
Copy Markdown
Contributor

@danielpclark Thanks!

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

Successfully merging this pull request may close these issues.

2 participants