Class: MailManager::ContactsController
Instance Method Summary
collapse
#delete, #undelete
#site_url, #title, #use_show_for_resources?
Instance Method Details
#create ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/mail_manager/contacts_controller.rb', line 43
def create
@contact = Contact.new(params[:contact])
if @contact.save
flash[:notice] = 'Contact was successfully created.'
redirect_to(mail_manager.contacts_path)
else
render :action => "new"
end
end
|
#destroy ⇒ Object
63
64
65
66
67
|
# File 'app/controllers/mail_manager/contacts_controller.rb', line 63
def destroy
find_contact
@contact.delete
redirect_to(mail_manager.contacts_url)
end
|
#edit ⇒ Object
39
40
41
|
# File 'app/controllers/mail_manager/contacts_controller.rb', line 39
def edit
find_contact
end
|
#index ⇒ Object
29
30
31
32
33
|
# File 'app/controllers/mail_manager/contacts_controller.rb', line 29
def index
@mailing_list = MailingList.find_by_id(params[:mailing_list_id])
params[:status] ||= 'active'
@contacts = Contact.search(params).paginate(:page => params[:page], :per_page => params[:per_page])
end
|
#new ⇒ Object
35
36
37
|
# File 'app/controllers/mail_manager/contacts_controller.rb', line 35
def new
@contact = Contact.new
end
|
#send_one_off_message ⇒ Object
21
22
23
24
25
26
27
|
# File 'app/controllers/mail_manager/contacts_controller.rb', line 21
def send_one_off_message
@contact = Contact.find(params[:id])
@mailing = Mailing.find(params[:mailing_id])
@mailing.send_one_off_message(@contact)
flash[:info] = "Test message sent to #{@contact.email_address_with_name}"
redirect_to mail_manager.contacts_path
end
|
#subscribe ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/controllers/mail_manager/contacts_controller.rb', line 6
def subscribe
if params[:contact].present? and params[:contact][:email_address].present?
@contact = MailManager::Contact.find_by_email_address(params[:contact][:email_address])
@contact = MailManager::Contact.new if @contact.nil?
@contact.update_attributes(params[:contact])
end
if params[:redirect_url].present? redirect_to params[:redirect_url]
else
redirect_to mail_manager.thank_you_path end
end
|
#update ⇒ Object
53
54
55
56
57
58
59
60
61
|
# File 'app/controllers/mail_manager/contacts_controller.rb', line 53
def update
find_contact
if @contact.update_attributes(params[:contact])
flash[:notice] = 'Contact was successfully updated.'
redirect_to(mail_manager.contacts_path)
else
render :action => "edit"
end
end
|