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

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Philip R. (Guest)
on 2006-01-09 12:16
(Received via mailing list)

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:

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

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?


Philip R.

Pricom Pty Limited  (ACN 003 252 275  ABN 91 003 252 275)
GPO Box 3411
Sydney NSW      2001
Mobile:  +61:(0)411-185-652
Fax:     +61:(0)2-8221-9599
E-mail:  removed_email_address@domain.invalid
Jens-Christian F. (Guest)
on 2006-01-09 12:25
(Received via mailing list)
>   <p><b>Author</b>
>   </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.