Chris Richards
2008-Sep-12 09:12 UTC
Using Rails view templates without the Controller? How?
Hi I have a SupplierBreakdownReport class that uses a rails view to generate a html report, which then is converted into a PDF, as follows : class ReportGeneratorController < ApplicationController .. def supplier_breakdown_report ... if request.post? @report SupplierBreakdownReport.new(@start_date,@end_date,params[:retailer_trivial_matrices]) html = render_to_string :action=>"supplier_breakdown_report" pdf = generate_pdf(html) ... end end .. end I now want to detach this report generation from the the Rails controller so that I can generate these report in the background (maybe using BackgroundDRB) without having to go through the rails controller. I first though about using just ERB but this won''t suffice as custom rails methods like "render :partial=>...." wont work with ERB. I need the full power of the rails templating system without going through the controller. Does anyone have any ideas how to do this? Any help is appreciated. Thanks Chris -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Erol Fornoles
2008-Sep-13 17:11 UTC
Re: Using Rails view templates without the Controller? How?
On Sep 12, 5:12 pm, Chris Richards <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi > > I have a SupplierBreakdownReport class that uses a rails view to > generate a html report, which then is converted into a PDF, as follows : > > class ReportGeneratorController < ApplicationController > > .. > > def supplier_breakdown_report > ... > if request.post? > @report > SupplierBreakdownReport.new(@start_date,@end_date,params[:retailer_trivial_matrices]) > html = render_to_string :action=>"supplier_breakdown_report" > pdf = generate_pdf(html) > ... > end > end > > .. > > end > > I now want to detach this report generation from the the Rails > controller so that I can generate these report in the background (maybe > using BackgroundDRB) without having to go through the rails controller. > > I first though about using just ERB but this won''t suffice as custom > rails methods like "render :partial=>...." wont work with ERB. I need > the full power of the rails templating system without going through the > controller. > > Does anyone have any ideas how to do this? Any help is appreciated. > > Thanks > Chris > -- > Posted viahttp://www.ruby-forum.com/.Cells *might* work: http://cells.rubyforge.org/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mike Zaschka
2008-Sep-14 20:33 UTC
Re: Using Rails view templates without the Controller? How?
Chris Richards wrote:> Hi > > I have a SupplierBreakdownReport class that uses a rails view to > generate a html report, which then is converted into a PDF, as follows : > > class ReportGeneratorController < ApplicationController > > .. > > def supplier_breakdown_report > ... > if request.post? > @report > SupplierBreakdownReport.new(@start_date,@end_date,params[:retailer_trivial_matrices]) > html = render_to_string :action=>"supplier_breakdown_report" > pdf = generate_pdf(html) > ... > end > end > > .. > > end > > I now want to detach this report generation from the the Rails > controller so that I can generate these report in the background (maybe > using BackgroundDRB) without having to go through the rails controller. > > I first though about using just ERB but this won''t suffice as custom > rails methods like "render :partial=>...." wont work with ERB. I need > the full power of the rails templating system without going through the > controller. > > Does anyone have any ideas how to do this? Any help is appreciated. > > Thanks > ChrisWhy aren''t you making the report available as an url? So you can have the report at http://yourdomain/report and call this url from your backgroundjob with html = Net::HTTP.get(''www.yourdomain.com'', ''report'') Let Rails do its stuff the right way and just consume the outcome. Not tested, but that would be my apporach. Mike -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---