samedi 17 octobre 2015

How to send a reply-email from inside Rails dynamically

Hello i am trying to create an email-system. I am using Griddler gem as an email processor to create and save emails sent to a certain address in the db.

What i am trying to achieve now. Is reply to those emails but without saving the actual email in the db.

this is what i have so far. mailbox_controller.rb

class MailboxController < ApplicationController
  before_filter :is_admin?
  def index
    @mailbox  = Mailbox.all
  end

  def show
    @mailbox = Mailbox.find_by(id: params[:id])
    @reply = Mailbox.new
  end

  def destroy
    Mailbox.find(params[:id]).destroy
    flash[:notice] = "Email deleted"
    redirect_to mailbox_index_url
  end


end

and in my show view

<div class="row">
    <div class="large-12">
      <%= form_for @reply, url: new_mailbox_path do |f| %>
        <div class="field panel">
          <%= f.label :body %><br>
          <%= f.text_area :body, size: "30x10" %>
        </div>
      <% end %>
    </div>
  </div>

i am also thinking about using hidden fields to input email address dynamically. is there a different,better way to dynamically create attributes save content temporarily until i press the send button?

Aucun commentaire:

Enregistrer un commentaire