title: Rails 4, creating model entries by parsing xml file. Need current_user
body: <p>Fairly new with rails and am digging with a new web app. I'm parsing an XML file uploaded by the user. The parsing is done with a before_save call in the <code>upload.rb</code> model file.</p>
  
  <p>In the xml parsing function (<code>parse_xml</code>), my intention is to create a new model for the XML children elements and save all the attributes.</p>
  
  <p>The problem I am facing is this:</p>
  
  <p>As I understand, current_user is a controller helper function from devise and is not available in the models. The current model I have (Items Model containing the XML child elements) is tagged against a user_id (The current_user). The Items model does not have controllers at the moment and there is no way I can think of passing in the current_user's ID attribute into the Uploads model.</p>
  
  <p>Again, to my understanding, the Uploads model works on the <code>parse_xml</code> function before actually running the <code>@upload.save</code> function in the uploads_controller.rb.</p>
  
  <p>I'm not sure how to approach this problem. While I know <code>Thread.current[:user]</code> is suggested by a lot of people, as a learner, i prefer getting the right approach in my head rather than have a #facepalm moment when someone looks at my code :-)</p>
  
  <p>Update:
  Since Items records require an upload_id value, the records cannot be created until the Parent Upload record is created. Is this the reason why I also get an <code>uninitialized constant Upload::Item</code> error during the before_save execution in <code>Upload#create</code> route?</p>
  
  <p>I'm not sure where things are going wrong!</p>