I followed this guide learning how to do file uploads to a secure directory on my server, rather than public (default). When I try to go to the show to view the links, I get:
undefined method `redocument' for #<ActionView::Helpers::FormBuilder:0xa2ae338>
near: <%= link_to File.basename(f.redocument.url), "/uploads/#{f.id}/#{File.basename(f.redocument.url)}" %>
It is having trouble rendering the link. Am I missing something here? Am I not supposed to copy this code line by line? They don’t specify whether or not I should be replacing ‘redocument’, but my model name is Entry, and the string the file’s link is stored is mv_link. Anyone have any idea what the fix is?
Update: Hopefully in the right direction
I changed all the cases of ‘f.redocument’ to ‘@entry.mv_link’. Now on the show page, the link is there. However when I click it and try to download, the path specified by the controller is broken. This is what the controller was
def download
path = "/#{redocument.redocument}"
send_file path, :x_sendfile=>true
end
What should I change this path to?
OK, going on a limb here… But I think you have something like this setup:
In your controller, you need to find the Entry and then get the path form the mv_link