Attaching multiple files at a time on a has_many through

Hi
My models are

class MessageThread < ActiveRecord::Base
has_many :messages
accepts_nested_attributes_for :messages
end

class Message < ActiveRecord::Base
has_many :message_participants
belongs_to :message_thread
has_many :document_messages
has_many :documents, :through => :document_messages
accepts_nested_attributes_for :documents
end

class Document < ActiveRecord::Base
has_attached_file :attachment,
:storage => :database
default_scope select_without_file_columns_for(:attachment)
has_many :document_messages
has_many :messages, :through => :document_messages
end

class DocumentMessage < ActiveRecord::Base
belongs_to :message
belongs_to :document
end

I have to make an email compose interface. So my messages controller

new and create(sample) action like

def new
@message_thread = MessageThread.new
@message = @message_thread.messages.build
end

def create
MessageThread.create(params[:message_thread])
end

And the new form I tried like

<%form_for @message_thread, :url => { :action => “create” },:html =>
{:multipart => true} do |f| %>

<%= text_area_tag ‘mail_to’,nil,:cols => 10, :rows => 3,:style =>
“height:30px;”%>



<% f.fields_for :messages_attributes do |message| %>
<%= message.label :subject,‘Subject’ %>
<%= message.text_field :subject,:maxlength => 255 %>
<%#=end %>



Attachments:


<%message.fields_for :documents do |a| %>
<%=a.file_field “attachment[]”%>
<%=a.file_field “attachment[]”%>
<%end%>


Send

Or Cancel


<%end%>

And I am getting error

NoMethodError in MessagesController#create

undefined method `with_indifferent_access’ for “”:String

Please help me to correct this

Thanks in advance
Tom