Class: MailinglistController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- MailinglistController
- Defined in:
- app/controllers/mailinglist_controller.rb
Instance Method Summary collapse
- #add_address ⇒ Object
- #edit ⇒ Object
- #list ⇒ Object
- #new ⇒ Object
- #new_address ⇒ Object
- #openposting ⇒ Object
- #remove ⇒ Object
- #show ⇒ Object
Instance Method Details
#add_address ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/mailinglist_controller.rb', line 71 def add_address if request.post? @mailinglist = Mailinglist.find(session[:mailinglist_id]) # address = Address.new(params[:address]) @mailinglist.subscribe params[:address][:address] session[:user] = User.find session[:user].id redirect_to :action => "show", :id => @mailinglist else end end |
#edit ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/mailinglist_controller.rb', line 21 def edit @mailinglist = Mailinglist.find(params[:id]) if request.post? if @mailinglist.update_attributes(params[:mailinglist]) @mailinglist.mailinglist_class = MailinglistClass.find_by_id params[:mailinglist_class_id] if @mailinglist.save flash[:notice] = 'The mailinglist was successfully edited.' redirect_to :action => 'show', :id => @mailinglist end end end end |
#list ⇒ Object
34 35 36 37 38 |
# File 'app/controllers/mailinglist_controller.rb', line 34 def list @user = User.find session[:user_id] @mailinglists = @user.mailinglists # @mailinglist_pages, @mailinglists = paginate(:mailinglists) end |
#new ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/mailinglist_controller.rb', line 40 def new @user = User.find(session[:user_id]) @domain = @user.domain if request.post? @mailinglist = Mailinglist.new(params[:mailinglist]) @mailinglist.user = @user @mailinglist.mailinglist_class = MailinglistClass.find_by_id params[:mailinglist_class_id] if @mailinglist.save flash[:notice] = @mailinglist.name + ' was successfully added.' redirect_to :action => 'list' else flash[:error] = 'ERR: The mailing list could not be added' end else #@mailinglist = Mailinglist.new end end |
#new_address ⇒ Object
67 68 69 |
# File 'app/controllers/mailinglist_controller.rb', line 67 def new_address end |
#openposting ⇒ Object
63 64 65 |
# File 'app/controllers/mailinglist_controller.rb', line 63 def openposting end |
#remove ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/mailinglist_controller.rb', line 10 def remove if request.post? Mailinglist.find(params[:id]).destroy flash[:notice] = 'The mailinglist was successfully destroyed.' redirect_to :controller => 'account', :action => 'welcome' else flash[:notice] = 'Click Destroy to destroy the mailinglist.' redirect_to :action => 'edit', :id => params[:id] end end |
#show ⇒ Object
59 60 61 |
# File 'app/controllers/mailinglist_controller.rb', line 59 def show @mailinglist = Mailinglist.find(params[:id]) end |