Sha256: 105a615038be90e48a292b432ce9d83da42f8eb1024f57992af471652e80e4af

Contents?: true

Size: 839 Bytes

Versions: 1

Compression:

Stored size: 839 Bytes

Contents

class E9Crm::ContactEmailsController < E9Crm::ResourcesController
  defaults

  respond_to :js, :html

  def create
    create! do |success, failure|
      success.html { redirect_to :admin_sent_email }
      success.js { head :ok }
    end
  end

  protected

  def build_resource
    get_resource_ivar || begin
      object = if params[resource_instance_name]
        ContactEmail.new(params[resource_instance_name] || {})
      else
        ContactEmail.new_from_template(template, :from_email => current_user.email, :contact_ids => params[:uids])
      end

      object.valid?

      set_resource_ivar(object)
    end
  end

  # throw record_not_found if there's no template.  #new requires email_template_id
  # be passed in params (and also contact_ids)
  def template
    @_template ||= EmailTemplate.find(params[:etid])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
e9_crm-0.1.4 app/controllers/e9_crm/contact_emails_controller.rb