I am trying to save the displayed web page through a click on a button (just like when you click on the "Save As" button in the browser), but I can't figure out this error:
Missing template shipments/save_page_xls, application/save_page_xls with {:locale=
[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee, :haml]}. Searched i
n: * "/home/andres/Documents/Aptana Studio 3 Workspace/EcuadorCargo/app/views" * "
/var/lib/gems/1.9.1/gems/devise-2.1.2/app/views" * "/var/lib/gems/1.9.1/gems/twitt
er-bootstrap-rails-2.1.1/app/views"
I think the problem is that the render function should not be in controller, or that the render function is not finding the proper layout file. I based on this page rails: emulate "Save page as" behaviour
View (in haml):
= link_to "Save as XLS", save_page_xls_shipments_path, :class => 'btn btn-primary'
Controller file:
class ShipmentsController < ApplicationController
def save_page_xls
#this is the magic line!
send_data(render, :filename => "archivo.xls")
end
end
Routes:
resources :shipments, :only => :index do
collection do
get 'save_page_xls'
end
end