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

Deprecation warnings under 'standard' rails usage #171

Closed
skippy opened this issue Dec 2, 2015 · 3 comments
Closed

Deprecation warnings under 'standard' rails usage #171

skippy opened this issue Dec 2, 2015 · 3 comments

Comments

@skippy
Copy link

skippy commented Dec 2, 2015

if a rails controller has an equivalent line to this:

  render json: ModelDecorator.new(model)

as of 2.4 this throws the deprecation warning: [Representable] Mixing user and representable options is deprecated. Please provide your options via :user_options. I had no ideal how or where this was coming from as there is only one instance of :user_options on the readme. (though putting a breakpoint in a debug session quickly solved that problem).

If you are curious, rails controller adds this by default #to_json(:prefixes=>["[controller_path]", "application"], :template=>"[object_name]") and possibly other things

I put 'standard' in quotes as there are many ways to do this in rails, but passing an object that responds to #to_json is a common rails pattern. In this case, it is easy to fix by doing the following:

  render json: ModelDecorator.new(model).to_json

but if you use Rails ActiveController helpers respond_to and respond_with you can't do that.

I understand the core issue here, where you want to split out control flags used by Representable from user-supplied data. But I am curious, is it common to pass in representable parameters into a #to_json call rather than define it at the property level?

anyway, I am logging this just in case it is a pain point for others.

@apotonick
Copy link
Member

Hi Adam,

all documentation is moved to our website. Here are the docs for user options: http://trailblazer.to/gems/representable/3.0/api.html#user-options

This warning will go away if you upgrade to 3.0 or turn off deprecations using Representable.deprecations = false.

Other than that, in Trailblazer you don't pass models into responders, but operations. I'm not interested in supporting the vanilla Rails way anymore, because I think almost everything about it is wrong. Sorry for the inconvenience, though. 😉

@apotonick
Copy link
Member

Whoops, that might sound a bit harsh, didn't mean it like that. ❤️ What I was trying to say is, I don't know what I can do about it as I'm not gonna tolerate any weird Rails parameters just for the sake of "The Rails Way".

Anyway, this warning should go away once you turn off deprecations.

@skippy
Copy link
Author

skippy commented Dec 2, 2015

np! I understand. 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

No branches or pull requests

2 participants