Skip to content

Instantly share code, notes, and snippets.

@francois
Created June 18, 2009 18:38
Show Gist options
  • Select an option

  • Save francois/132101 to your computer and use it in GitHub Desktop.

Select an option

Save francois/132101 to your computer and use it in GitHub Desktop.
diff --git a/app/controllers/titles_controller.rb b/app/controllers/titles_controller.rb
index f681879..03dd863 100644
--- a/app/controllers/titles_controller.rb
+++ b/app/controllers/titles_controller.rb
@@ -23,12 +23,10 @@ class TitlesController < ApplicationController
@msg = "Title " + @tsr.title_no + " is being downloaded."
end
- respond_to do |format|
- format.js {render :text => @msg}
- if @success
- logger.info "Request to send_file: " + @tsr.title_no.to_f.to_s
- sendfile('titles/' + @tsr.title_no.to_f.to_s + '.pdf')
- end
+ if File.file?('titles/%f.pdf', @tsr.title_no.to_f) then
+ send_file('titles/' + @tsr.title_no.to_f.to_s + '.pdf', :disposition => "inline")
+ else
+ render :action => :not_available, :status => :missing
end
end
diff --git a/app/views/title_searches/_search_results.html.erb b/app/views/title_searches/_search_results.html.erb
index 1f9dbe0..d5b67f8 100644
--- a/app/views/title_searches/_search_results.html.erb
+++ b/app/views/title_searches/_search_results.html.erb
@@ -12,13 +12,11 @@
<td><%=h result.title_type %></td>
<td><%=h result.title_status %></td>
- <td><%= link_to_remote(image_tag("/images/icons/page_white_acrobat.png", :border => 0),
- :url => titles_url(:id => result.title_no, :tsid => result.title_search_id.to_s, :sid => result.session_id),
- :method => :download,
- :update => 'request_msg') %></td>
+ <td><%= link_to(image_tag("/images/icons/page_white_acrobat.png", :border => 0),
+ download_title_url(:id => result.title_no, :tsid => result.title_search_id.to_s, :sid => result.session_id)) if @title_available %></td>
<td><%= link_to_remote(image_tag("/images/icons/email_go.png", :border => 0),
- :url => titles_url(:id => result.title_no, :tsid => result.title_search_id.to_s, :sid => result.session_id),
+ :url => download_title_url(:id => result.title_no, :tsid => result.title_search_id.to_s, :sid => result.session_id),
:method => :email,
:update => 'request_msg') %></td>
diff --git a/config/routes.rb b/config/routes.rb
index 44f0e91..bb6a6c4 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -35,6 +35,6 @@ ActionController::Routing::Routes.draw do |map|
map.resources :title_searches
- map.resources :titles, :only => [:download, :email]
+ map.resources :titles, :only => [:download, :email], :member => {:download => :post, :email => :post}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment