I am getting this error and I can’t for the life of me figure out why
this
is happening. Even google is not spitting out anything useful.
This is what I have.
route:
map.resources :users, :member => { :edit_email => :get, :edit_password
=>
:get } do |user|
user.resources :pictures
end
Just some standard debugging advice: start taking stuff out until it
works. What happens if the form doesn’t contain upload fields? What if
create is empty?
map.resources :users, :member => { :edit_email => :get, :edit_password
=>
:get } do |user|
user.resources :pictures
end
I have a funny feeling this has something to do with the fact this is a
nested resource. I have found other people with the same problem and
they
were using nested resources as well but I could never find their
solution
:-).
Just some standard debugging advice: start taking stuff out until it
works. What happens if the form doesn’t contain upload fields? What if
create is empty?
I think I figured it out:
rake routes | grep picture
user_pictures GET /users/:user_id/pictures
{:action=>"index", :controller=>"pictures"}
formatted_user_pictures GET
/users/:user_id/pictures.:format
{:action=>“index”, :controller=>“pictures”}
POST /users/:user_id/pictures
{:action=>“create”, :controller=>“pictures”}
POST
/users/:user_id/pictures.:format
{:action=>“create”, :controller=>“pictures”}
new_user_picture GET /users/:user_id/pictures/new
{:action=>“new”, :controller=>“pictures”}
formatted_new_user_picture GET
/users/:user_id/pictures/new.:format {:action=>“new”,
:controller=>“pictures”}
edit_user_picture GET
/users/:user_id/pictures/:id/edit
{:action=>“edit”, :controller=>“pictures”}
formatted_edit_user_picture GET
/users/:user_id/pictures/:id/edit.:format {:action=>“edit”,
:controller=>“pictures”}
user_picture GET /users/:user_id/pictures/:id
{:action=>“show”, :controller=>“pictures”}
formatted_user_picture GET
/users/:user_id/pictures/:id.:format {:action=>“show”,
:controller=>“pictures”}
PUT /users/:user_id/pictures/:id
{:action=>“update”, :controller=>“pictures”}
PUT
/users/:user_id/pictures/:id.:format {:action=>“update”,
:controller=>“pictures”}
DELETE /users/:user_id/pictures/:id
{:action=>“destroy”, :controller=>“pictures”}
DELETE
/users/:user_id/pictures/:id.:format {:action=>“destroy”,
:controller=>“pictures”}
POST AND DELETE do not have methods for creating the URL… you have to
just
pass the :url with an :action and :controller. Does anyone know why
this is
the case?
I wish that was it but it is not the case. I am getting the same error
and
I do not think it matters if I set method or not because even if I do
not
set the method it is by default set as a post.
Any other suggestions please?
HELP
You need to specify the method used by the form tag:
<% form_for(:picture, user_pictures_path(params[:user_id]), :method =>
:post, :html => { :multipart => true }) do |f| -%>
<%= file_field :picture, :picture %>
<% end -%>
Jason
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.