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:
Photo Gallery
-
<% @photos.each do |photo| %>
<%= render(:partial => '/photos/list_item', :object => photo)%>
<% end %>
<% form_for(:photo, :url => formatted_photos_path(:format => ‘js’),
:html => { :multipart => true, :target => ‘upload_frame’}) do |form| %>
<%= render(:partial => ‘/photos/form’, :object => form) %>
<% end %>
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