Migration for adding summary and description to polls created. Both text_areas were added to polls form.

Imageable class included in polls model and the first aproach for adding images added to form.
This commit is contained in:
iagirre
2017-09-28 17:46:30 +02:00
parent 4e5b80f79f
commit 77d0a551cf
6 changed files with 51 additions and 1 deletions

View File

@@ -73,7 +73,9 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
end
def poll_params
params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, geozone_ids: [])
params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, :summary, :description,
geozone_ids: [],
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
end
def search_params

View File

@@ -1,4 +1,6 @@
class Poll < ActiveRecord::Base
include Imageable
has_many :booth_assignments, class_name: "Poll::BoothAssignment"
has_many :booths, through: :booth_assignments
has_many :partial_results, through: :booth_assignments

View File

@@ -19,6 +19,43 @@
</div>
</div>
<div class="row">
<div class="small-12 column">
<%=f.text_area :summary, rows: 4%>
</div>
</div>
<div class="row">
<div class="small-12 column">
<%=f.text_area :description, rows: 8%>
</div>
</div>
<div class="images small-12 column">
<div>
<%= f.label :image, t("images.form.admin_title") %>
<div id="nested-image">
<%= f.fields_for :image do |image_builder| %>
<%= render 'images/image_fields', f: image_builder, imageable: @poll %>
<% end %>
</div>
</div>
<%= link_to_add_association t('images.form.add_new_image'), f, :image,
force_non_association_create: true,
partial: "images/image_fields",
id: "new_image_link",
class: "button hollow #{"hide" if @poll.image.present?}",
render_options: {
locals: { imageable: @poll }
},
data: {
association_insertion_node: "#nested-image",
association_insertion_method: "append"
} %>
</div>
<div class="row">
<div class="small-6 medium-6 column">
<%= f.check_box :geozone_restricted, data: { checkbox_toggle: "#geozones" } %>