Last active
August 29, 2015 14:18
-
-
Save jasononaquest/21ab3db0399c11766a50 to your computer and use it in GitHub Desktop.
CopyList controller example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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