Search code examples
mysqlruby-on-rails-3activerecordreportruport

Rails Ruport using SQL


Guys I'm using Ruport gem for Ruby Reporting, I gone through basic coding and configuration as follows

class Project < ActiveRecord::Base
  acts_as_reportable
end

and in IRB console i tried as follows

irb(main):001:0> puts Project.report_table

and it's working fine to me.

Problem is instead of Model, how to write my own queries with SQL and add that to Ruport table object?


Solution

  • Finally I got this in Ruport API

    So, Instead of using Model directly for reporting like this

    irb(main):001:0> puts Project.report_table
    

    We can write our SQL queries to model like this,

    irb(main):001:0> puts Project.report_table_by_sql("SELECT * FROM projects")
    

    what I need was this syntax

    report_table_by_sql