This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/admin/roles_controller.rb

58 lines
1.2 KiB
Ruby

class Admin::RolesController < ApplicationController
layout "new_admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
helper Admin::AttributeValuesViewHelper
def index
@attributes = Role.all.entries
render :template => 'admin/attributes/index'
end
def show
end
def new
@attribute = Role.new
render :template => 'admin/attributes/new'
end
def edit
@attribute = Role.find(params[:id])
@attribute_fields_upper_object = @attribute.sub_roles
render :template => 'admin/attributes/edit'
end
def create
@attribute = Role.new(params[:role])
@attribute.save
redirect_to :action => :index
end
def update
@attribute = Role.find(params[:id])
@attribute.update_attributes(params[:role])
respond_to do |format|
format.html { redirect_to :action => :index }
format.js { render 'admin/attributes/toggle_enable' }
end
end
def destroy
@attribute = Role.find(params[:id])
@attribute.destroy
redirect_to :action => :index
end
protected
def set_attribute
@attribute_type = 'role'
@class = 'roles'
end
end