Displaying 2 results from an estimated 2 matches for "sales_reports".
2009 Apr 16
0
how to convert the find_by_sql code to the find code
I want to convert following query into pure ruby one i.e. by using find
@us_state_sales=SalesReport.find_by_sql("SELECT z.state,
sum(s.royalty_price) as royalty_price, sum(s.units) as units FROM
sales_reports s, zip_codes z
WHERE royalty_currency = ''USD'' && z.zip_code=s.postal_code GROUP BY
z.state ORDER BY royalty_price desc LIMIT 10")
i try something like this
@us_state_sales1=SalesReport.find(:all, :select=>" zip_codes.state,
sum(sales_reports.royalty_p...
2006 Oct 13
2
Splitting controller
I''m trying to split controller into several files. I tried extracting
methods into separate files and then requiring them in main
controller, but this doesn''t seem to work.
controllers/reports/sales_reports.rb:
class ReportController < ApplicationController
def sales
end
end
controllers/reports/purchases_reports.rb:
class ReportController < ApplicationController
def purchases
end
end
controllers/report_controller.rb:
require ''reports/sales_reports''
require ''r...