Forum: Ruby on Rails Modifying script generated scaffold output Books/Authors

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.
55f28e9c77b35b1539af6be60986b0e4?d=identicon&s=25 Philip Rhoades (Guest)
on 2006-01-09 11:16
(Received via mailing list)
People,

For my little book library db I find the rails script generated stuff
fine for most of my needs but there is one thing I couldn't figure
out . .

Part of the auto output of app/view/books/edit.rhtml is:

<%= start_form_tag :action => 'update', :id => @book %>
  <%= render :partial => 'form' %>
  <%= submit_tag 'Edit' %>
<%= end_form_tag %>

but I need to add in:

  <p><b>Author</b>
  <select name="book[author_id]">
   <% @authors.each do |author| %>
       <option value="<%= author.id %>"
         <%= ' selected' if author.id == @book.author_id %>>
         <%= author.last_name %>
         <%= author.first_name %>
         <%= author.other_name %>
       </option>
   <% end %>
  </select>

so I can update the author (in the author's table) if necessary.  If I
insert this code after the first line above it seems to update the
author OK (comment: shouldn't the button say "Update"?) but is there
some way to position the author label and field on the page
automatically like the other bookk fields?

Thanks,

Phil.
--
Philip Rhoades

Pricom Pty Limited  (ACN 003 252 275  ABN 91 003 252 275)
GPO Box 3411
Sydney NSW      2001
Australia
Mobile:  +61:(0)411-185-652
Fax:     +61:(0)2-8221-9599
E-mail:  phil@pricom.com.au
5085ba37ba624a788e04a842cd09bd6e?d=identicon&s=25 Jens-Christian Fischer (Guest)
on 2006-01-09 11:25
(Received via mailing list)
>   <p><b>Author</b>
[...snip...]
>   </select>

this should go into the _form.rthml file wich defines the actual
fields displayed

Also I found, that I always rewrite _form.rhtml an "hard-code" field
names etc in order to get the layout I want for my forms.

cu jc
This topic is locked and can not be replied to.