class UserController < ApplicationController
def download_image
@user = User.where(:id => params[:id]).first
file_path = @user.image_file_name
if !file_path.nil?
send_file @user.image.path
else
redirect_to :back
end
end
end
views
<a href="/download_image/<%=@user.id%>">Download</a><br/>
routes
get "/download_image/:id" => "user#download_image"
def download_image
@user = User.where(:id => params[:id]).first
file_path = @user.image_file_name
if !file_path.nil?
send_file @user.image.path
else
redirect_to :back
end
end
end
views
<a href="/download_image/<%=@user.id%>">Download</a><br/>
routes
get "/download_image/:id" => "user#download_image"
Comments
Post a Comment