odecio.hero
odecio.hero

Reputation: 37

acts_as_xslx: undefined method `to_xlsx' for #<String:0x007f206b7daf90>

Some of you guys ever used the gem 'acts_as_xslx'? https://github.com/randym/acts_as_xlsx

model

class Task < ActiveRecord::Base
  acts_as_xlsx

controller

tasks = @organization.tasks

respond_to do |format|
  format.xlsx {
         send_data tasks.report(start_period, end_period).to_xlsx.to_stream.read, :filename => 'posts.xlsx', :type => "application/vnd.openxmlformates-officedocument.spreadsheetml.sheet"
     }

ErrorMessage

undefined method `to_xlsx' for # string:0x007f206b7daf90

Upvotes: 1

Views: 326

Answers (1)

hd1
hd1

Reputation: 34657

Try:

tasks[0].to_xlsx.to_stream.read, :filename => 'posts.xlsx', :type => "application/vnd.openxmlformates-officedocument.spreadsheetml.sheet"

to_xlsx is duck-typed on ActiveRecord, not String, at least according to the test.

Upvotes: 1

Related Questions