티스토리 뷰
기본적인 문법
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 |
댓글
Copyright ⓒ 2018 moneystory.blog. All rights reserved.
