41 lines
1.1 KiB
Ruby
41 lines
1.1 KiB
Ruby
class Public::QuestionsController < ApplicationController
|
|
layout "public"
|
|
|
|
def new
|
|
@question = Question.new
|
|
@title = "Me contacter"
|
|
end
|
|
|
|
|
|
def create
|
|
@title = "Me contacter"
|
|
@question = Question.new(params.require(:question).permit!)
|
|
|
|
|
|
if @question.save
|
|
|
|
QuestionMailer.send_question(@question).deliver
|
|
|
|
@question_title = "Question de #{@question.name} - "+ActionController::Base.helpers.localize(@question.created_at).to_s
|
|
@article = Article.new(:enabled => false, :title => @question_title, :slug => @question_title.to_slug, :tags_cache => "Question", :created_at => @question.created_at,:published_at => @question.created_at)
|
|
|
|
if @article.save
|
|
|
|
|
|
@article.block.portlets << Portlet.create(:content => TextContent.new(:content => "<p>Question de #{@question.name} : </p><blockquote>"+ActionController::Base.helpers.simple_format(@question.content)+"</blockquote>"))
|
|
|
|
end
|
|
redirect_to [:public, @question]
|
|
else
|
|
render :action => :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def show
|
|
@title = "Me contacter"
|
|
end
|
|
|
|
end
|