Class: PermissionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PermissionsController
- Defined in:
- lib/generators/permissify/controller/template/permissions_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #find_permissions_object ⇒ Object
- #index ⇒ Object
- #js_response ⇒ Object
- #set_nav ⇒ Object
- #set_the_permissions_class(the_class, corresponding_class_params_key, prefix, applicability, permissions_header, sort_field = :name) ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/generators/permissify/controller/template/permissions_controller.rb', line 24 def create @permissions_object = @permissions_class.new @permissions_object.name = params[@corresponding_class_params_key][:name] @permissions_object.from = params[@corresponding_class_params_key][:from] @permissions_object.save @response_message = @permissions_object.errors..join(', ') js_response end |
#destroy ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/generators/permissify/controller/template/permissions_controller.rb', line 15 def destroy if @permissions_object.respond_to?(:deleted_at) @permissions_object.update_attribute(:deleted_at, Time.now) else @permissions_object.destroy end js_response end |
#edit ⇒ Object
11 12 13 |
# File 'lib/generators/permissify/controller/template/permissions_controller.rb', line 11 def edit js_response end |
#find_permissions_object ⇒ Object
63 64 65 66 |
# File 'lib/generators/permissify/controller/template/permissions_controller.rb', line 63 def @permissions_object = @permissions_class.find(params[:id]) end |
#index ⇒ Object
7 8 9 |
# File 'lib/generators/permissify/controller/template/permissions_controller.rb', line 7 def index render :template => 'permissions/index' end |
#js_response ⇒ Object
68 69 70 |
# File 'lib/generators/permissify/controller/template/permissions_controller.rb', line 68 def js_response render :action => "#{@view_directory}#{params[:action]}_response" end |
#set_nav ⇒ Object
72 73 74 75 76 77 |
# File 'lib/generators/permissify/controller/template/permissions_controller.rb', line 72 def set_nav @active_tab = 'admin' @active_section = 'Admin' @active_nav = @permissions_header @current_entity = @entity = Admin.first end |
#set_the_permissions_class(the_class, corresponding_class_params_key, prefix, applicability, permissions_header, sort_field = :name) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/generators/permissify/controller/template/permissions_controller.rb', line 49 def (the_class, corresponding_class_params_key, prefix, applicability, , sort_field = :name) @permissions_prefix = prefix @permissions_class = the_class @corresponding_class_params_key = corresponding_class_params_key @applicability = applicability # relative pathing isn't working in devint (ok in dev): working around with post-deploy symlinks @view_directory = Rails.env == 'development' ? '../permissions/' : '' @permissions_name = @permissions_prefix.chop @permissions_category = @permissions_name+'s' @sort_field = sort_field @index_columns = corresponding_class_params_key == :role ? 6 : 4 @permissions_header = end |
#update ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/permissify/controller/template/permissions_controller.rb', line 34 def update = params[@permissions_name] ||= {} class_attributes = params[@corresponding_class_params_key] class_attributes ||= {} # @saved = @permissions_object.update_attributes class_attributes.merge(permission_attributes) attrs = class_attributes.merge() @permissions_object.name = attrs[:name] @permissions_object. = attrs[:permissions] (attrs) # @permissions_object.attributes = class_attributes.merge(permission_attributes) @saved = @permissions_object.save js_response end |