David Johnson
2006-Mar-14 10:03 UTC
[Rails] I''m missing something obvious to a taglib programmer ...
I am trying to create, display and edit a referenced object''s text field on the same view as my root object. I have just about come to the conclusion that whoever invented of taglibs should be shot. quiz.preamble_presentation references a Presentation object instance. The Presentation object contains a property called text, among others. The generated form will display the ID of the presentation, but I cannot figure out for the life of me how to display/edit the contents of the text property of the presentation. What (I think) I want to display/edit is quiz.preamble_presentation.text Thanks in advance, David Johnson The quiz/_form.rhtml contains: <%= error_messages_for ''quiz'' %> <!--[form:quiz]--> <p><label for="quiz_name">Name</label><br/> <%= text_field ''quiz'', ''name'' %></p> <p><label for="quiz_preamble_presentation">Preamble presentation</label><br/> <%= text_field ''quiz'', ''preamble_presentation'' %></p> <p><label for="quiz_postamble_presentation">Postamble presentation</label><br/> <%= text_field ''quiz'', ''postamble_presentation'' %></p> <!--[eoform:quiz]--> The ddl for the tables is: create table presentations ( ID char(36) not null primary key, text varchar (1024), audio varchar (1024), visual varchar (1024) ); create table quizzes ( ID char(36) not null primary key, name varchar (255) not null, preamble_presentation char(36), postamble_presentation char(36), foreign key (preamble_presentation) references presentations(ID), foreign key (postamble_presentation) references presentations(ID) );
Alan Francis
2006-Mar-14 13:59 UTC
[Rails] Re: I''m missing something obvious to a taglib programmer ...
David Johnson wrote:> I am trying to create, display and edit a referenced object''s text field > on the same view as my root object. I have just about come to the > conclusion that whoever invented of taglibs should be shot.The two args to text_field are the object and the field, so I think you may need <%= text_field :quiz.preamble, :text %> I have no ruby with me at present, so if this doesn''t work, you may need: <% preamble = @quiz.preamble %> <%= text_field preamble, :text %> Lastly, you might need to just drop down to basics and use <% text_field_tag "quiz[preamble][text]", @quiz.preamble.text %> A. -- Posted via http://www.ruby-forum.com/.