class Decidim::Meetings::Admin::MeetingRegistrationsForm
This class holds a Form to update meeting registrations from Decidim’s admin panel.
def available_slots_greater_than_or_equal_to_registrations_count
def available_slots_greater_than_or_equal_to_registrations_count errors.add(:available_slots, :invalid) if available_slots < meeting.registrations.count end
def id
for the controller we're using.
`create` action, thus raising an error since this action is not defined
method will return an empty string and Rails will treat this as a
to resubmit the form, the form will not hold an ID, so the `to_param`
If we remove this method, get an error onn the `update` action and try
and thus its `to_param` method will always return a significant value.
We need this method to ensure the form object will always have an ID,
def id return super if super.present? meeting.id end
def meeting
def meeting @meeting ||= context[:meeting] end
def reserved_slots_lower_than_or_equal_to_rest_available_slots_and_registrations_count
def reserved_slots_lower_than_or_equal_to_rest_available_slots_and_registrations_count total_slots = available_slots - meeting.registrations.count errors.add(:reserved_slots, I18n.t("decidim.meetings.admin.registrations.form.reserved_slots_less_than", count: total_slots)) if reserved_slots > total_slots end