# -*- encoding : utf-8 -*-

class Admin::OdrTrackersController < ApplicationController
  layout "admin"
  before_action :auth_admin

  before_action :admin_space
  
  def admin_space
    @admin_space = "default"
  end
  
  def index
    @odr_trackers = OdrTracker.order(:name).all

  end

  def show
    @odr_tracker = OdrTracker.find(params[:id])

  end

  def new
    @odr_tracker = OdrTracker.new
  
  end

  def edit
    @odr_tracker = OdrTracker.find(params[:id])
    
  end

  def create
    @odr_tracker = OdrTracker.new(params.require(:odr_tracker).permit!)

    if @odr_tracker.save
      
    else
      render action: "new"
 
    end

  end


  def update
    @odr_tracker = OdrTracker.find(params[:id])


    if @odr_tracker.update_attributes(params.require(:odr_tracker).permit!)
      
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @odr_tracker = OdrTracker.find(params[:id])
    @odr_tracker.destroy
    
  end
end
