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>
'ruby on rails' 카테고리의 다른 글
DRY code: Don't Repeat Yourself (0) | 2020.11.11 |
---|---|
REST to CRUD (0) | 2020.11.11 |
Active Record Validation (0) | 2020.11.10 |
Models and rails console (0) | 2020.11.10 |
rails naming conventions & migration (0) | 2020.11.10 |