Skip to content

Instantly share code, notes, and snippets.

View bjoerne2's full-sized avatar

Björn Weinbrenner bjoerne2

View GitHub Profile
@bjoerne2
bjoerne2 / gist:1edbf6a00a8ec015fa43c5a1924e15e8
Last active July 14, 2017 21:57
Erstellen einer Konversation
// empty fields will break you application
conversation = current_user.send_message(recipients, body, subject).conversation
def create
@conversation_transient_model = ConversationTransientModel.new(conversation_params)
if @conversation_transient_model.valid?
recipients = User.where(id: @conversation_transient_model.recipients)
conversation = current_user.send_message(recipients, @conversation_transient_model.body, @conversation_transient_model.subject).conversation
flash[:notice] = "Your message was successfully sent!"
redirect_to conversation_path(conversation)
else
flash[:error] = "Errors found!"
render action: 'new'
class ConversationTransientModel
include ActiveModel::Validations
include ActiveModel::Validations::Callbacks
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :recipients, :subject, :body
before_validation :clear_empty_recipients
validates :recipients, presence: true
validates :subject, presence: true
Mailboxer::Receipt.class_eval do
has_secure_token
end
Mailboxer.setup do |config|
...
config.notification_mailer = NotificationMailer
config.message_mailer = MessageMailer
end
class NotificationMailer < Mailboxer::NotificationMailer
def mail(headers = {}, &block)
headers[:template_path] = 'mailboxer/message_mailer'
receipts = @message.receipts.select { |receipt| receipt.receiver == @receiver && receipt.mailbox_type == 'inbox' }
raise "Unexpected number of receipts (= #{receipts.count}) for receiver #{@receiver.email}" if receipts.count != 1
receipt = receipts.first
headers[:from] = Mailboxer.default_from.sub '@', "-#{receipt.token}@"
super(headers, &block)
end
end
mkdir <Anwendungsverzeichnis>
cd <Anwendungsverzeichnis>
composer create-project kenjis/codeigniter-composer-installer .
<VirtualHost *:80>
DocumentRoot /Users/bjoerne/Source/codeigniter-routing/public
ServerName codeigniter-routing.bjoerne.local
</VirtualHost>
<Directory "/Users/bjoerne/Source/codeigniter-routing">
Options FollowSymLinks Multiviews Indexes
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
public function index()
{
}
public function show($id)
{
}
public function new_item()
{