search for: render_to_str

Displaying 20 results from an estimated 89 matches for "render_to_str".

2008 Feb 19
3
render_to_string in a controller test?
Hi all, I know that in general, view and controller tests should be isolated, such that controller specs don''t test views etc. However, I think I''ve run into a situation that might be an exception. My controller uses render_to_string to produce a chunk of HTML that it passes to a model to be processed. The controller then redirects the user to a different page. The results of the render_to_string are not seen by the user. Since the controller is calling render_to_string, I''ve been trying to test that it is...
2007 Apr 19
4
render_to_string in a model ?
I have a batch job that will call script/runner, I would like in this call to create html formated email and save it to the database. This is easy enough in a controller with yournewhost.email = render_to_string :action => "email_newhost_ready", :layout => false But render_to_string is only available in controller action pack, is there a easy way to render_to_string in a Model? Or is there a way to call a controller action from script/runner? -- Posted via http://www.ruby-forum.com/....
2012 May 28
1
rendering a partial inside another using render_to_string and (:formats) in controller
I want to clean my code by moving the duplicated lines : partial = render_to_string( :partial => "#{file}", :formats => [:html] ) to the pagination_partials function. ================================================= WORKING CODE: ================================================= def render_format_search_partial(file, options={}) # TODO remove this...
2007 Nov 30
5
render_to_string in an after filter
I''m using render_to_string in an after_filter, which renders a partial that is sent to a web service. Here''s the code: class MyController < ApplicationController after_filter :post_to_webservice def show # show logic end def post_to_webservice stuff = render_to_string :partial => ''stuff'...
2007 Nov 25
2
Fwd: Render_to_string from a worker
Hi, I am trying to generate a PDF from within a worker using PDF::Writer. In my controller I use render_to_string to create the pdf file however from what I understand render_to_string can only be used from a controller. Does anybody have any suggestions how I might be able to replicate this functionality in a worker? -- thanks, Felix -------------- next part -------------- An HTML attachment was scrubbe...
2011 Mar 06
2
render_views and render_to_string
Hey guys. One of my controller actions uses #render_to_string to send back a JSON response. When I try to spec this, Ruby raises a NoMethodError, saying that #render_to_string doesn''t exist in my controller action. Here''s the controller action, spec, and output: http://pastie.org/1640962 Any idea what I''m doing wrong? Thanks...
2006 May 26
8
calling render_to_string outside of controller
How can I call render_to_string outside of a controller. I''m stuck on this. I''ve nearly got my plugin finished but I can''t seem to get this to work. The method is in ActionController::Base but it is protected. -- Posted via http://www.ruby-forum.com/.
2010 Nov 04
0
Re: Train wreck getting render_to_string to work from foreign controller [SOLVED]
...troller. It seems like this is more work, but I can see that perhaps this was done by design as it forces me to more cleanly define what the controller actions render. On Wed, Nov 3, 2010 at 6:26 PM, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org>wrote: > I am calling render_to_string on an action of a different controller. I am > not sure if this is just in Rails 3 (I am using) or if it would have > presented in previous versions. I especially don''t understand why this > method should ignore :controller => "xx" and assume the current controller...
2010 Mar 17
3
rails+prawnto: setting :type to :prawn in a #render_to_string call not working
...t/worksheets/1.pdf This is great. However, now I need to add a feature where someone can request that I email them a PDF copy of a worksheet. In the interest of being DRY, I want to re-use all the prawn pdf generation code in my "show.pdf.prawn" view file. After poking around, I figured #render_to_string might do the job. The "email request" is implemented as the #email method/action in my controller. After grabbing the @worksheet object, I attempt to render the PDF as follows: worksheet = render_to_string :action => "show", :layout => false, :type => :prawn The #...
2006 Jul 11
1
Aggregate Controllers
Hi, I''m developing a dashboard like page and basically want to combine the result of multiple actions on a page. I''ve done this so far: def index r1 = render_to_string :action => "action1" r2 = render_to_string :action => "action2" render :text => r1+r2 end This works, but now I want to render from other controllers and this is where I''m stuck. So in my current controller lets call it "Dashboard", I want t...
2006 Mar 08
0
render_to_string() in a controller that isn''t default route?
Is it possible to call render_to_string() in a controller that is not set as the default route? The content controller is set in routes.rb: map.connect '''', :controller => "content". The content controller is calling a template controller, and I would like to be able to call render_to_string() within...
2009 Jun 23
0
render_to_string inside method shared across several controllers
I use render_to_string to generate short reports (in HTML) under certain conditions when users access my application. The reports are stored in the database and uses database information at the time they are generated (and can thus not be generated later, e.g; when you want to consult them). The reports are generated...
2011 May 17
1
rails render_to_string problem
Hi I`m trying to test my controller with rspec and always get an error. The error is in the render_to_string method call (without it test works fine). So could u please help me with that? users_controller.rb: def update @user.update_attributes!(params[:user]) redirect_to @user, :status => 202, :text => render_to_string(:partial => "users/show", :type => "json"...
2006 Jul 05
3
Calling render_to_string from a view
I''m playing around with a list of todos, which I want to render as <ul>''s that can nest to an arbitrary level, so I wrote this as a helper method: def print_todo(t) str = "<ul>\n\t<li>" str += render_to_string(:partial => ''todo'', :object => t) + "\n" t.children.each { |c| str += print_todo(c) } str += "\n\t</li>\n</ul>" return str end Unfortunately, I can''t call this from the view because of the render_to_s...
2006 Apr 20
0
Using render_to_string in other custom classes
...iews. The problem is when I want to publish via email I don''t want to ask the controller to render the views. This is what I tried to do: #/lib/myclass.rb class foo def build @rts = ActionController::Base.new file_x file_y end def file_x contents = @rts.render_to_string( path_to_my_template, self ) # and then I''d make the file etc end def file_y contents = @rts.render_to_string( path_to_my_template, self ) # and then I''d make the file etc end end the problem is that render_to_string is protected. Anyone know how I c...
2012 Mar 31
0
Missing Template Error on render_to_string - Rails 3.2.2
Hi, I''m trying to execute some javascript in the browser after completing my create action in the controller. Here''s how I''m doing it: In my controller: def create # exectue some code js = render_to_string(:layout => false, :template => "planned_meals/meal.js.coffee.erb") render :js => js end Two questions: 1) Am I going about it the right way? Should I be rendering the js differently? 2) WIth this implementation, everything works great, but I''m getting the foll...
2006 Mar 27
0
render_to_string troubles
...page(options, path = nil) # get rid of the existing one expire_page(options) # pull the page in as a string # set page parameters first: if options.has_key?(:params) options[:params].each_pair { |key, value| @params[key] = value } end page = render_to_string(options) # write the rendered content to the right place cache_page(page, options) end I can see the parameters have been set, but somehow the ''page'' parameter never gets processed by the funding action, so I end up with a 4 pages that all have the same content (t...
2006 Feb 20
3
Background work
...r/rails/actionpack/lib/action_controller/benchmarking.rb:53:in `render'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:53:in `render'' /vendor/rails/actionpack/lib/action_controller/base.rb:636:in `render_to_string'' I use render_to_string(:partial => ''datapoint'') to render the individual datapoints; whats odd is that render_to_string isnt working after redirect_to and render(). If I move the data-dump before these, it works fine and no errors appear. But whatever, although...
2007 Jun 11
0
render_to_string from within the worker?
Is it possible to call render_to_string from with in a brb worker? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070611/21c1821a/attachment.html
2006 May 26
0
render_to_string in model or script/runner?
Hey, is there a way to render a view to string in a model or is there a way to call a controller method (because there its possible to call render_to_string) in a model or externaly via script/runner ? Thx very much yo