I tried following an attachment_fu ajax tutorial online but am having
trouble displaying the validations. Here is the tutorial:
http://khamsouk.souvanlasy.com/2007/5/1/ajax-file-uploads-in-rails-using-attachment_fu-and-responds_to_parent
The validations work but are not displayed...
Here''s my index.rhtml page:
<h1>Photo Gallery</h1>
<div class="box">
<div class="title_bar">Photos</div>
<ul id="photos">
<% @photos.each do |photo| %>
<%= render(:partial => ''/photos/list_item'', :object
=> photo)%>
<% end %>
</ul>
<div id="column_fix"></div>
</div>
<div class="box">
<div class="title_bar">Upload</div>
<%= error_messages_for :photo %>
<% form_for(:photo, :url => formatted_photos_path(:format =>
''js''),
:html => { :multipart => true, :target =>
''upload_frame''}) do |form| %>
<%= render(:partial => ''/photos/form'', :object =>
form) %>
<% end %>
<iframe id=''upload_frame'' name="upload_frame"
style="width:1px;height:1px;border:0px"
src="about:blank"></iframe>
</div>
and the create action in my controller:
def create
@photo = Photo.new(params[:photo])
@user = User.find(session[:user_id])
respond_to do |format|
if @user.photos << @photo
flash[:notice] = ''Photo was successfully created.''
format.html { redirect_to photo_url(@photo) }
format.xml { head :created, :location => photo_url(@photo) }
format.js do
responds_to_parent do
render :update do |page|
page.insert_html :bottom, "photos", :partial =>
''photos/list_item'', :object => @photo
page.visual_effect :highlight, "photo_#{@photo.id}"
end
end
end
else
format.html { render :action => "new" }
format.xml { render :xml => @photo.errors.to_xml }
format.js do
responds_to_parent do
render :update do |page|
end
end
end
end
end
end
--
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
-~----------~----~----~----~------~----~------~--~---