Class: LotusAdmin::ResourceController
- Inherits:
-
AuthenticatedController
- Object
- ActionController::Base
- ApplicationController
- AuthenticatedController
- LotusAdmin::ResourceController
- Defined in:
- app/controllers/lotus_admin/resource_controller.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index(&block) ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Class Method Details
.manages(model_class) ⇒ Object
8 9 10 |
# File 'app/controllers/lotus_admin/resource_controller.rb', line 8 def self.manages(model_class) self._resource_class = model_class end |
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/lotus_admin/resource_controller.rb', line 24 def create self.resource = build_resource(permitted_params) (resource) if using_pundit? if resource.save redirect_to after_create_redirect, notice: "Created new #{ resource_class.model_name.human } successfully" else render :new end end |
#destroy ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/lotus_admin/resource_controller.rb', line 60 def destroy (resource) if using_pundit? if resource.destroy flash[:notice] = "#{ resource_class.model_name.human } has been removed" else flash[:error] = "There was an error removing that #{ resource_class.model_name.human }" end redirect_to after_destroy_redirect end |
#index(&block) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/lotus_admin/resource_controller.rb', line 46 def index(&block) (resource_class) if using_pundit? respond_to do |format| format.html block.call(format) if block.present? end end |
#new ⇒ Object
18 19 20 21 22 |
# File 'app/controllers/lotus_admin/resource_controller.rb', line 18 def new self.resource = build_resource (resource) if using_pundit? end |
#show ⇒ Object
56 57 58 |
# File 'app/controllers/lotus_admin/resource_controller.rb', line 56 def show (resource) if using_pundit? end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/lotus_admin/resource_controller.rb', line 36 def update (resource) if using_pundit? if resource.update(permitted_params) redirect_to after_update_redirect, notice: "Updated new #{ resource_class.model_name.human } successfully" else render :edit end end |