Skip to content

Instantly share code, notes, and snippets.

Avatar

Björn Weinbrenner bjoerne2

View GitHub Profile
View gist:1edbf6a00a8ec015fa43c5a1924e15e8
// empty fields will break you application
conversation = current_user.send_message(recipients, body, subject).conversation
View conversations_controller.rb
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'
View conversation_transient_model.rb
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
View mailboxer.rb
Mailboxer::Receipt.class_eval do
has_secure_token
end
View mailboxer.rb
Mailboxer.setup do |config|
...
config.notification_mailer = NotificationMailer
config.message_mailer = MessageMailer
end
View notification_mailer.rb
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
View gist:1855744e9dc6da9db1cf51f2b61a7d6f
mkdir <Anwendungsverzeichnis>
cd <Anwendungsverzeichnis>
composer create-project kenjis/codeigniter-composer-installer .
View gist:83ced5ac8bfd83947999f8bc1b761a8c
<VirtualHost *:80>
DocumentRoot /Users/bjoerne/Source/codeigniter-routing/public
ServerName codeigniter-routing.bjoerne.local
</VirtualHost>
View gist:d975b910b9530491cdd008e8a001dd94
<Directory "/Users/bjoerne/Source/codeigniter-routing">
Options FollowSymLinks Multiviews Indexes
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
View items.php
public function index()
{
}
public function show($id)
{
}
public function new_item()
{
You can’t perform that action at this time.