I am trying to save a id of my Quotation model and store it in a cookie on my controller. But when I try to read the cookie rails displays a exception reentered error. Controller:
class BasicsController < ApplicationController
before_action :get_cookie
def quotations
if params[:quotation]
@quotation = Quotation.new( params.require(:quotation).permit(:author_name, :quote, :category) )
if @quotation.save
flash[:notice] = 'Quotation was successfully created.'
Quotation.new
end
else
@quotation = Quotation.new
end
if params[:sort_by] == "date"
@quotations = Quotation.order(:created_at)
else
@quotations = Quotation.order(:category)
end
end
def get_search
@quotations = Quotation.all
if params[:search]
@quotations = Quotation.search(params[:search])
else
@quotations = Quotation.all.order("created_at DESC")
end
end
def cookies
id = params[:id]
@removed_id = [1, 2, 3, 4]
cookies[:removed_id] = @removed_id
redirect_to basics_quotations_path
end
private
def get_cookie
cookies.delete :test
# @removed_ids = Array.new
puts @removed_ids.to_s
end
end
Aucun commentaire:
Enregistrer un commentaire