Displaying 20 results from an estimated 50000 matches similar to: "render_to_string in model or script/runner?"
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
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 line to use the one
2007 Jun 07
0
Module Not Loaded by script/runner
Hello ~
I have a Model Action that I wish to call from script/runner. This
Model accesses another action in a module in the lib directory. If I
fire up script/console and execute Model.action it works perfectly,
but when I run the command via script/runner it cannot find the action
I want to call in my module.
If I run: script/runner "puts $:" The lib directory is shown, so the
2010 Nov 04
0
Re: Train wreck getting render_to_string to work from foreign controller [SOLVED]
Just for collective knowledge as I have found no info on this problem
online:
I solved this by adding an .html.erb file for the "missing template", since
by design or bug Rails3 will not find or render another controllers view (in
my experience). Then in the new html.erb file, I just put <%= render
"comparisons/display" %> because the views *are* able to find templates
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
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
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 +=
2006 Apr 20
0
Using render_to_string in other custom classes
I have a project where I''m publishing files. Once when the user
clicks publish via a URL and one when an email is received that tells
the app they want to publish again. Because the publishing requires
templates I have them in there own views. 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
2010 Mar 17
3
rails+prawnto: setting :type to :prawn in a #render_to_string call not working
Hello, my question is rails related though it is also somewhat
specific to the prawnto plugin (installed latest version as of
2010-03-15). I would ask on a prawnto forum/list if I knew where one
was.
Anyhow, I''m using rails 2.3.5 (with ruby 1.8.6 patchlevel 111) in an
app that is successfully using the prawnto gem (with the prawn gem
version 0.7.1). I''ve got a a
2006 Aug 03
0
render_to_string without render twice error
When I have a user go to a certain page, it will fork off a thread that
will perform some action. So the main thread will finish and render
:nothing => true .
Now, I want that forked off thread to render into a string a partial.
However, I cannot render_to_string :partial=> :foobar because I have
already rendered once. Is there anyway to get around this?
--
Posted via
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''
webservice_post(stuff)
end
I get a DoubleRenderError in the
2006 Apr 07
0
render_to_string and DoubleRender error
Hi all,
I''m trying to use render_to_string in a controller in order to make an output
file for download, and then redirect to a "Thank you for downloading" page. Of
cource, this is not possible since one cannot have a "render" and "redirect" in
the same action. Anyone know how I can do this?
-cal
2010 Jun 24
0
Rails3: render_to_string of a .html.erb when request is a json request raises MissingTemplate error
I''ve the following situation (which actually works in Rails 2.3.8 and
this is a result of the migration of our app to rails3):
I have a partial which is rendered a few times (imagine tr''s in a
table). On the clientside there''s a script that does a json request
for a specific row (jQuery + ajax dataType: ''json'' and type: ''POST'')
In
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 the
template controller, however I receive the error:
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 the same way regardless of
which controller has been accessed. Conditions for
2008 Oct 28
1
Script/Runner
I have a production site that has a couple of batch jobs, I have used
script/runner and cron to run these jobs. This works ok for jobs that
only run once overnight during off peak.
I am expiring sessions older than 30 mins every 15 mins using
script/runner, but I''m concerned about the hit of script/runner loading
up the whole rails environment, specifically since I only have a 256MB
2006 Jul 26
1
lesson learned: script/runner does not abort on failed require
After a fresh installation of an application, some utility scripts
run with script/runner quietly aborted right after their start. No
error message whatsoever, just a new shell prompt. The reason was an
uninstalled dependecy, but that was difficult to determine because
the load failure was not reported:
% ruby script/runner ''require "foobarbaz"''
%
Why
2006 May 21
0
expiring cache fragments using script/runner
I''ve just set up caching on my site and want to expire some of fragments on
an hourly basis.
I was going to use cron and script/runner to do this.
For other fragments that I am expiring, I am using expire_fragment inside a
sweeper class, something like:
class QuestionSweeper < ActionController::Caching::Sweeper
observe Question
def after_validation_on_update(question)
2007 Mar 26
2
Calling a controller action from script/console or runner
Is there a way to call or invoke a controller method from script/console
or script/runner? The reason is that I''d like to pre-cache some of the
actions on my controller.
The pseudo code below is what I''d like to be able to do:
class MyController < ApplicationController
caches_action :test
def test
puts ''Hi there''
end
end
script/console:
2006 Jan 27
0
Cache Sweepers and runner scripts that act on models?
I created a script that I call by ''./script/runner -e production
UpdateItems.get_new_items()'', which basically calls the model Item:
Item.create(attributes...)
I''ve set up a cache sweeper which removes caches after each
create/destroy/update on Item, and it works fine when accessing
controllers via the web server, but apparently doesn''t work via runner.