Created
December 13, 2012 13:04
-
-
Save AlexanderZaytsev/4276274 to your computer and use it in GitHub Desktop.
'Set shared record' pattern in Rails 4.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostController < ActionController::Base | |
before_action :set_post, except: [:index, :new, :create] | |
def show | |
# do something with @post | |
end | |
private | |
def set_post | |
@post = Post.find(params[:id]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment