Activate active_storage — Init letter controller
This commit is contained in:
parent
12c7dbebe2
commit
1bcb99734a
3 changed files with 34 additions and 1 deletions
|
@ -1,2 +1,35 @@
|
|||
class LettersController < ApplicationController
|
||||
before_action :set_letter, only: %i[show edit update delete]
|
||||
def new
|
||||
@letter = Letter.new
|
||||
end
|
||||
|
||||
def create
|
||||
@letter = Letter.new(letter_params)
|
||||
respond_to do |format|
|
||||
if @letter.save
|
||||
format.html { redirect_to @laboratory, notice: 'Votre lettre ouverte a bien été soumise. Vous avez été redirigé sur votre lettre ouverte. Vous pouvez maintenant la partager.' }
|
||||
format.json { render :show, status: :created, location: @letter }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @letter.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_letter
|
||||
@letter = Letter.find(params[:id])
|
||||
end
|
||||
|
||||
def letter_params
|
||||
params.require(:letter).permit(
|
||||
:title,
|
||||
:document,
|
||||
:author,
|
||||
:email,
|
||||
:private_email
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
0
app/views/letters/new.html.erb
Normal file
0
app/views/letters/new.html.erb
Normal file
|
@ -5,7 +5,7 @@ require "rails"
|
|||
require "active_model/railtie"
|
||||
# require "active_job/railtie"
|
||||
require "active_record/railtie"
|
||||
# require "active_storage/engine"
|
||||
require "active_storage/engine"
|
||||
require "action_controller/railtie"
|
||||
# require "action_mailer/railtie"
|
||||
# require "action_mailbox/engine"
|
||||
|
|
Loading…
Reference in a new issue