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

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

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

  end

  def show
    @s_project_module = SProjectModule.find(params[:id])

  end

  def new
    @s_project_module = SProjectModule.new
  
  end

  def edit
    @s_project_module = SProjectModule.find(params[:id])
    
  end

  def create
    @s_project_module = SProjectModule.new(params.require(:s_project_module).permit!)

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

  end


  def update
    @s_project_module = SProjectModule.find(params[:id])


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


  def destroy
    @s_project_module = SProjectModule.find(params[:id])
    @s_project_module.destroy
    
  end
end
