Displaying 2 results from an estimated 2 matches for "messagethread".
Did you mean:
message_thread
2009 May 12
2
2.3 Nested Model Forms; build new without updating existing
...ing at the bottom of the thread.
The problem is that using fields_for generates form fields for each
existing record, and for one new record. In this case, there is no
need to edit existing messages - just a need to add new messages.
Does anybody know how to do this? Code is below.
Models:
class MessageThread < ActiveRecord::Base
has_many :messages
accepts_nested_attributes_for :messages, :allow_destroy => true
end
class Message < ActiveRecord::Base
belongs_to :message_threads
end
View (show.html.erb)
<% @message_thread.messages.each do |message| %>
<%= message.message %&g...
2008 Jan 04
5
Confused by the unit test results.
I''m testing the relation between two of my models: MessageThread
(parent), which has_many Message (children). When I run the following
test, it gives me an error:
---------------------------------
# test with a valid message
def test_valid_message_new
thread = MessageThread.new :title => ''awesome thread''
message = thread.message...