Class: Adminable::ResourcesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Adminable::ResourcesController
- Defined in:
- app/controllers/adminable/resources_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/adminable/resources_controller.rb', line 24 def create @entry = @resource.model.new(resource_params) if @entry.save redirect_to polymorphic_path(@resource.model), notice: t( 'adminable.resources.created', resource: @resource.model.model_name.human ) else flash.now[:alert] = @entry.errors. render :new end end |
#destroy ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/adminable/resources_controller.rb', line 52 def destroy @entry.destroy redirect_to polymorphic_path(@resource.model), notice: t( 'adminable.resources.deleted', resource: @resource.model.model_name.human ) end |
#edit ⇒ Object
21 22 |
# File 'app/controllers/adminable/resources_controller.rb', line 21 def edit end |
#index ⇒ Object
11 12 13 14 15 |
# File 'app/controllers/adminable/resources_controller.rb', line 11 def index @q = @resource.model.ransack(params[:q]) @entries = @q.result.includes(*@resource.includes).all .page(params[:page]).per(25) end |
#new ⇒ Object
17 18 19 |
# File 'app/controllers/adminable/resources_controller.rb', line 17 def new @entry = @resource.model.new end |
#update ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/adminable/resources_controller.rb', line 39 def update if @entry.update(resource_params) redirect_to polymorphic_path(@resource.model), notice: t( 'adminable.resources.updated', resource: @resource.model.model_name.human ) else flash.now[:alert] = @entry.errors. render :edit end end |