Class: Campagne::CampagneListsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Campagne::CampagneListsController
- Defined in:
- app/controllers/campagne/campagne_lists_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
20 21 22 23 24 |
# File 'app/controllers/campagne/campagne_lists_controller.rb', line 20 def create @list = CampagneList.new(params[:campagne_campagne_list]) flash[:notice] = 'List was successfully created.' if @list.save respond_with(@list, :location => campagne_campagne_lists_path) end |
#import ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/campagne/campagne_lists_controller.rb', line 26 def import @list = CampagneList.find(params[:id]) if request.post? emails = params[:emails].split("\r\n") emails.each do |email| if contact = CampagneContact.find_by_email(email) if !@list.contacts.exists?(contact.id) @list.contacts << contact @list.save end else @list.contacts.create(:email => email) end end redirect_to campagne_campagne_lists_path, :notice => "Contacts were successfully imported." end end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/campagne/campagne_lists_controller.rb', line 6 def index @lists = CampagneList.all end |
#new ⇒ Object
15 16 17 18 |
# File 'app/controllers/campagne/campagne_lists_controller.rb', line 15 def new @list = CampagneList.new respond_with(@list) end |
#show ⇒ Object
10 11 12 13 |
# File 'app/controllers/campagne/campagne_lists_controller.rb', line 10 def show @list = CampagneList.find(params[:id]) respond_with(@list) end |