Accept nested attributes for documents on proposals. Adapt documentable js file to allow many input files at the same page.

This commit is contained in:
Senén Rodero Rodríguez
2017-08-12 17:28:03 +02:00
parent e327b420ff
commit e9c5f77368
10 changed files with 74 additions and 24 deletions

View File

@@ -25,6 +25,7 @@ class ProposalsController < ApplicationController
def create
@proposal = Proposal.new(proposal_params.merge(author: current_user))
@proposal = parse_documents(@proposal)
if @proposal.save
redirect_to share_proposal_path(@proposal), notice: I18n.t('flash.actions.create.proposal')
@@ -76,7 +77,8 @@ class ProposalsController < ApplicationController
def proposal_params
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url,
:responsible_name, :tag_list, :terms_of_service, :geozone_id)
:responsible_name, :tag_list, :terms_of_service, :geozone_id,
documents_attributes: [:cached_attachment, :title] )
end
def retired_params
@@ -122,4 +124,5 @@ class ProposalsController < ApplicationController
def load_successful_proposals
@proposal_successful_exists = Proposal.successful.exists?
end
end