Class: EmailPagePortlet

Inherits:
Portlet
  • Object
show all
Defined in:
app/portlets/email_page_portlet.rb

Instance Attribute Summary

Attributes inherited from Portlet

#connect_to_container, #connect_to_page_id, #controller

Instance Method Summary collapse

Methods inherited from Portlet

columns_for_index, default_template, default_template_path, enable_template_editor, form, get_subclass, handler, has_edit_link?, inherited, #inline_options, #instance_name, #portlet_type_name, render_inline, set_default_template_path, #store_errors_in_flash, #store_hash_in_flash, #store_params_in_flash, #type_name, types, #url_for_failure, #url_for_success

Instance Method Details

#deliverObject

—– Handlers ————————————————————–



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/portlets/email_page_portlet.rb', line 11

def deliver
  message = EmailMessage.new(params[:email_message])
  message.subject = self.subject
  message.body = "#{params[:email_page_portlet_url]}\n\n#{message.body}"    
  if message.save
    url_for_success
  else
    store_params_in_flash
    store_errors_in_flash(message.errors)
    url_for_failure
  end
end

#renderObject



3
4
5
6
7
8
# File 'app/portlets/email_page_portlet.rb', line 3

def render
  pmap = flash[instance_name] || params
  @email_message = EmailMessage.new pmap[:email_message]
  @email_message.errors.add_from_hash flash["#{instance_name}_errors"]
  @email_page_portlet_url = pmap[:email_page_portlet_url] || request.request_uri
end