Skip to content

nested params are not found in route hash #280

Closed
@marcusg

Description

@marcusg

it seems like the nested parameter names overwrite same parameter-names in different namespaces.
when i declare my parameter validation like this:

params do
  requires :name, :type => String, :desc => "Wish item id."
  group :target_location_attributes do
    requires :lat, :type => Float, :desc => "Wish item target location latitude."
    requires :lng, :type => Float, :desc => "Wish item target location longitude."
    requires :country_code, :type => String, :desc => "Wish item target location county code."
    requires :query, :type => String, :desc => "Wish item target query string."
  end
  group :source_location_attributes do
    optional :lat, :type => Float, :desc => "Wish item source location latitude."
    optional :lng, :type => Float, :desc => "Wish item source location longitude."
    optional :country_code, :type => String, :desc => "Wish item source location county code."
    optional :query, :type => String, :desc => "Wish item source query string."
  end
end

the resulting route parameters look like:

API::V1::Api.routes[11].route_params
{
            "name" => {
         :required => true,
             :type => "String",
             :desc => "Wish item id.",
        :full_name => "name"
    },
     "description" => {
         :required => true,
             :type => "String",
             :desc => "Wish item description.",
        :full_name => "description"
    },
           "price" => {
         :required => true,
             :type => "Float",
             :desc => "Wish item price.",
        :full_name => "price"
    },
       "allowance" => {
         :required => true,
             :type => "Float",
             :desc => "Wish item allowance.",
        :full_name => "allowance"
    },
             "lat" => {
         :required => false,
             :type => "Float",
             :desc => "Wish item source location latitude.",
        :full_name => "source_location_attributes[lat]"
    },
             "lng" => {
         :required => false,
             :type => "Float",
             :desc => "Wish item source location longitude.",
        :full_name => "source_location_attributes[lng]"
    },
    "country_code" => {
         :required => false,
             :type => "String",
             :desc => "Wish item source location county code.",
        :full_name => "source_location_attributes[country_code]"
    },
           "query" => {
         :required => false,
             :type => "String",
             :desc => "Wish item source query string.",
        :full_name => "source_location_attributes[query]"
    }
}

so no "target"-stuff can be found here and i think it's an issue. any ideas?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions