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

Cell::RailsExtensions::HelpersAreShit.url_for doesn't support ActionController::Parameters #54

Open
teoulas opened this issue Jul 19, 2019 · 0 comments

Comments

@teoulas
Copy link

teoulas commented Jul 19, 2019

In Rails 5+ controller parameters are an ActionController::Parameters object. This applies to all nested hashes and not only the top level key-value pairs (I think this last part is new to Rails 5 compared to 4). So if you want to pass some parameters into a cell, which happens to call url_for with these parameters, it fails because of the case block here:

case options
when nil
_routes.url_for(url_options.symbolize_keys)
when Hash
_routes.url_for(options.symbolize_keys.reverse_merge!(url_options))
when String
options
when Array
polymorphic_url(options, options.extract_options!)
else
polymorphic_url(options)
end

does not handle ActionController::Parameters. A workaround is to call to_h on the parameter object, however it would be great if cells-rails handled it properly. Note that we can't add ActionController::Parameters next to Hash because it symbolize_keys has been deprecated in 5.0 and removed in a later version. It needs another when block which should call to_h.


A use case for the above is if you have a cell which needs to create URLs for sorting purposes (e.g. a table). In this case, you need to have the existing parameters in order to create the URLs for say, the links in the table header.

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

1 participant