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 pictures/new.html.erb <% form_for(:picture, user_pictures_path(params[:user_id]), :html => { :multipart => true }) do |f| -%> <%= file_field :picture, :picture %> <% end -%> pictures_controller.rb def create @picture = @user.pictures.build params[:picture] @picture.file_name = @user.nickname + Time.now.strftime("%Y%m%d%H%M%S") if (@user.pictures << @picture.save) redirect_to user_url(@user) else render :action => :new end end HELP :-) -- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org Blog: http://www.kopanas.com Conference: http://www.cusec.net Twits: http://www.twitter.com/kopanas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2007-Dec-12 13:42 UTC
Re: "Only get, put, and delete requests are allowed."?
On Dec 11, 2007 10:04 PM, John Kopanas <kopanas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > pictures/new.html.erb > > <% form_for(:picture, user_pictures_path(params[:user_id]), :html => { > :multipart => true }) do |f| -%> > <%= file_field :picture, :picture %> > <% end -%> > > pictures_controller.rb > > def create > @picture = @user.pictures.build params[:picture] > @picture.file_name = @user.nickname + Time.now.strftime("%Y%m%d%H%M%S") > > if (@user.pictures << @picture.save) > redirect_to user_url(@user) > else > render :action => :new > end > end > > > HELP :-) > > -- > John Kopanas > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > Blog: http://www.kopanas.com > Conference: http://www.cusec.net > Twits: http://www.twitter.com/kopanas > > > > 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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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? :-( On Dec 12, 2007 8:42 AM, Jason Roelofs <jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 11, 2007 10:04 PM, John Kopanas <kopanas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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 > > > > pictures/new.html.erb > > > > <% form_for(:picture, user_pictures_path(params[:user_id]), :html => { > > :multipart => true }) do |f| -%> > > <%= file_field :picture, :picture %> > > <% end -%> > > > > pictures_controller.rb > > > > def create > > @picture = @user.pictures.build params[:picture] > > @picture.file_name = @user.nickname + Time.now.strftime("%Y%m%d%H%M%S") > > > > if (@user.pictures << @picture.save) > > redirect_to user_url(@user) > > else > > render :action => :new > > end > > end > > > > > > HELP :-) > > > > -- > > John Kopanas > > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > > > Blog: http://www.kopanas.com > > Conference: http://www.cusec.net > > Twits: http://www.twitter.com/kopanas > > > > > > > > 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 > > > > >-- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org Blog: http://www.kopanas.com Conference: http://www.cusec.net Twits: http://www.twitter.com/kopanas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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? ///ark --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I did that... I have the following and I am still having the same problem: new.html.erb <% form_for(:picture, user_pictures_path(params[:user_id]), :html => { :method => :post }) do |f| -%> <p><%= submit_tag ''Upload'' %></p> <% end -%> pictures_controller.rb def create render :text => "hello" end routes.rb 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 :-). Any feedback? On Dec 12, 2007 12:30 PM, Mark Wilden <mark-OCn100epQuBBDgjK7y7TUQ@public.gmane.org> wrote:> > 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? > > ///ark > > >-- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org Blog: http://www.kopanas.com Conference: http://www.cusec.net Twits: http://www.twitter.com/kopanas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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? On Dec 12, 2007 12:37 PM, John Kopanas <kopanas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I did that... I have the following and I am still having the same problem: > > new.html.erb > > <% form_for(:picture, user_pictures_path(params[:user_id]), :html => { > :method => :post }) do |f| -%> > > <p><%= submit_tag ''Upload'' %></p> > > <% end -%> > > pictures_controller.rb > > def create > render :text => "hello" > end > > routes.rb > > 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 > :-). > > Any feedback? > > > > On Dec 12, 2007 12:30 PM, Mark Wilden < mark-OCn100epQuBBDgjK7y7TUQ@public.gmane.org> wrote: > > > > > 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? > > > > ///ark > > > > > > > > > -- > John Kopanas > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > Blog: http://www.kopanas.com > Conference: http://www.cusec.net > Twits: http://www.twitter.com/kopanas >-- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org Blog: http://www.kopanas.com Conference: http://www.cusec.net Twits: http://www.twitter.com/kopanas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
in your routes.rb add :collection => {:new=>:any} map.resources :users, :member => { :edit_email => :get, :edit_password => :get } do |user| user.resources :pictures,:collection => {:new=>:any} end It worked for me -- ruby.rails3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.