ruby on rails

debugging & route, action, view

흰두부1 2020. 11. 10. 16:35

config>routes.rb

resources :articles, only: [:show]

~/articles/~ 에 대해 모두 articles_controller.rb로 요청을 보냄, show request만 허용

 

articles_controller.rb

  def show
    byebug
    @article = Article.find(params[:id])
  end

byebug: rails의 디버깅 플러그인, 콘솔에서 디버깅 가능

 

입력 예시

params
parmas[:id]
continue

show.html.rb

<p><strong>Title: </strong><%= @article.title %></p>
<p><strong>Description: </strong><%= @article.description %></p>