Skip to content

Instantly share code, notes, and snippets.

@Bahanix
Last active April 5, 2018 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bahanix/6bbcaf22abb3d3e4f0e1b675d2855727 to your computer and use it in GitHub Desktop.
Save Bahanix/6bbcaf22abb3d3e4f0e1b675d2855727 to your computer and use it in GitHub Desktop.
# Simple :
# params[:user][:tags] = ["tag1", "tag2"]
user.update!(user_params)
# Ou encore :
user.tags = ["tag1", "tag2"]
user.save!
# Beau
def user_params
params.require(:user).permit(
:email,
# ...
tags: []
)
end
# Moche
def user_params
params.require(:user).permit(
{ tags: [] },
:email,
# ...
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment