You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if a rails controller has an equivalent line to this:
renderjson: 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:
renderjson: 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.
The text was updated successfully, but these errors were encountered:
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. 😉
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.
if a rails controller has an equivalent line to this:
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 thingsI 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:but if you use Rails ActiveController helpers
respond_to
andrespond_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.
The text was updated successfully, but these errors were encountered: