Ability to give a statement

This commit is contained in:
2017-04-13 17:16:03 +02:00
parent b30bd91f3d
commit dd5e22ea48
66 changed files with 812 additions and 25 deletions
+29
View File
@@ -0,0 +1,29 @@
class PublicitiesController < ApplicationController
before_action :authenticate_supporter!
def new
@publicity = current_supporter.publicity || Publicity.new
end
def create
@publicity = Publicity.new(publicity_params.merge(supporter: current_supporter, state: :pending))
flash['success'] = t('.success') if @publicity.valid?
return redirect_to(root_path) if @publicity.save
render :new
end
def update
create
end
def destroy
current_supporter.publicity&.destroy
redirect_to(root_path)
end
private
def publicity_params
params.require(:publicity).permit(:organisation, :statement, :avatar)
end
end