内容
ブレイクポイントとしてbinding.pryを設定した場合、
その場所限りでデバッグが可能でしたが、ステップイン・ステップアウトなどができません。
そこで、pry.navを追加すると移動操作が可能になります。
設定
Gemfile
gem "pry-debugger", "~> 0.2.2"
.pryrcに下記を追記してプロジェクトルート直下に保存
Pry.commands.alias_command 'c', 'continue' Pry.commands.alias_command 's', 'step' Pry.commands.alias_command 'n', 'next' Pry.commands.alias_command 'f', 'finish' Pry.commands.alias_command 'q', 'quit'
サンプル
実装コード
class SigninController < ApplicationController skip_filter :authorize, :except=>:index skip_filter :authorize, :except=>:signin def index flash[:message] render_partial message_display: true end def signin user = User.find_by name: params[:login] unless user && user.authenticate(params[:password]) flash[:message] = "fail password authentication" render_partial message_display: true return redirect_to action: 'index' end binding.pry session[:user_id] = user.id render_partial menu_display: true, message_display: true redirect_to controller: 'user',action: 'list' end def signout session[:user_id] = nil flash[:message] = "ログアウトしました" render_partial message_display: true redirect_to :controller => 'signin', :action => 'index' end end