티스토리 뷰
반응형
기본적인 문법
class PostsController < ApplicationController
def edit
@post = Post.find(params[:id])
if session[:user_id] != @post.user_id
flash[:notice] = "Sorry, you can't edit this post"
redirect_to post_path
end
end
end
대체가능한 문법
class PostsController < ApplicationController
def edit
@post = Post.find(params[:id])
if session[:user_id] != @post.user_id
redirect_to (post_path, notice: "Sorry, you can't edit this post")
end
end
end
반응형
'Ruby&Rails > Rails' 카테고리의 다른 글
| [Rails] Ajax로 Create & Delete 기능 구현 (0) | 2015.06.26 |
|---|---|
| [Rails] N+1 쿼리 문제 해결방안 (0) | 2015.06.25 |
| [Rails] validates 문법 (0) | 2015.06.24 |
| [Rails] CRUD의 Create & Update & Delete 문법 (0) | 2015.06.24 |
| [Rails] 외부 fonts 경로 및 사용법 (0) | 2015.01.28 |
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 알고리즘
- 반도체관련주
- 이펙티브 자바
- 중동리스크
- 한미반도체
- 주식투자
- K방산
- SK하이닉스
- 로봇관련주
- javascript
- 방산주
- 해운주
- 코스피
- 한화오션
- AI반도체
- Rails
- 투자전략
- 주가전망
- HBM
- 엔비디아
- 현대차
- ruby
- 한화에어로스페이스
- 개인투자자
- 호르무즈해협
- 삼성전자
- 국제유가
- 자료구조
- ruby on rails
- Java
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |
글 보관함
Copyright ⓒ 2018 moneystory.blog. All rights reserved.
