我的促销有保质期(到期日),到期后如何销毁??我想控制日期,Date.today.to_s
因为以这种形式返回"YYYY-MM-DD"
我的数据库中的日期。
但是我有控制器显示并销毁我把它放在哪里?
def show
@promotion = Promotion.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @promotion }
end
end
def destroy
@promotion = Promotion.find(params[:id])
if @promotion.user == current_user #if user is the owner of that promotion
@promotion.destroy
respond_to do |format|
format.html { redirect_to promotions_url, notice:'Promotion was successfully delete.' }
format.json { head :ok }
end
else
redirect_to root_path ,:alert => 'This is not your promotion, you can delete only those who have entered.'
end
end
end