I would like to create an object with fields equal to that of the ActiveRecord query, but with the fields pre-filled or blank, so that they are called in the same way in the other file ...
For a better example, the code snippet I
def organization_name_for_emails(organization = @organization)
@organization_name_for_emails ||= organization.emails.first
if @organization_name_for_emails == "" || @organization_name_for_emails.blank?
#CRIAR O OBJETO
return @organization_name_for_emails = "RETORNO QUE EU
QUISER DAR DA TABELA, NESTE CASO GOSTARIA DE DAR UM VALOR
chamado "Nome" para o campo "name" da tabela que irá receber no outro arquivo."
else
return @organization_name_for_emails
end
end
In this case it would have to work in this code snippet,
def confirm_email(event, participant)
@event = event
@organization = event.owner_organization
@participant = participant
**@organization_name_for_emails = organization_name_for_emails(@organization)
subject = I18n.t("views.mailer.event_registration.confirm_email.subject", :name_subject => @organization_name_for_emails.name)**
destination = AppConfig[:send_emails] ? @participant.email : AppConfig["default_email"]
mail(:to => destination, :subject => subject)
end
Has anyone ever had it, has a better solution or some hint?
Thank you!