forked from saurabh/orbit4-5
64 lines
1.3 KiB
Ruby
64 lines
1.3 KiB
Ruby
class Admin::RoleStatusesController < OrbitMemberController
|
|
before_action :set_role_status, only: [:show, :edit , :update, :destroy]
|
|
|
|
def index
|
|
@role = Role.find(params[:role_id]) rescue nil
|
|
@role_statuses = RoleStatus.where(role_id: @role.id) if @role
|
|
|
|
respond_to do |format|
|
|
format.html # index.html.erb
|
|
format.js
|
|
end
|
|
end
|
|
|
|
def show
|
|
end
|
|
|
|
def new
|
|
@role_status = RoleStatus.new
|
|
render layout: false
|
|
end
|
|
|
|
def create
|
|
@role_status = RoleStatus.new(role_status_params)
|
|
if @role_status.save
|
|
redirect_to action: :index
|
|
else
|
|
redirect_to action: :new
|
|
end
|
|
end
|
|
|
|
def edit
|
|
render layout: false
|
|
end
|
|
|
|
def update
|
|
if @role_status.update_attributes(role_status_params)
|
|
redirect_to action: :index
|
|
else
|
|
flash.now[:error] = t('update.error.category')
|
|
render action: :edit
|
|
end
|
|
end
|
|
|
|
def toggle
|
|
@role_status.disable = @role_status.disable ? false : true
|
|
@role_status.save!
|
|
render action: :index
|
|
end
|
|
|
|
def destroy
|
|
end
|
|
|
|
private
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
def set_role_status
|
|
@role_status = RoleStatus.find(params[:id])
|
|
end
|
|
|
|
# Never trust parameters from the scary internet, only allow the white list through.
|
|
def role_status_params
|
|
params.require(:role_status).permit!
|
|
end
|
|
end
|