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| %>
<p><%= text_area_tag 'mail_to',nil,:cols => 10, :rows => 3,:style =>
"height:30px;"%></p>
<p>
<% f.fields_for :messages_attributes do |message| %>
<%= message.label :subject,'Subject' %>
<%= message.text_field :subject,:maxlength => 255 %>
<%#=end %>
</p>
<div class="attachments">
<p><strong>Attachments:</strong></p>
<%message.fields_for :documents do |a| %>
<%=a.file_field "attachment[]"%>
<%=a.file_field "attachment[]"%>
<%end%>
</div>
<div class="two-buttons">
<button type="submit" class="form-button2
fixed"><span>Send</span></button>
</div>
<p>Or <a href="#">Cancel</a></p>
<%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
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.