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

Support for permitted_attributes #20

Open
spiderbites opened this issue Jul 27, 2016 · 1 comment
Open

Support for permitted_attributes #20

spiderbites opened this issue Jul 27, 2016 · 1 comment

Comments

@spiderbites
Copy link

Hey, thanks for the gem, I've been using it on a project and am really enjoying the design.

Wondering if you have any ideas about implementing pundit's permitted_attributes feature (https://github.com/elabs/pundit#strong-parameters) via a pundit-resources defined policy.

@NuckChorris
Copy link

NuckChorris commented Nov 20, 2016

If I'm not mistaken, this would be as simple as something like this:

module PunditResource
  def self.updatable_fields(context)
    policy.permitted_attributes
  end

  def self.creatable_fields(context)
    policy.permitted_attributess
  end
end

JSONAPI::Resources already provides hooks for this exact purpose. I'll send a PR in a couple weeks if nobody beats me to the punch

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

2 participants