Skip to content

Instantly share code, notes, and snippets.

@JasonSpatial
Last active August 29, 2015 14:18
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 JasonSpatial/21ab3db0399c11766a50 to your computer and use it in GitHub Desktop.
Save JasonSpatial/21ab3db0399c11766a50 to your computer and use it in GitHub Desktop.
CopyList controller example
if !params[:new_list_name].present?
# make sure we're scoping to the logged in user
@list = current_user.lists.find(params[:id])
@new_list_name = params[:new_list_name]
if @new_list = CopyList.call(@list, @new_list_name)
redirect_to lists_path, notice: "#{@new_list_name} created from your selected list"
else
redirect_to :back, alert: "We were unable to copy your selected list"
end
else
redirect_to :back, alert: "Please enter a name for the new list"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment