I'm missing something obvious to a taglib programmer


#1

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 J.

The quiz/_form.rhtml contains:

<%= error_messages_for ‘quiz’ %>

Name
<%= text_field 'quiz', 'name' %>

Preamble presentation
<%= text_field 'quiz', 'preamble_presentation' %>

Postamble presentation
<%= text_field 'quiz', 'postamble_presentation' %>

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)
);


#2

David J. 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.