diff --git a/app/controllers/organizations/page_texts_controller.rb b/app/controllers/organizations/page_texts_controller.rb index f28915405..7ac8ae7b2 100644 --- a/app/controllers/organizations/page_texts_controller.rb +++ b/app/controllers/organizations/page_texts_controller.rb @@ -8,19 +8,18 @@ def update if @page_text.update(page_text_params) redirect_to edit_page_text_path, notice: "Page text updated successfully!" else - render :edit, status: :unprocessable_entity + redirect_to edit_page_text_path, alert: @page_text.errors.full_messages.to_sentence end end private def page_text_params - params.require(:page_text).permit(:hero, :about) + params.require(:page_text).permit(:hero, :about, :hero_image, about_us_images: []) end def set_page_text - @page_text = current_user.organization.page_text - + @page_text = PageText.first authorize! @page_text end end diff --git a/app/models/page_text.rb b/app/models/page_text.rb index 1db410c01..54a9fe4d0 100644 --- a/app/models/page_text.rb +++ b/app/models/page_text.rb @@ -20,6 +20,17 @@ class PageText < ApplicationRecord acts_as_tenant(:organization) + has_one_attached :hero_image + has_many_attached :about_us_images + validates :hero, presence: true, allow_nil: true validates :about, presence: true, allow_nil: true + + validates :hero_image, content_type: ["image/png", "image/jpeg"], + limit: {max: 1}, + size: {less_than: 2.megabytes} + + validates :about_us_images, content_type: ["image/png", "image/jpeg"], + limit: {max: 2}, + size: {less_than: 2.megabytes} end diff --git a/app/views/components/_attachment_form.html.erb b/app/views/components/_attachment_form.html.erb index 09c7f0f13..5b44ef0a3 100644 --- a/app/views/components/_attachment_form.html.erb +++ b/app/views/components/_attachment_form.html.erb @@ -10,7 +10,7 @@ <%= bootstrap_form_with(model: instance, url: url, method: :post) do |form| %>
<%= Current.organization.page_text&.hero || "Where every paw finds a home" %>
- <%= Current.organization.page_text&.about || "#{Current.organization.name} was founded by an incredible group of ladies in April of 2020. Our initial goal was to have both a rescue and a spay/neuter clinic, however, we quickly realized that it would be more efficient to separate into two organizations."%> -
-- <%= link_to 'Read More', about_us_path, class: 'custom-btn-green mt-5 mb-3' %> -
-+ <%= Current.organization.page_text&.about || "#{Current.organization.name} was founded by an incredible group of ladies in April of 2020. Our initial goal was to have both a rescue and a spay/neuter clinic, however, we quickly realized that it would be more efficient to separate into two organizations." %> +
++ <%= link_to 'Read More', about_us_path, class: 'custom-btn-green mt-5 mb-3' %> +
+Edit your landing page. -
+