Answer the question
In order to leave comments, you need to log in
Controller extension?
Hello. And do not tell me how to do it right if I want to add methods to the controller, for example, sending data
1) include the Mailer module
2) create a separate Mailer class based on ApplicationController and already create subclasses
3) create a separate Mailer class, and create instances of Mailer in the controller. new?
Or is there a better solution, thanks?
Answer the question
In order to leave comments, you need to log in
Maybe this will help you rusrails.ru/action-mailer-basics ?
In general, I think that in the controller there should be only a call to the "container" (where some calculations take place, getting data from the database, for example, trailblazer, dry solve this problem) and rendering the received, i.e. Literally 3-4 lines of code.
Here is an example from triblazer:
class Song::Create < Trailblazer::Operation
step Model( Song, :new )
step :assign_current_user!
step Contract::Build( constant: MyContract )
step Contract::Validate()
failure :log_error!
step Contract::Persist()
def log_error!(options)
# ..
end
def assign_current_user!(options)
options["model"].created_by =
options["current_user"]
end
end
####
result = Song::Create.({ title: "The Feeling Is Alright" }, "current_user": current_user)
result.success? #=> true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question