Class: Administrate::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Administrate::ApplicationController
- Defined in:
- app/controllers/administrate/application_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/administrate/application_controller.rb', line 42 def create resource = new_resource(resource_params) (resource) if resource.save yield(resource) if block_given? redirect_to( after_resource_created_path(resource), notice: translate_with_resource("create.success") ) else render :new, locals: { page: Administrate::Page::Form.new(dashboard, resource) }, status: :unprocessable_entity end end |
#destroy ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'app/controllers/administrate/application_controller.rb', line 73 def destroy if requested_resource.destroy flash[:notice] = translate_with_resource("destroy.success") else flash[:error] = requested_resource.errors..join("<br/>") end redirect_to after_resource_destroyed_path(requested_resource), status: :see_other end |
#edit ⇒ Object
36 37 38 39 40 |
# File 'app/controllers/administrate/application_controller.rb', line 36 def edit render locals: { page: Administrate::Page::Form.new(dashboard, requested_resource) } end |
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/administrate/application_controller.rb', line 5 def index (resource_class) search_term = params[:search].to_s.strip resources = filter_resources(scoped_resource, search_term: search_term) resources = apply_collection_includes(resources) resources = order.apply(resources) resources = paginate_resources(resources) page = Administrate::Page::Collection.new(dashboard, order: order) render locals: { resources: resources, search_term: search_term, page: page, show_search_bar: } end |
#new ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/controllers/administrate/application_controller.rb', line 28 def new resource = new_resource (resource) render locals: { page: Administrate::Page::Form.new(dashboard, resource) } end |
#show ⇒ Object
22 23 24 25 26 |
# File 'app/controllers/administrate/application_controller.rb', line 22 def show render locals: { page: Administrate::Page::Show.new(dashboard, requested_resource) } end |
#update ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/administrate/application_controller.rb', line 59 def update if requested_resource.update(resource_params) redirect_to( after_resource_updated_path(requested_resource), notice: translate_with_resource("update.success"), status: :see_other ) else render :edit, locals: { page: Administrate::Page::Form.new(dashboard, requested_resource) }, status: :unprocessable_entity end end |