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
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/administrate/application_controller.rb', line 43 def create resource = resource_class.new(resource_params) (resource) if resource.save redirect_to( [namespace, resource], notice: translate_with_resource("create.success"), ) else render :new, locals: { page: Administrate::Page::Form.new(dashboard, resource), } end end |
#destroy ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'app/controllers/administrate/application_controller.rb', line 72 def destroy if requested_resource.destroy flash[:notice] = translate_with_resource("destroy.success") else flash[:error] = requested_resource.errors..join("<br/>") end redirect_to action: :index end |
#edit ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/administrate/application_controller.rb', line 37 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 21 |
# File 'app/controllers/administrate/application_controller.rb', line 5 def index search_term = params[:search].to_s.strip resources = Administrate::Search.new(scoped_resource, dashboard_class, search_term).run resources = apply_resource_includes(resources) resources = order.apply(resources) resources = resources.page(params[:page]).per(records_per_page) page = Administrate::Page::Collection.new(dashboard, order: order) render locals: { resources: resources, search_term: search_term, page: page, show_search_bar: , } end |
#new ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/controllers/administrate/application_controller.rb', line 29 def new resource = resource_class.new (resource) render locals: { page: Administrate::Page::Form.new(dashboard, resource), } end |
#show ⇒ Object
23 24 25 26 27 |
# File 'app/controllers/administrate/application_controller.rb', line 23 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 |
# File 'app/controllers/administrate/application_controller.rb', line 59 def update if requested_resource.update(resource_params) redirect_to( [namespace, requested_resource], notice: translate_with_resource("update.success"), ) else render :edit, locals: { page: Administrate::Page::Form.new(dashboard, requested_resource), } end end |