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
Specifically, when creating a perspective for a plain old ruby object, it invokes .base_class on the class of the first collection member.
Additionally, for namespaced classes, the default has an unexpected value when used to construct the Perspectives for the Collection. In many cases the behavior is counterintuitive and can result in an ArgumentError being raised by asset_valid_params!.
For instance given these classes and perspectives:
Trying to render the foo/foo_classes/show perspective will raise an ArgumentError because it does not instantiate the baz show perspective with a :baz param. The default param key in this case is :foo::bar::baz.
It seems more advantageous to default to the demodulized class name, and to only use the base_class method if it is available so that nested collections can be used with POROs.
I've created a fix that does this in my fork of the project. When you have a chance can you take a look, and add your thoughts about what this behavior should be.
Thanks!
The text was updated successfully, but these errors were encountered:
emerson-h
changed the title
Unexpected behavior in calculation of default as option
Unexpected behavior in calculation of default as option for nested collections
Sep 24, 2014
Specifically, when creating a perspective for a plain old ruby object, it invokes
.base_class
on the class of the first collection member.Additionally, for namespaced classes, the default has an unexpected value when used to construct the Perspectives for the Collection. In many cases the behavior is counterintuitive and can result in an
ArgumentError
being raised byasset_valid_params!
.For instance given these classes and perspectives:
Trying to render the foo/foo_classes/show perspective will raise an
ArgumentError
because it does not instantiate the baz show perspective with a:baz
param. The default param key in this case is:foo::bar::baz
.It seems more advantageous to default to the demodulized class name, and to only use the
base_class
method if it is available so that nested collections can be used with POROs.I've created a fix that does this in my fork of the project. When you have a chance can you take a look, and add your thoughts about what this behavior should be.
Thanks!
The text was updated successfully, but these errors were encountered: