Sha256: 46317ebe6a9c7d823893b8c94e42d4b7468ba6dc080039015830759a2a94a461

Contents?: true

Size: 902 Bytes

Versions: 5

Compression:

Stored size: 902 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
    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, :contact_ids => params[:uids])
      end

      object.from_email ||= current_user.email

      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

  def determine_layout
    request.xhr? ? false : super
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
e9_crm-0.1.13 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.12 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.11 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.10 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.8 app/controllers/e9_crm/contact_emails_controller.rb