-
Notifications
You must be signed in to change notification settings - Fork 63
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
Wrap jsonapi methods in a helper module to avoid polluting the controller #43
Comments
Hi Michael – avoiding pollution of ActionController::Base is definitely
something I'm interested in (I introduced today an option to prevent the
railtie to automatically mixin the JSONAPI::Rails::Controller module).
Please do issue a PR, as your solution strikes me as a good balance.
Cheers,
Lucas
On Tue, 25 Jul 2017 at 15:59, Michael Deutsch ***@***.***> wrote:
Rather than adding a bunch of jsonapi_* methods to the controller, add a
single method that returns a helper object and define the methods in the
helper. For example, jsonapi_pointers would become jsonapi.pointers.
I got this idea from the paper_trail gem: paper-trail-gem/paper_trail#719
<paper-trail-gem/paper_trail#719>. I've done it in our
Rails application to customize jsonapi-rails for our use case. If it's of
interest, I can put together a PR.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#43>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/ACHPYjhOEMLK4fH22feiokE3jUjD8zhiks5sRfTWgaJpZM4OimM8>
.
--
Lucas Hosseini
[email protected]
|
Hi Michael – the direction jsonapi-rails is currently taking is that of overridable hooks in the controller. I'm going to close this issue for now, but feel free to reopen it should you think of a better pattern. |
No worries. Sorry for dropping the ball on this -- I went out on paternity leave earlier than expected and now that I'm back I've been focused on another project. |
No worries – and congratulations! |
Rather than adding a bunch of
jsonapi_*
methods to the controller, add a single method that returns a helper object and define the methods in the helper. For example,jsonapi_pointers
would becomejsonapi.pointers
.I got this idea from the paper_trail gem: paper-trail-gem/paper_trail#719. I've done it in our Rails application to customize jsonapi-rails for our use case. If it's of interest, I can put together a PR.
The text was updated successfully, but these errors were encountered: