Skip to content

Instantly share code, notes, and snippets.

@iissnan
Created April 7, 2017 05:40
Show Gist options
  • Save iissnan/3ced9c12d9222b400c90a16c53ca0b4b to your computer and use it in GitHub Desktop.
Save iissnan/3ced9c12d9222b400c90a16c53ca0b4b to your computer and use it in GitHub Desktop.
#Rails - Insert attributes into Request Params
class PostsController < ApplicationController
def create
Post.create!(post_params)
end
private
def post_params
params.require(post).permit(:some_attrs).merge(user_id: current_user.id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment