This one’s really got me scratching my head.
I’ve got a button_to_function (in application.rhtml) that opens a new window containing a file from the public directory. Or at least that’s what it’s supposed to do. It always launches a new window. Sometimes the file loads as expected. Sometimes the window launches that then I get an ActionController error (in the newly launched window) saying ‘no action responded’ to the file name.
I can reproduce the behavior, but have no idea why it’s behaving the way it is and would really appreciate it if someone could help me understand it.
I’ll post the code below. It’s not very interesting. What is interesting is this.
If the URL just calls the controller with no ‘/’ at the end, the new window is launched and the file opened in it. With the code below, if my URL is ‘http://localhost:3000/admin’ everything works.
OTOH, if my URL is ‘http://localhost:3000/admin/’ or ‘http://localhost:3000/index’ the new window is launched but I get the ActionController error saying ‘no action responded’ to the file name.
I can’t figure out why including the action in the URL, or even just having the ‘/’ at the end of the controller name in the URL, is causing the window.open javascript call to trigger a call to a Rails controller/action.
Anybody? I sure would appreciate any help / explanation.
Thanks!
Bill
--------- controller ------------
class AdminController < ApplicationController
def index end
end
-------------- index.rhtml ---------------
PDF Created!
<%= button_to_function “View/Print PDF”, “viewPDF()”, :class => ‘submit-btn’ %>
--------- application.rhtml -------------
YourTimeMatters.com <%= javascript_include_tag :defaults %> <%= stylesheet_link_tag 'scaffold' %><%= flash[:notice] %>
<%= @content_for_layout %>