title: Deleting a public folder or file from a Rails3 view?
body: <p>I have a user model where users can upload their profile image, using the Paperclip gem. This all works fine and stores the file in the <code>/public/images/#{user.id}/medium</code> or original or small directory.</p>
  
  <p>However I need to create an method to be able to delete these files, could someone help me with this?</p>
  
  <p>Here is the code I have so far:</p>
  
  <p>app/views/users/index.html.erb:</p>
  
  <pre><code>&lt;%= link_to "Delete", method: :file_cleanup, action: :destroy %&gt;
  </code></pre>
  
  <p>app/controllers/users_controllers.rb:</p>
  
  <pre><code>def file_cleanup
      File.delete(Rails.root + 'public/#{current_user.image.url}')
      redirect_to :action =&gt; :edit
  end
  </code></pre>
  
  <p>I have not added any routes as the page seems to load without any errors.</p>