Module: Godmin::Resources::ResourceController
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/godmin/resources/resource_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
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/godmin/resources/resource_controller.rb', line 40 def create respond_to do |format| if @resource_service.create_resource(@resource) format.html { redirect_to redirect_after_create, notice: } format.json { render :show, status: :created, location: @resource } else format.html { render :edit } format.json { render json: @resource.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/godmin/resources/resource_controller.rb', line 68 def destroy @resource_service.destroy_resource(@resource) respond_to do |format| format.html { redirect_to redirect_after_destroy, notice: } format.json { head :no_content } end end |
#edit ⇒ Object
38 |
# File 'lib/godmin/resources/resource_controller.rb', line 38 def edit; end |
#index ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/godmin/resources/resource_controller.rb', line 21 def index respond_to do |format| format.html format.json format.csv end end |
#new ⇒ Object
36 |
# File 'lib/godmin/resources/resource_controller.rb', line 36 def new; end |
#show ⇒ Object
29 30 31 32 33 34 |
# File 'lib/godmin/resources/resource_controller.rb', line 29 def show respond_to do |format| format.html format.json end end |
#update ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/godmin/resources/resource_controller.rb', line 52 def update return if perform_batch_action set_resource respond_to do |format| if @resource_service.update_resource(@resource, resource_params) format.html { redirect_to redirect_after_update, notice: } format.json { render :show, status: :ok, location: @resource } else format.html { render :edit } format.json { render json: @resource.errors, status: :unprocessable_entity } end end end |