Sha256: 78e499ad6d6ad97546f78aa32ece9de733bbb30a48692ba77419c055c151221a

Contents?: true

Size: 1.29 KB

Versions: 23

Compression:

Stored size: 1.29 KB

Contents

class SegmentsController < ArtfullyOseController
  before_filter :load_tags, :only => [:show]

  def index
    authorize! :view, Segment
    @segments = current_organization.segments.paginate(:page => params[:page], :per_page => 10)
  end

  def show
    @segment = Segment.find(params[:id])
    authorize! :view, @segment
    @people = @segment.people.paginate(:page => params[:page], :per_page => 20)
    respond_to do |format|
     format.html
     format.csv { render :csv => @segment.people, :filename => "#{@segment.name}-#{DateTime.now.strftime("%m-%d-%y")}" }
   end
  end

  def create
    authorize! :create, Segment
    @segment = current_organization.segments.build(params[:segment])
    if @segment.save
      redirect_to @segment
    else
      flash[:error] = "List segment could not be created. Please remember to type a name."
      redirect_to session[:return_to]
    end
  end

  def destroy
    authorize! :destroy, Segment
    current_organization.segments.find(params[:id]).destroy
    redirect_to segments_path
  end

  def tag
    @segment = Segment.find(params[:id])
    authorize! :tag, Segment
    @segment.tag(params[:name])
    flash[:notice] = "We're tagging all the people in this list segment and we'll be done shortly.  Refresh this page in a minute or two."
    redirect_to @segment
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.21 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.20 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.19 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.18 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.17 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.16 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.15 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.12 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.11 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.10 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.9 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.8 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.7 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.6 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.5 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.4 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.3 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.2 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre.1 app/controllers/segments_controller.rb
artfully_ose-1.2.0.pre app/controllers/segments_controller.rb