Skip to content

Instantly share code, notes, and snippets.

@tatey
Last active December 21, 2015 16:09
Show Gist options
  • Save tatey/6331296 to your computer and use it in GitHub Desktop.
Save tatey/6331296 to your computer and use it in GitHub Desktop.
The good ol' fashion way of restricting params in a controller. In response to https://twitter.com/awws/status/371437294776901632
class PostsController
def create
@post = Post.new post_params
@post.save
respond_with @post
end
private
def post_params
params.fetch(:post, {}).slice :title, :slug, :body
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment