class Admin::RedirectionsController < Admin::DashboardController
	

	before_action :set_redirection, only: [:edit, :update]	

	def index
		@redirections = Redirection.paginate(:page => params[:page], :per_page => 10).order(:id => "DESC")
	end

	def new
		@redirection = Redirection.new
	end

	def create
		@redirection = Redirection.new(redirection_params)
		respond_to do |format|
			if @redirection.save
				format.html{ redirect_to admin_redirections_path, :notice => "New redirection Tag has been created" }
			else
				format.html{ render :new }
			end
		end
	end

	def edit
		
	end

	def update
		respond_to do |format|
			if @redirection.update(redirection_params)
				format.html{ redirect_to admin_redirections_path, :notice => "Redirection Tag has been updated" }
			else
				format.html{ render :new }
			end
		end
	end

	private

		def set_redirection
			@redirection = Redirection.find(params[:id]) if params[:id]
		end

		def redirection_params
			params.require(:redirection).permit(:source, :destination)
		end	

end