Forum: Ruby on Rails I'm missing something obvious to a taglib programmer ...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
David J. (Guest)
on 2006-03-14 12:04
(Received via mailing list)
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' %>

<!--[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 F. (Guest)
on 2006-03-14 15:58
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.
This topic is locked and can not be replied to.