spec/dummy/app/controllers/reports_controller.rb
def show
    if params[:id].to_s =~ /^\d+$/
      _report = Report.find(params[:id])
    elsif Report.respond_to?(params[:id])
      _report = Report.find_by_name(params[:id])
    else
      redirect_to root_url, notice: 'That report does not exist'
      return
    end
    @report = _report.run(params)
    template = {template: "meta_reports/" + (@report[:template] || "default") }

    respond_to do |format|
      format.html { render template }
      format.pdf { render template }
      format.xlsx { render template }
    end
    _report.view
  end
# remember to add authentication/authorization. E.g:
# before_filter :require_user
# load_and_authorize_resource
remember to add authentication/authorization.
remember to add authentication / authorization .
def show
    if params[:id].to_s =~ /^\d+$/
      _report = Report.find(params[:id])
    elsif Report.respond_to?(params[:id])
      _report = Report.find_by_name(params[:id])
    else
      redirect_to root_url, notice: 'That report does not exist'
      return
    end
    @report = _report.run(params)
    template = {template: "meta_reports/" + (@report[:template] || "default") }
    respond_to do |format|
      format.html { render template }
      format.pdf { render template }
      format.xlsx { render template }
    end
    _report.view
  end
def show if params [ :id ] . to_s =~ / ^ \d +$ / _report = Report . find ( params [ :id ] ) elsif Report . respond_to? ( params [ :id ] ) _report = Report . find_by_name ( params [ :id ] ) else redirect_to root_url , notice : 'That report does not exist' return end @report = _report . run ( params ) template = { template : "meta_reports/" + ( @report [ :template ] || "default" ) } respond_to do | format | format . html { render template } format . pdf { render template } format . xlsx { render template } end _report . view end
remember to add authentication/authorization.
remember to add authentication / authorization .