Hi
   Thanks for replying.I could do it partially with the following 
modifications to my models and views

message_thread
====================
  has_many messages
  accepts_nested_attributes_for :messages


message
==============
  belongs_to message_thread
  has_many :document_messages
  has_many :documents, :through => :document_messages
  accepts_nested_attributes_for :documents,:reject_if => lambda {|a| 
a[:attachment].blank?}
  validates_presence_of :subject


      No other change. But the  problem is from the view I am not 
selecting any file for upload and not entering values for  'subject' . 
So surely the validation will fail and rerender my new action . My 
'create' action like

  def create
    @message_thread = MessageThreads.new(params[:message_thread])
    if @message_thread.save
      flash[:notice] = "Message sent successfully"
      redirect_to home_url
    else
      flash.now[:error] = @message_thread.errors.full_messages.join("<br 
/>")
      render :action => 'new'
    end
  end


      The problem is now the file_field disappears. What might be the 
cause?I am struggling with this for hours.Please help

Thanks
-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to