MakersNetwork/agenda-saude

View on GitHub
app/controllers/admin/appointments_bulks_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Admin
  class AppointmentsBulksController < Base
    def new
      @appointments_bulk = AppointmentsBulk.new from: Time.zone.now.to_date, to: 1.week.from_now.to_date,
                                                ubs_ids: [], active: true
    end

    def create
      @appointments_bulk = AppointmentsBulk.new appointments_bulk_params

      flash.now[:notice] = 'Agendamentos criados.' if @appointments_bulk.save

      render :new
    end

    private

    def appointments_bulk_params
      params.require(:appointments_bulk).permit(:from, :to, :active, ubs_ids: [])
    end
  end
end