Skip to content

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

@teoulas

Description

@teoulas

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions