The action 'report' could not be found for MedicalRecordsController

0

The following happens,

I have this in the routes:

resources :professionals do
    #...
    resources :medical_records, controller: 'medical_records', only: [] do
      collection do
        get :report
      end
    end
  end

And the action within MedicalRecordsController exists and is this:

def report
    medical_records_scope = begin_of_association_chain.order('active DESC')
    medical_records_scope = medical_records_scope.like(params[:filter].strip) if params[:filter]

    @medical_records_report = medical_records_scope

    respond_to do |format|
      format.xlsx {
        response.headers['Content-Disposition'] = 'attachment; filename="medical_records.xlsx"'
        render disposition: 'inline'
      }
    end
  end

The error message is that of the title, which does not find the action. According to the documentation

The action 'report' could not be found for MedicalRecordsController
    
asked by Marcos R. Guevara 17.04.2017 в 23:22
source

1 answer

0

Fixed!

I had def report below a private

Like this

private
def report
    medical_records_scope = begin_of_association_chain.order('active DESC')
    medical_records_scope = medical_records_scope.like(params[:filter].strip) if params[:filter]

    @medical_records_report = medical_records_scope

    respond_to do |format|
      format.xlsx {
        response.headers['Content-Disposition'] = 'attachment; filename="medical_records.xlsx"'
        render disposition: 'inline'
      }
    end
  end

climbed up and ready.

    
answered by 18.04.2017 / 16:21
source