Philip Rhoades
2006-Jan-09 10:14 UTC
[Rails] Modifying script generated scaffold output Books/Authors
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
Jens-Christian Fischer
2006-Jan-09 10:23 UTC
[Rails] Modifying script generated scaffold output Books/Authors
> > 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>[...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 -- InVisible GmbH, Langgr?tstrasse 172, 8047 Z?rich Phone: +41 44 401 09 30 http://www.invisible.ch http://not.invisible.ch -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2361 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060109/8aa67ade/smime.bin