Woo. My first question.
I have a feeling I'm overlooking something pretty basic in the construction of my form. I'm using attachment_fu and can't get this form to pass anything besides the file data. A user has_many profiles and a profile has_many documents.
My form looks like this:
<%= error_messages_for :document %>
<% form_for([@user, @profile, @document], :html => {:multipart => true }) do |f| -%>
<p>
<label for="document">Upload A document:</label>
<%= f.file_field :uploaded_data %>
</p>
<%= f.label :description%>
<%= f.text_field :description%>
<p>
<%= submit_tag 'Upload' %>
</p>
<% end -%>
And here's the controller:
before_filter :require_user, :get_profile
def new
@document = @profile.documents.build
end
def create
@document = @profile.documents.build(params[:document])
if @document.save
flash[:notice] = 'Your document was successfully created.'
redirect_to document_url(@document)
else
render :action => :new
end
end
private
def get_profile
@user = current_user
@profile = @user.profiles.find(params[:profile_id])
end
The logs show all the image data getting posted, but I cannot pass the description or, more importantly, the profile_id, which is the foreign key in my document model. I was stuck on this all night, and can't think of anything fresh this morning. Any help would be great.