gem pryを掘る(pry-rails編)

pry-railsで使えるコマンドについて調べてみる

pryのプラグインである、pry-railsを追加することで使えるコマンドについて調べてみた show-models あたりが一番便利そう

show-routes

rails routesを表示

show-models

modelの一覧、各modelの属性、各modelのリレーションを見ることができる

Category
  id: integer
  packing_list_id: integer
  name: string
  created_at: datetime
  updated_at: datetime
  description: text
  position: integer
  belongs_to :packing_list
  has_many :packing_items

show-model <モデル名>

show-modelsで表示される内容をmodel名を指定して見ることができる

show-middleware

rails middleware と同じでrack middlewareの一覧を表示してくれる

use Webpacker::DevServerProxy
use Rack::Sendfile
use ActionDispatch::Static
use ActionDispatch::Executor
use ActiveSupport::Cache::Strategy::LocalCache
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use ActionDispatch::RemoteIp
...

recognize-path url

urlで指定したパスを担当するcontroller Actionを表示してくれる。

find-routes

rails routesから keywordが含まれたルートを探してくれる