4
4

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 1 year has passed since last update.

【Rails】byebugの使用例

Last updated at Posted at 2023-06-10

備忘録

boards_controller.rb

def create
    byebug
    @board = current_user.boards.build(board_params)
    if @board.save
      redirect_to boards_path, success: t('defaults.message.created', item: Board.model_name.human)
    else
      flash.now['danger'] = t('defaults.message.not_created', item: Board.model_name.human)
      render :new
    end
  end

スクリーンショット 2023-06-10 16.37.38(2).png

   11:     @board = Board.new
   12:   end
   13: 
   14:   def create
   15:     byebug
=> 16:     @board = current_user.boards.build(board_params)
   17:     if @board.save
   18:       redirect_to boards_path, success: t('defaults.message.created', item: Board.model_name.human)
   19:     else
   20:       flash.now['danger'] = t('defaults.message.not_created', item: Board.model_name.human)
(byebug) board_params
<ActionController::Parameters {"title"=>"aaaaa", "body"=>"bbbbb", "board_image_cache"=>""} permitted: true>

デバッグ勉強中

4
4
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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?