Code Monkey home page Code Monkey logo

as_csv's People

Contributors

danielfone avatar ibroadfo avatar parndt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

as_csv's Issues

`to_csv` output without headers

Hi!
First of all, thanks for this gem :)
I have an issue related to to_csv method output. I can't find a way to exclude headers from the output. I've tried to pass { write_headers: false } to csv_output, but without success.
Is there any possibility at the moment to avoid headers in serialized output?

Thanks!

Version 3 does not work in Rails 7

Hi,

First of all, thanks for your work on this gem!

I have noticed that since version 3, the gem is no longer loaded correctly for Rails 7 at least. I had to downgrade to 2.0.2 to have access to the as_csv method on my records. Looks like the railtie is not functioning correctly?

Relation .to_csv method isn't defined

Not sure what I'm doing wrong... I've installed the gem. ActiveModel::Serialization is included by models. Individual model to_csv method works fine. But to_csv on a relation doesn't work:

irb(main):014:0> Service < ActiveModel::Serialization
=> true
irb(main):015:0> Service.first.to_csv
=> "id,created_at,updated_at,type,name,gtfs_agency_id,logo,email,url,phone,start_or_end_area_id,trip_within_area_id,fare_structure,fare_details,archived\n1,2017-04-05 14:01:12 -0400,2017-04-20 13:34:28 -0400,Transit,Sample Transit Service,\"\",,,http://www.mbta.com,555-555-5555,,,,{:fare_table=>{}},false\n"
irb(main):016:0> Service.all.to_csv
undefined method `to_csv' for #<Service::ActiveRecord_Relation:0x007f9a4bbf5b20>
Did you mean?  to_s

From the readme it sounds like I should be able to just install the gem, include Serialization on my model, and call to_csv on a relationship. Am I missing something?

Thanks!

FYI I'm using Ruby 2.4.0, Rails 5.0.2

ActionController::UnknownFormat - ActionController::UnknownFormat

I am attempting to use this gem but getting an UnknownFormat error.

Are there steps I missed in configuring my app to use the gem?

# Enrollment Controller
  def roster
    respond_to do |format|
      format.csv { render csv: enrollments }
    end
  end

# Enrollment Model
def as_csv(options = {})
    attributes
end

I also have a serializer exposing attributes for enrollments, just trying to brain storm on next steps in debugging this. Any thoughts?

rais exception of missing template

I've added gem in my Gemfile
bundled new gems

Added method in my controller
def export_csv respond_to do |format| format.csv do format.csv { render csv: Widget.all } end end end

But when I open localhost:3000/export_csv.csv it returns this error

Missing template whatwebs/export_csv, application/export_csv with {:locale=>[:en], :formats=>[:csv], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:

  • "/home/anasir/MyWork/scrapetag/app/views"
  • "/home/anasir/.rvm/gems/ruby-2.3.1@scrapetag/gems/devise-4.2.0/app/views"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.