Sha256: 6cd15b63dd9e8b2af315b600231f033e50f8ece29abc2074aabfada236568e55

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

# encoding: utf-8

module ConstructorCap
  class EmailsController < ConstructorCore::AdminController
    # TODO
    include ConstructorAuth::DeviseHelper   
    
    before_filter :authenticate_user!, :except => [:show, :add]
            
    layout 'constructor_core/application_admin', :except => [:show]    

    # TODO
    def index
      @user_signed_in = user_signed_in?
      @emails = Email.all
    end

    def new
      @email = Email.new
    end
    
    def show
      @email = Email.new  
      render :layout => false
    end
    
    def edit
      @email = Email.find(params[:id])
    end

    def create
      @email = Email.new(params[:email])

      if @email.save
        redirect_to emails_path, :notice => 'Email успешно добавлен.'
      else
        render :action => "new"
      end
    end
    
    def add
      @email = Email.new(params[:email])

      if @email.save
        redirect_to root_path, :notice => "Спасибо! Мы сообщим вам об открытии сайта."
      else
        render :action => "show", :layout => false
      end      
    end
    
    def update
      @email = Email.find(params[:id])

      if @email.update_attributes(params[:email])
        redirect_to emails_url, :notice => 'Email успешно обновлен.'
      else
        render :action => "edit"
      end
    end

    def destroy
      Email.find(params[:id]).destroy
      redirect_to emails_url, :notice => 'Email успешно удален.'
    end
    
    def delete_all
      Email.delete_all
      redirect_to emails_url
    end
  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
constructor-cms-0.2.1 cap/app/controllers/constructor_cap/emails_controller.rb