|
|
|
|
@ -73,19 +73,20 @@ class OrganisationsController < ApplicationController
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def new |
|
|
|
|
@resource = Organisation.new |
|
|
|
|
@organisation = Organisation.new |
|
|
|
|
@rent_periods = helpers.rent_periods_with_checked_attr |
|
|
|
|
render "new", layout: "application" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def create |
|
|
|
|
selected_rent_periods = params.require(:organisation).permit(rent_periods: [])[:rent_periods].compact_blank |
|
|
|
|
@resource = Organisation.new(org_params) |
|
|
|
|
if @resource.save |
|
|
|
|
@organisation = Organisation.new(org_params) |
|
|
|
|
if @organisation.save |
|
|
|
|
OrganisationRentPeriod.transaction do |
|
|
|
|
selected_rent_periods.each { |period| OrganisationRentPeriod.create!(organisation: @resource, rent_period: period) } |
|
|
|
|
selected_rent_periods.each { |period| OrganisationRentPeriod.create!(organisation: @organisation, rent_period: period) } |
|
|
|
|
end |
|
|
|
|
redirect_to organisations_path |
|
|
|
|
flash[:notice] = I18n.t("organisation.created", organisation: @organisation.name) |
|
|
|
|
redirect_to organisation_path @organisation |
|
|
|
|
else |
|
|
|
|
@rent_periods = helpers.rent_periods_with_checked_attr(checked_periods: selected_rent_periods) |
|
|
|
|
render :new, status: :unprocessable_entity |
|
|
|
|
|