Class: HyperAdmin::ResourceController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- HyperAdmin::ResourceController
- Defined in:
- app/controllers/hyper_admin/resource_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #resource ⇒ Object
- #resource_class ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/hyper_admin/resource_controller.rb', line 26 def create @resource = @resource_class.new params[@resource_class.model_name.param_key] if @resource.save redirect_to [ :admin, @resource ] else render "admin/resources/new", layout: layout end end |
#destroy ⇒ Object
46 47 48 49 50 51 52 |
# File 'app/controllers/hyper_admin/resource_controller.rb', line 46 def destroy @resource = @resource_class.find params[:id] @resource.destroy redirect_to [ :admin, @resource_class ] end |
#edit ⇒ Object
21 22 23 24 |
# File 'app/controllers/hyper_admin/resource_controller.rb', line 21 def edit @resource = resource render 'admin/resources/edit', layout: layout end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/hyper_admin/resource_controller.rb', line 6 def index @resources = resource_class.all render 'admin/resources/index', layout: layout end |
#new ⇒ Object
16 17 18 19 |
# File 'app/controllers/hyper_admin/resource_controller.rb', line 16 def new @resource = resource_class.new render 'admin/resources/new', layout: layout end |
#resource ⇒ Object
54 55 56 |
# File 'app/controllers/hyper_admin/resource_controller.rb', line 54 def resource resource_class.find params[:id] end |
#resource_class ⇒ Object
58 59 60 |
# File 'app/controllers/hyper_admin/resource_controller.rb', line 58 def resource_class raise "This method must be overridden" end |
#show ⇒ Object
11 12 13 14 |
# File 'app/controllers/hyper_admin/resource_controller.rb', line 11 def show @resource = resource render 'admin/resources/show', layout: layout end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/hyper_admin/resource_controller.rb', line 36 def update @resource = @resource_class.find params[:id] if @resource.update params[@resource_class.model_name.param_key] redirect_to [ :admin, @resource ] else render "admin/resources/edit", layout: layout end end |