Skip to content

Instantly share code, notes, and snippets.

@AlexanderZaytsev
Created December 13, 2012 13:04
Show Gist options
  • Save AlexanderZaytsev/4276274 to your computer and use it in GitHub Desktop.
Save AlexanderZaytsev/4276274 to your computer and use it in GitHub Desktop.
'Set shared record' pattern in Rails 4.0
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