title: RoR: Carrierwave Not Working/Saving to Database
body: <p>This is my hacked together attempt at getting Carrierwave to work right from watching Railscast. I have a Post Project page where users enter in details for a project. They can also upload a file to this page, and submit the project. So I am using a nested_form_for on the page.</p>
  
  <p>new_step_3.html.erb</p>
  
  <pre><code>&lt;%= nested_form_for @project, :html =&gt; {:multipart =&gt; true} do |f| %&gt;
    &lt;%= f.text_field :title %&gt;
    &lt;%= f.text_field :description %&gt;
  
      &lt;%= f.fields_for :document do |attachment_form| %&gt;
        &lt;%= attachment_form.file_field :title %&gt;
      &lt;% end %&gt;
  
    &lt;%= f.text_field :skills %&gt;
    &lt;%= f.submit 'Post Project' %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>project.rb model</p>
  
  <pre><code>attr_accessible :category, :title, :budget, :end_date, :description, :skills, :document, :days_lasting, :documents_attributes
  
  belongs_to :user
  has_many :posts
  has_many :documents, :as =&gt; :attachable
  
  validates_presence_of :category, :title, :description, :skills
  
  accepts_nested_attributes_for :documents
  </code></pre>
  
  <p>document.rb model</p>
  
  <pre><code>attr_accessible :project_id, :title, :document
  
  belongs_to :user
  belongs_to :project
  has_many :posts
  
  mount_uploader :document, DocumentUploader
  </code></pre>
  
  <p>projects_controller.rb</p>
  
  <pre><code>def create
  @project = current_user.projects.build(params[:project])
  
  respond_to do |format|
    if @project.save
      format.html { redirect_to project_step_4_path(:start =&gt; @project.id), notice: 'Project was successfully created.' }
      format.json { render json: @project, status: :created, location: @project }
    else
      format.html { render action: "new" }
      format.json { render json: @project.errors, status: :unprocessable_entity }
    end
  end
  </code></pre>
  
  <p>end</p>
  
  <p>Right now, when I try to submit the form, it will say unknown attribute: document
  app/controllers/projects_controller.rb:85:in `create'</p>
  
  <p>Running the command in Rails console works Document.create!(:document => File.new("test.jpg"))</p>