I’ve officially lost my mind. I’ve got a form that looks like this:
<%= error_messages_for :avatar %>
<% form_for(:avatar, :url => avatars_path, :html => { :multipart =>
true }) do |f| %>
<%= f.file_field :uploaded_data %>
<%= submit_tag "Upload" %> <% end %>
It uses attachment_fu to allow users to upload avatars. Everything
works fine when I’m in development, but in production the “create”
action is not invoked from some reason.
I’m using standard RESTful routes, like this:
map.resources :avatars
And I’ve got a “create” action in my avatars controller:
def create
@avatar = current_user.avatars.build params[:avatar]
respond_to do |format|
if @avatar.save
flash[:notice] = ‘Avatar was successfully created.’
format.html { redirect_to avatars_path }
format.xml { head :created, :location => avatars_path }
else
format.html { render :action => “new” }
format.xml { render :xml => @avatar.errors.to_xml }
end
end
end
In development, everything works as expected. My production.log file
shows me this following when I try to upload a new avatar:
Processing AvatarsController#new (for 203.98.22.198 at 2007-04-02
21:11:35) [GET]
Parameters: {“action”=>“new”, “controller”=>“avatars”}
Rendering within layouts/application
Rendering avatars/new
Completed in 0.15629 (6 reqs/sec) | Rendering: 0.01185 (7%) | DB:
0.14027 (89%) | 200 OK
Processing AvatarsController#index (for 203.98.22.198 at 2007-04-02
21:11:45) [GET]
Parameters: {“action”=>“index”, “controller”=>“avatars”}
Rendering content_typetext/htmlactionindexlayoutfalse within layouts/
application
Rendering avatars/index
Completed in 0.13149 (7 reqs/sec) | Rendering: 0.06164 (46%) | DB:
0.06527 (49%) | 200 OK
In development, things looks right, though:
Processing AvatarsController#new (for 127.0.0.1 at 2007-04-03
16:14:50) [GET]
Parameters: {“action”=>“new”, “controller”=>“avatars”}
Rendering within layouts/application
Rendering avatars/new
Completed in 0.93098 (1 reqs/sec) | Rendering: 0.23151 (24%) | DB:
0.15408 (16%) | 200 OK
Processing AvatarsController#create (for 127.0.0.1 at 2007-04-03
16:14:57) [POST]
Parameters: {“commit”=>“Upload”, “action”=>“create”,
“controller”=>“avatars”, “avatar”=>{“uploaded_data”=>#<File:/tmp/
CGI3922-0>}}
Redirected to http://localhost:3000/avatars
Completed in 0.54049 (1 reqs/sec) | DB: 0.06105 (11%) | 302 Found
Processing AvatarsController#index (for 127.0.0.1 at 2007-04-03
16:14:59) [GET]
Parameters: {“action”=>“index”, “controller”=>“avatars”}
Rendering content_typetext/htmllayoutfalseactionindex within layouts/
application
Rendering avatars/index
Completed in 0.96327 (1 reqs/sec) | Rendering: 0.49423 (51%) | DB:
0.05750 (5%) | 200 OK
I just don’t get why the “create” action isn’t being invoked in
production with this code. Is there something wrong with my form that
I’m missing? I can’t seem to figure this one out.
Any help would be greatly appreciated.