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

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

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

  end

  def show
    @s_modules_state = SModulesState.find(params[:id])

  end

  def new
    @s_modules_state = SModulesState.new
  
  end

  def edit
    @s_modules_state = SModulesState.find(params[:id])
    
  end

  def create
    @s_modules_state = SModulesState.new(params.require(:s_modules_state).permit!)

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

  end


  def update
    @s_modules_state = SModulesState.find(params[:id])


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


  def destroy
    @s_modules_state = SModulesState.find(params[:id])
    @s_modules_state.destroy
    
  end
end