You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/controllers/collections_controller.rb

21 lines
572 B

class CollectionsController < ApplicationController
before_action :require_login
def create
tip_exception("勿重复收藏") if current_user.collections.find_by(create_params).present?
current_user.collections.create!(create_params)
normal_status("收藏成功,您可以在个人主页对应的栏目中查看")
end
def cancel
collection = current_user.collections.find_by!(create_params)
collection.destroy!
normal_status("操作成功")
end
private
def create_params
params.permit(:container_id, :container_type)
end
end