Skip to content

Error id is invalid on get route #1352

@Goundar

Description

@Goundar

Hi, i've an issue :'(

In this configuration, the route nearby_missions doesn't work and grape kick me with an error :

{
error: "id is invalid"
}
resource :missions do
  desc "Return a mission."
  params do
    requires :id, type: Integer, desc: "Mission id."
  end
  route_param :id do
    get do
      authenticate!
      Mission.find(params[:id]
    end
  end

  desc "Return nearby missions."
  params do
    requires :latitude, type: Float#, values: -90.0..+90.0
    requires :longitude, type: Float#, values: -180.0..+180.0 
  end
  get 'nearby_missions' do
    authenticate!
    Mission.nearby_missions(params[:latitude], params[:longitude],params[:options])
  end
end

but with this configuration everything is ok.

resource :missions do

 desc "Return nearby missions."
  params do
    requires :latitude, type: Float#, values: -90.0..+90.0
    requires :longitude, type: Float#, values: -180.0..+180.0 
  end
  get 'nearby_missions' do
    authenticate!
    Mission.nearby_missions(params[:latitude], params[:longitude],params[:options])
  end

  desc "Return a mission."
  params do
    requires :id, type: Integer, desc: "Mission id."
  end
  route_param :id do
    get do
      authenticate!
      Mission.find(params[:id]
    end
  end
end

I don't understand why the position of this code affects my API.

Someone would have any idea ?

Thx !

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