brianp
2009-Nov-26 08:38 UTC
Ajax.Updater & Only get, put, and delete requests are allowed.
Hey everyone,
I''m using the Ajax tabs method/example seen at:
http://actsasflinn.com/Ajax_Tabs/index.html
It renders partials without a problem but when I need it to render
from :controller => ''manage'', :action =>
''new'' I receive:
ActionController::MethodNotAllowed
Only get, put, and delete requests are allowed.
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/recognition_optimisation.rb:64:in `recognize_path''
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/route_set.rb:437:in `recognize''
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/route_set.rb:432:in `call''
running rake routes I can see:
GET /manage/new(.:format)
{:controller=>"manage", :action=>"new"}
and if I access the page on it''s own (root/manage/new) everything
works fine.
Any recommendations on how to get the desired content loaded?
thanks,
bp
--
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.
brianp
2009-Nov-26 08:45 UTC
Ajax.Updater & Only get, put, and delete requests are allowed.
Hey everyone,
I''m using the Ajax tabs method/example seen at:
http://actsasflinn.com/Ajax_Tabs/index.html
It renders partials without a problem but when I need it to render
from :controller => ''manage'', :action =>
''new'' I receive:
ActionController::MethodNotAllowed
Only get, put, and delete requests are allowed.
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/recognition_optimisation.rb:64:in `recognize_path''
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/route_set.rb:437:in `recognize''
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/route_set.rb:432:in `call''
running rake routes I can see:
GET /manage/new(.:format)
{:controller=>"manage", :action=>"new"}
and if I access the page on it''s own (root/manage/new) everything
works fine.
Any recommendations on how to get the desired content loaded?
thanks,
bp
--
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.
Jeffrey L. Taylor
2009-Nov-26 08:57 UTC
Re: Ajax.Updater & Only get, put, and delete requests are allowed.
Quoting brianp <brian.o.pearce-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Hey everyone, > > I''m using the Ajax tabs method/example seen at: http://actsasflinn.com/Ajax_Tabs/index.html > > It renders partials without a problem but when I need it to render > from :controller => ''manage'', :action => ''new'' I receive: > > ActionController::MethodNotAllowed > Only get, put, and delete requests are allowed. >The AJAX code is making a POST request. Change the routing to allow POSTs or change the template or RJS to make a GET request (probably add '':method => :get'') to parameter list. If the action does not alter the state, use the former, otherwise use the latter. E.g., is it okay if a search engine spider invokes the ''new'' action? From the name, I''d guess not. So change the routing to allow or even require POST requests. HTH, Jeffrey -- 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.
brianp
2009-Nov-26 09:18 UTC
Re: Ajax.Updater & Only get, put, and delete requests are allowed.
Hey Jeffery,
thanks for the quick reply.
I had a good feeling it was trying to make a post request.
I did try changing the :method => :post but this actually chokes the
method altogether. I get no response at all.
And the other option for changing my routing I''m not sure I know how
to do.
My manage related routes are currently:
map.resources :manage
map.resources :manage, :collection => { :available => :get }
How would I go about forcing :new to be :post ?
i tried something like:
map.resources :manage, :collection => { :new => :post } but this caues
the sever now to run.
On Nov 26, 12:57 am, "Jeffrey L. Taylor"
<r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org>
wrote:> Quoting brianp
<brian.o.pea...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>
> > Hey everyone,
>
> > I''m using the Ajax tabs method/example seen
at:http://actsasflinn.com/Ajax_Tabs/index.html
>
> > It renders partials without a problem but when I need it to render
> > from :controller => ''manage'', :action =>
''new'' I receive:
>
> > ActionController::MethodNotAllowed
> > Only get, put, and delete requests are allowed.
>
> The AJAX code is making a POST request. Change the routing to allow POSTs
or
> change the template or RJS to make a GET request (probably add
'':method =>
> :get'') to parameter list. If the action does not alter the state,
use the
> former, otherwise use the latter. E.g., is it okay if a search engine
spider
> invokes the ''new'' action? From the name, I''d
guess not. So change the
> routing to allow or even require POST requests.
>
> HTH,
> Jeffrey
--
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@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Jeffrey L. Taylor
2009-Nov-26 17:49 UTC
Re: Re: Ajax.Updater & Only get, put, and delete requests are allowed.
Brian, You are running into Rails/RESTful convention. In those conventions, the new action is a GET that returns the form for a new object. The create action expects a POST with the data for the new object. If this is not the semantics of your app or controller, either don''t use ''map.resources'' which does conform to the Rails/RESTful way, or change your actions and routes. So what does your ''new'' action do? Jeffrey Quoting brianp <brian.o.pearce-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Hey Jeffery, > > thanks for the quick reply. > > I had a good feeling it was trying to make a post request. > > I did try changing the :method => :post but this actually chokes the > method altogether. I get no response at all. > > And the other option for changing my routing I''m not sure I know how > to do. > > My manage related routes are currently: > map.resources :manage > map.resources :manage, :collection => { :available => :get } > > How would I go about forcing :new to be :post ? > > i tried something like: > map.resources :manage, :collection => { :new => :post } but this caues > the sever now to run. > > On Nov 26, 12:57 am, "Jeffrey L. Taylor" <r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> > wrote: > > Quoting brianp <brian.o.pea...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > Hey everyone, > > > > > I''m using the Ajax tabs method/example seen at:http://actsasflinn.com/Ajax_Tabs/index.html > > > > > It renders partials without a problem but when I need it to render > > > from :controller => ''manage'', :action => ''new'' I receive: > > > > > ActionController::MethodNotAllowed > > > Only get, put, and delete requests are allowed. > > > > The AJAX code is making a POST request. Change the routing to allow POSTs or > > change the template or RJS to make a GET request (probably add '':method => > > :get'') to parameter list. If the action does not alter the state, use the > > former, otherwise use the latter. E.g., is it okay if a search engine spider > > invokes the ''new'' action? From the name, I''d guess not. So change the > > routing to allow or even require POST requests. > > > > HTH, > > Jeffrey > > -- > > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
brianp
2009-Nov-26 18:04 UTC
Re: Ajax.Updater & Only get, put, and delete requests are allowed.
The ''new'' action creates 3 empty models and displays the form
to fill
in the properties for the 3 new objects (all from 1 form).
Create is followed from new to save the objects to the db etc via post
as expected.
So I suppose the best idea would be to find a way to make the
Ajax.Updater run via :get instead of :post. So I may keep my proper
RESTful resources.
The script for the Ajax.updater is:
function reloadPane(pane, src) {
new Ajax.Updater(pane, src, {asynchronous:1, evalScripts:true,
onLoading:function(request){pane.innerHTML=''<img
alt="Wait" src="/
images/spinner.gif" style="vertical-align:-3px" />
Loading...''}})
}
method:''delete''
I tried using:
function reloadPane(pane, src) {
new Ajax.Updater(pane, src, {asynchronous:1, evalScripts:true,
method:delete, onLoading:function(request){pane.innerHTML=''<img
alt="Wait" src="/images/spinner.gif"
style="vertical-align:-3px" />
Loading...''}})
}
This didn''t work but just now I found an example with:
method:''delete'' . Maybe the lack of quotes is what killed the
script.
I''ll try that as soon as I get home and post back.
Thanks for the help Jeffrey!
On Nov 26, 9:49 am, "Jeffrey L. Taylor"
<r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org>
wrote:> Brian,
>
> You are running into Rails/RESTful convention. In those conventions, the
> new action is a GET that returns the form for a new object. The create
action
> expects a POST with the data for the new object. If this is not the
semantics
> of your app or controller, either don''t use
''map.resources'' which does conform
> to the Rails/RESTful way, or change your actions and routes.
>
> So what does your ''new'' action do?
>
> Jeffrey
>
> Quoting brianp
<brian.o.pea...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>
> > Hey Jeffery,
>
> > thanks for the quick reply.
>
> > I had a good feeling it was trying to make a post request.
>
> > I did try changing the :method => :post but this actually chokes
the
> > method altogether. I get no response at all.
>
> > And the other option for changing my routing I''m not sure I
know how
> > to do.
>
> > My manage related routes are currently:
> > map.resources :manage
> > map.resources :manage, :collection => { :available => :get }
>
> > How would I go about forcing :new to be :post ?
>
> > i tried something like:
> > map.resources :manage, :collection => { :new => :post } but this
caues
> > the sever now to run.
>
> > On Nov 26, 12:57 am, "Jeffrey L. Taylor"
<r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org>
> > wrote:
> > > Quoting brianp
<brian.o.pea...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>
> > > > Hey everyone,
>
> > > > I''m using the Ajax tabs method/example seen
at:http://actsasflinn.com/Ajax_Tabs/index.html
>
> > > > It renders partials without a problem but when I need it to
render
> > > > from :controller => ''manage'', :action
=> ''new'' I receive:
>
> > > > ActionController::MethodNotAllowed
> > > > Only get, put, and delete requests are allowed.
>
> > > The AJAX code is making a POST request. Change the routing to
allow POSTs or
> > > change the template or RJS to make a GET request (probably add
'':method =>
> > > :get'') to parameter list. If the action does not alter
the state, use the
> > > former, otherwise use the latter. E.g., is it okay if a search
engine spider
> > > invokes the ''new'' action? From the name,
I''d guess not. So change the
> > > routing to allow or even require POST requests.
>
> > > HTH,
> > > Jeffrey
>
> > --
>
> > 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
athttp://groups.google.com/group/rubyonrails-talk?hl=en.
--
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@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Jeffrey L. Taylor
2009-Nov-26 18:28 UTC
Re: Re: Ajax.Updater & Only get, put, and delete requests are allowed.
Brian, Sounds good. Jeffrey Quoting brianp <brian.o.pearce-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> The ''new'' action creates 3 empty models and displays the form to fill > in the properties for the 3 new objects (all from 1 form). > > Create is followed from new to save the objects to the db etc via post > as expected. > > So I suppose the best idea would be to find a way to make the > Ajax.Updater run via :get instead of :post. So I may keep my proper > RESTful resources. > > The script for the Ajax.updater is: > > function reloadPane(pane, src) { > new Ajax.Updater(pane, src, {asynchronous:1, evalScripts:true, > onLoading:function(request){pane.innerHTML=''<img alt="Wait" src="/ > images/spinner.gif" style="vertical-align:-3px" /> Loading...''}}) > } > > method:''delete'' > > I tried using: > function reloadPane(pane, src) { > new Ajax.Updater(pane, src, {asynchronous:1, evalScripts:true, > method:delete, onLoading:function(request){pane.innerHTML=''<img > alt="Wait" src="/images/spinner.gif" style="vertical-align:-3px" /> > Loading...''}}) > } > > This didn''t work but just now I found an example with: > method:''delete'' . Maybe the lack of quotes is what killed the script. > I''ll try that as soon as I get home and post back.-- 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.
brianp
2009-Nov-26 19:26 UTC
Re: Ajax.Updater & Only get, put, and delete requests are allowed.
And for anyone following this thread with the same problem, by method:''delete'' i mean method:''get'' lol I copy & pasted from an example. On Nov 26, 10:28 am, "Jeffrey L. Taylor" <r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote:> Brian, > Sounds good. > > Jeffrey > > Quoting brianp <brian.o.pea...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > The ''new'' action creates 3 empty models and displays the form to fill > > in the properties for the 3 new objects (all from 1 form). > > > Create is followed from new to save the objects to the db etc via post > > as expected. > > > So I suppose the best idea would be to find a way to make the > > Ajax.Updater run via :get instead of :post. So I may keep my proper > > RESTful resources. > > > The script for the Ajax.updater is: > > > function reloadPane(pane, src) { > > new Ajax.Updater(pane, src, {asynchronous:1, evalScripts:true, > > onLoading:function(request){pane.innerHTML=''<img alt="Wait" src="/ > > images/spinner.gif" style="vertical-align:-3px" /> Loading...''}}) > > } > > > method:''delete'' > > > I tried using: > > function reloadPane(pane, src) { > > new Ajax.Updater(pane, src, {asynchronous:1, evalScripts:true, > > method:delete, onLoading:function(request){pane.innerHTML=''<img > > alt="Wait" src="/images/spinner.gif" style="vertical-align:-3px" /> > > Loading...''}}) > > } > > > This didn''t work but just now I found an example with: > > method:''delete'' . Maybe the lack of quotes is what killed the script. > > I''ll try that as soon as I get home and post back.-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
brianp
2009-Nov-27 01:42 UTC
[Solved] Re: Ajax.Updater & Only get, put, and delete requests are allowed.
function reloadPane(pane, src) {
new Ajax.Updater(pane, src, {method:''get'', asynchronous:1,
evalScripts:true, onLoading:function(request){pane.innerHTML=''<img
alt="Wait" src="/images/spinner.gif"
style="vertical-align:-3px" />
Loading...''}})
}
Makes the function work like desired. Now i just have to change my
render layout so it doesn''t load the entire page layout inside the
container =)
On Nov 26, 11:26 am, brianp
<brian.o.pea...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> And for anyone following this thread with the same problem, by
> method:''delete'' i mean method:''get'' lol
I copy & pasted from an
> example.
>
> On Nov 26, 10:28 am, "Jeffrey L. Taylor"
<r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org>
> wrote:
>
> > Brian,
> > Sounds good.
>
> > Jeffrey
>
> > Quoting brianp
<brian.o.pea...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>
> > > The ''new'' action creates 3 empty models and
displays the form to fill
> > > in the properties for the 3 new objects (all from 1 form).
>
> > > Create is followed from new to save the objects to the db etc via
post
> > > as expected.
>
> > > So I suppose the best idea would be to find a way to make the
> > > Ajax.Updater run via :get instead of :post. So I may keep my
proper
> > > RESTful resources.
>
> > > The script for the Ajax.updater is:
>
> > > function reloadPane(pane, src) {
> > > new Ajax.Updater(pane, src, {asynchronous:1, evalScripts:true,
> > > onLoading:function(request){pane.innerHTML=''<img
alt="Wait" src="/
> > > images/spinner.gif" style="vertical-align:-3px"
/> Loading...''}})
> > > }
>
> > > method:''delete''
>
> > > I tried using:
> > > function reloadPane(pane, src) {
> > > new Ajax.Updater(pane, src, {asynchronous:1, evalScripts:true,
> > > method:delete,
onLoading:function(request){pane.innerHTML=''<img
> > > alt="Wait" src="/images/spinner.gif"
style="vertical-align:-3px" />
> > > Loading...''}})
> > > }
>
> > > This didn''t work but just now I found an example with:
> > > method:''delete'' . Maybe the lack of quotes is
what killed the script.
> > > I''ll try that as soon as I get home and post back.
--
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@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.