Class: SegmentsController
- Inherits:
-
ArtfullyOseController
- Object
- ActionController::Base
- ArtfullyOseController
- SegmentsController
- Defined in:
- app/controllers/segments_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/segments_controller.rb', line 19 def create :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 |
#destroy ⇒ Object
30 31 32 33 34 |
# File 'app/controllers/segments_controller.rb', line 30 def destroy :destroy, Segment current_organization.segments.find(params[:id]).destroy redirect_to segments_path end |
#index ⇒ Object
4 5 6 7 |
# File 'app/controllers/segments_controller.rb', line 4 def index :view, Segment @segments = current_organization.segments.paginate(:page => params[:page], :per_page => 10) end |
#show ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/segments_controller.rb', line 9 def show @segment = Segment.find(params[:id]) :view, @segment @people = @segment.people respond_to do |format| format.html { @people = @people.paginate(:page => params[:page], :per_page => 20) } format.csv { render :csv => Person.where(:id => @people.collect(&:id)).includes(:phones, :address, :tags).order('lower(people.last_name)'), :filename => "#{@segment.name}-#{DateTime.now.strftime("%m-%d-%y")}" } end end |
#tag ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/controllers/segments_controller.rb', line 36 def tag @segment = Segment.find(params[:id]) :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 |