So I think I''m making this a lot harder than it really is. I am still
learning the ins and out of Rails so and I think I''m just missing
something easy.
I am trying to create an edit form that allows a user to select a photo
album name, but rather than having them go to a new page I have the
first form post to the same page (I don''t know if this would be easier
in AJAX if so any help here would be great since I am in the process of
learning that as well). When the page reloads the new form is displayed.
I have followed several examples and when they do work the form fields
are empty. Here is the code:
Album.rhtml
...
<% if request.post? %>
<tr><td>
<% disp = params[:album] %>
Album Param: <%= disp %> # used this to verify that the correct id
was being sent to the form and it currently works
</td></tr>
<tr>
<% form_for :album, :action => ''update_album'', :id
=> params[:album]
do %>
<%= render :partial => ''form'' %>
</tr>
<tr>
<td colspan=''5'' align=''right''>
<%= submit_tag "Apply Changes" %>
<% end %>
</td></tr>
<% else %>
<tr><td>
<% form_for :album, :url => { :action => ''album'',
} do |form| %>
<%= @albums = Album.list_albums
form.collection_select('''' , @albums, :id,
:album_name)%>
<%= submit_tag "Update Album", :confirm =>
''Are you sure?''
%>
<% end %>
</td></tr>
<% end %>
...
_form.rhtml <-- I believe this is the standard _form.rhtml from the
rails scaffold
<%= error_messages_for ''album'' %>
<!--[form:gallery]-->
<td><label for="album_name">Name</label><br/>
<%= text_field ''album'', ''album_name''
%></td>
<td><label for="created_date">Created
date</label><br/>
<%= date_select ''album'', ''created_date''
%></td>
<td align=''center''><label
for="hide">Hide</label><br/>
<%= check_box ''album'', ''hide''
%></td>
<td align=''center''><label
for="private">Private</label><br/>
<%= check_box ''album'', ''private'' %>
<%= hidden_field ''album'', ''user_id'',
:value => 1 %></td>
<!--[eoform:gallery]-->
Any help is greatly apriciated.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---