Sha256: 843258c4e9aaa311faca188036551956030bea9fbe6a30983d609e9d0e3f5645

Contents?: true

Size: 774 Bytes

Versions: 4

Compression:

Stored size: 774 Bytes

Contents

class PostsController < ApplicationController
  respond_to :csv, :xls, :xlsx, :html

  def index
    respond_with(Post.all,
      :only => export_attributes)
  end

  def all_columns
    respond_with(Post.all.to_a)
  end

  def stream
    respond_with(Post.all,
      :stream => true,
      :only => export_attributes)
  end

  def stream_with_custom_url
    respond_with(Post.all,
      :stream => "/successful_redirect",
      :only => export_attributes)
  end

  # Used for stub/mocking a redirect request
  def successful_redirect
    # make rails 3.1 happy with a template
    # /views/posts/successful_redirect.html.erb
    render :text => "OK"
  end

protected
  def export_attributes
    %w[title visits conversion_rate published_on published expired_at]
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cloudxls-rails-0.6.2 spec/test_app/app/controllers/posts_controller.rb
cloudxls-rails-0.6.1 spec/test_app/app/controllers/posts_controller.rb
cloudxls-rails-0.6.0 spec/test_app/app/controllers/posts_controller.rb
cloudxls-rails-0.5.0 spec/test_app/app/controllers/posts_controller.rb