2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

コンソール上からGrapeのroutesを確認する

Posted at

普通のRailsのルーティングならpryを使っている場合以下のように簡単に確認できる。

> show-routes

Grapeの場合はうまい方法が見当たらなかったのでとりあえず以下のようにやった。

> pp Api.routes.select {|r| r.instance_variable_get(:@options)[:description] =~ /Login/ }
[#<Grape::Route:0x007fdd5a2c32a8
  @options=
   {:params=>
     {"mail"=>{:required=>true, :type=>"String"},
      "password"=>{:required=>true, :type=>"String"}},
    :description=>"Login",
    :prefix=>nil,
    :version=>"v1",
    :namespace=>"/",
    :method=>"POST",
    :path=>"/:version/login(.:format)",
    :compiled=>/\A\/(?<version>v1)\/login(?:\.(?<format>[^\/.?]+))?\Z/,
    :settings=>
     {:description=>
       {:description=>"Login",
        :params=>
         {"mail"=>{:required=>true, :type=>"String"},
          "password"=>{:required=>true, :type=>"String"}}},
      :declared_params=>[:mail, :password]}}>]

Grapeのパラメータの指定とか書く位置間違えて(ネスト間違えたり)して意図しないことになってたりしたことがあったので、作ってる最中はまめに確認したい。

beforeとかafterがどの単位に効いているかも確認できたら良いんだけどなー
どうしたらいいんだろう?

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?