hobo_ajax_response in web_method causing ActionView::MissingTemplate error. Ideas?

17 views
Skip to first unread message

Tim Griffin

unread,
Mar 6, 2015, 3:54:26 PM3/6/15
to hobo...@googlegroups.com
Hi all;

(Hobo 2.0.1)

I have a simple web_method defined that writes a PDF file to disk, and then responds with a javascript postamble:

  def generate_pdf

    # Generate the PDF here (write it to disk).

    # Notify user we're done.
    js = "notify(\"#{ t('caption') }\", \" #{ t('message') } \", \" #{icon} \");"
    hobo_ajax_response( :postamble => js )
  
  end

This is called with a POST:

  <form web-method="generate_pdf" method="POST">
    <submit id="btn_GeneratePDF" label="Generate PDF"/>
  </form>

While the method works and does its job, it's always raising a (harmless) exception:

  An ActionView::MissingTemplate occurred in instruments#generate_pdf:

  Missing template instruments/generate_pdf, application/generate_pdf with
    {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :dryml]}. Searched in:
  * "/webapps/polar/rels/20140812_00/app/views"
  * "/home/sshadmin/.rvm/gems/ruby-1.9.3-p545/bundler/gems/ckeditor-dc2a09e9e911/app/views"
  * "#<Dryml::Railtie::PageTagResolver:0x0000000a89b1b0>"

  actionpack (3.2.21) lib/action_view/path_set.rb:58:in `find'


Any ideas what might be missing to stop Rails looking for a template to render? 

Many thanks,
TIm




Ignacio Huerta

unread,
Mar 7, 2015, 11:07:08 AM3/7/15
to hobo...@googlegroups.com
Hi Tim,

Have you tried replacing hobo_ajax_response() with render?

render :js => "alert('hello')"

Warm regards,
Ignacio
> --
> You received this message because you are subscribed to the Google
> Groups "Hobo Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to hobousers+...@googlegroups.com
> <mailto:hobousers+...@googlegroups.com>.
> To post to this group, send email to hobo...@googlegroups.com
> <mailto:hobo...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/hobousers.
> For more options, visit https://groups.google.com/d/optout.

Tim Griffin

unread,
Mar 9, 2015, 8:26:33 AM3/9/15
to hobo...@googlegroups.com
Hi Ignacio;

Many thanks for the suggestion, but simply calling render doesn't allow me to update the part contexts I need to by using the web method. 

Oddly, having tested the very same web method, setup, and context on a staging box, I do not encounter the "missing template" issue. Bizarre!

So, it appears to be an environment problem. I will keep hunting and report back. But certainly in my staging environment, the normal "hobo_ajax_response" call works as intended with no complaints. 

Best regards,
Tim



You received this message because you are subscribed to a topic in the Google Groups "Hobo Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hobousers/vf4oSYOycdc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hobousers+...@googlegroups.com.
To post to this group, send email to hobo...@googlegroups.com.

Tim Griffin

unread,
Mar 9, 2015, 9:03:55 AM3/9/15
to hobo...@googlegroups.com
So, in looking more closely at the logs, I see that the calls that are being being correctly processed are handled as "AS JS" (where no template is needed), but the calls triggering the "MissingTemplate" error are being processed "AS HTML". And yet, in each case, the call originates from the same button on the same page! Sometimes they are being handled as JS and sometimes as HTML. 

So now I have to find out what the variable is. A browser issue? 

When I find out, I will definitely report back. 

Tim


This is the call that works:

Started GET "/instruments/1/135463/edit" for 64.26.134.201 at 2014-12-16 10:07:44 -0500
  1318 Processing by InstrumentsController#edit as HTML
  1319   Parameters: {"region_id"=>"1", "instrument_no"=>"135463"}
  1320   DRYML: Compiled app/views/instruments/edit.dryml in 0.69s
  1321 Checking for instrument image: /webapps/polar/scans/instruments/135463.pdf
  1322 Checking for instrument image: /webapps/polar/scans/instruments/135463.pdf
  1323   Rendered instruments/edit.dryml (3839.6ms)
  1324 Completed 200 OK in 3856.8ms (Views: 3594.6ms | ActiveRecord: 251.3ms)
  1325 Started POST "/instruments/385979/generate_pdf?page_path=%2Finstruments%2F1%2F135463%2Fedit&authenticity_token=CVYOVTX0pR7mBAjhWyhqc9ezNZWUsA4K8rh%2FWasv       HIY%3D&instrument_id=385979" for 64.26.134.201 at 2014-12-16 10:07:53 -0500
  1326 Processing by InstrumentsController#generate_pdf as JS
  1327   Parameters: {"render"=>{"0"=>{"part_context"=>"BAhbCDoXZGl2X2ltYWdlX2NvbnRyb2xzSSIWaW5zdHJ1bWVudDozODU5NzkGOgZFRlsA--722ee58851642f304aa6be4ca822a65576       976ea1", "id"=>"div-image-controls"}, "1"=>{"part_context"=>"BAhbCDomZGl2X2luc3RydW1lbnRfdHJhbnNpdGlvbl9idXR0b25zSSIWaW5zdHJ1bWVudDozODU5NzkGOgZFRlsA--74       1c5be8a0a417123b412c7f0b4f93bac9ec57eb", "id"=>"div-instrument-transition-buttons"}}, "page_path"=>"/instruments/1/135463/edit", "authenticity_token"=>"C       VYOVTX0pR7mBAjhWyhqc9ezNZWUsA4K8rh/WasvHIY=", "instrument_id"=>"385979", "id"=>"385979"}
  1328   Rendered lto_templates/_content.erb (0.6ms)
  1329   Rendered lto_templates/_attachments.erb (2.8ms)
  1330   Rendered lto_templates/_signature_block.erb (4.2ms)
  1331   Rendered lto_templates/_postal_address_grantors.erb (2.4ms)
  1332   Rendered lto_templates/_postal_address_grantees.erb (2.4ms)
  1333   Rendered lto_templates/_form13e_mortgage.erb (43.0ms)
  1334   Rendered lto_templates/_template_by_nature.erb (48.0ms)
  1335   Rendered instruments/print.erb (55.2ms)
  1336 Call part: div_image_controls. this-id = instrument:385979, locals = []
  1337 Checking for instrument image: /webapps/polar/scans/instruments/135463.pdf
  1338 Call part: div_instrument_transition_buttons. this-id = instrument:385979, locals = []
  1339 Checking for instrument image: /webapps/polar/scans/instruments/135463.pdf
  1340 Completed 200 OK in 2219.2ms (Views: 0.3ms | ActiveRecord: 9.2ms)

Yet, this is the call that fails:

Started GET "/instruments/1/135468/edit" for 64.26.134.201 at 2014-12-16 14:56:54 -0500
  5474 Processing by InstrumentsController#edit as HTML
  5475   Parameters: {"region_id"=>"1", "instrument_no"=>"135468"}
  5476 Checking for instrument image: /webapps/polar/scans/instruments/135468.pdf
  5477 Checking for instrument image: /webapps/polar/scans/instruments/135468.pdf
  5478   Rendered instruments/edit.dryml (3321.0ms)
  5479 Completed 200 OK in 3337.4ms (Views: 3214.7ms | ActiveRecord: 112.3ms)
  5480 Started POST "/instruments/385984/generate_pdf" for 64.26.134.201 at 2014-12-16 14:57:02 -0500
  5481 Processing by InstrumentsController#generate_pdf as HTML
  5482   Parameters: {"page_path"=>"/instruments/1/135468/edit", "authenticity_token"=>"8H8y3bua3H2vwi/M1Fhmk2tUlEKVwDrAtPAMzCtFmL0=", "instrument_id"=>"385984"       , "id"=>"385984"}
  5483   Rendered lto_templates/_content.erb (0.1ms)
  5484   Rendered lto_templates/_attachments.erb (1.7ms)
  5485   Rendered lto_templates/_postal_address_grantees.erb (2.1ms)
  5486   Rendered lto_templates/_postal_address_grantors.erb (1.9ms)
  5487   Rendered lto_templates/_signature_block.erb (2.6ms)
  5488   Rendered lto_templates/_signature_block.erb (1.4ms)
  5489   Rendered lto_templates/_postal_address_grantors.erb (1.9ms)
  5490   Rendered lto_templates/_postal_address_grantees.erb (1.9ms)
  5491   Rendered lto_templates/_form17e_transfer_of_lease.erb (35.4ms)
  5492   Rendered lto_templates/_template_by_nature.erb (35.6ms)
  5493   Rendered instruments/print.erb (40.9ms)
  5494 Completed 500 Internal Server Error in 2469.2ms


Ignacio Huerta

unread,
Mar 11, 2015, 8:19:06 AM3/11/15
to hobo...@googlegroups.com
Wild guess, maybe the user is using the middle click button? If the
button is a link, could you open it in a new tab, requesting that route
via a normal GET request instead of Ajax?

Warm regards,
Ignacio

El 09-03-2015 a las 14:03, Tim Griffin escribió:
> So, in looking more closely at the logs, I see that the calls that are
> being being correctly processed are handled as "AS JS" (where no
> template is needed), but the calls triggering the "MissingTemplate"
> error are being processed "AS HTML". And yet, in each case, the call
> originates from the same button on the same page! /Sometimes/ they are
> being handled as JS and /sometimes/ as HTML.
> Many thanks for the suggestion, but simply calling /render/ doesn't
> allow me to update the part contexts I need to by using the web method.
>
> Oddly, having tested the very same web method, setup, and context on
> a staging box, I do _not_ encounter the "missing template" issue.
> <mailto:hobousers%2Bunsu...@googlegroups.com>
> > <mailto:hobousers+...@googlegroups.com
> <mailto:hobousers%2Bunsu...@googlegroups.com>>.
> > To post to this group, send email to hobo...@googlegroups.com <mailto:hobo...@googlegroups.com>
> > <mailto:hobo...@googlegroups.com <mailto:hobo...@googlegroups.com>>.
> > Visit this group at http://groups.google.com/group/hobousers.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic
> in the Google Groups "Hobo Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/hobousers/vf4oSYOycdc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email
> to hobousers+...@googlegroups.com
> <mailto:hobousers%2Bunsu...@googlegroups.com>.

Tim Griffin

unread,
Mar 11, 2015, 12:56:57 PM3/11/15
to hobo...@googlegroups.com
A great suggestion, Ignacio. I looked again at the implementation, but the buttons are quite definitely rendered as Form Submit buttons. 

Still experimenting to figure out how to force the call to be handled as HTML instead of JS, to simulate the error. Why is it sometimes so difficult to replicate a problem! :)

Tim


To unsubscribe from this group and all its topics, send an email to hobousers+...@googlegroups.com.
To post to this group, send email to hobo...@googlegroups.com.

Ignacio Huerta

unread,
Mar 12, 2015, 3:59:05 AM3/12/15
to hobo...@googlegroups.com
Hmm, interesting.

I have another wild guess :P. What if a Javascript error/race condition
prevents the Ajax from working? You could try disabling JS in your
browser, loading that page and clicking the button.

Warm regards,
Ignacio
> > <mailto:hobousers%2Bunsu...@googlegroups.com
> <mailto:hobousers%252Buns...@googlegroups.com>>
> > > <mailto:hobousers+...@googlegroups.com
> <mailto:hobousers%2Bunsu...@googlegroups.com>
> > <mailto:hobousers%2Bunsu...@googlegroups.com
> <mailto:hobousers%252Buns...@googlegroups.com>>>.
> > > To post to this group, send email to hobo...@googlegroups.com <mailto:hobo...@googlegroups.com>
> <mailto:hobo...@googlegroups.com <mailto:hobo...@googlegroups.com>>
> > > <mailto:hobo...@googlegroups.com
> <mailto:hobo...@googlegroups.com>
> <mailto:hobo...@googlegroups.com
> <mailto:hobo...@googlegroups.com>>>.
> > > Visit this group at http://groups.google.com/group/hobousers.
> > > For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to a topic
> > in the Google Groups "Hobo Users" group.
> > To unsubscribe from this topic, visit
> > https://groups.google.com/d/topic/hobousers/vf4oSYOycdc/unsubscribe.
> > To unsubscribe from this group and all its topics, send an email
> > to hobousers+...@googlegroups.com
> <mailto:hobousers%2Bunsu...@googlegroups.com>
> > <mailto:hobousers%2Bunsu...@googlegroups.com
> <mailto:hobousers%252Buns...@googlegroups.com>>.
Reply all
Reply to author
Forward
0 new messages